8000 feat: Add web search tool, new Gemini models (flash-lite, 3.1-pro), and modern Python syntax by FojleRabbiRabib · Pull Request #5 · eLyiN/gemini-bridge · GitHub
[go: up one dir, main page]

Skip to content

feat: Add web search tool, new Gemini models (flash-lite, 3.1-pro), and modern Python syntax - #5

Merged
eLyiN merged 2 commits into
eLyiN:masterfrom
FojleRabbiRabib:master
Apr 18, 2026
Merged

eLyiN merged 2 commits into
eLyiN:masterfrom
FojleRabbiRabib:master

Conversation

@FojleRabbiRabib
@FojleRabbiRabib FojleRabbiRabib commented Mar 2, 2026 •
Copy link
Copy Markdown
Contributor

Pull Request Description

Summary

Enhances gemini-bridge with web search capability, additional Gemini model support, and modern Python code quality improvements.

Type of Change

  • ✨ New feature (non-breaking change which adds functionality)
  • 📚 Documentation update (improvements or additions to documentation)
  • 🧹 Code cleanup (refactoring, formatting, removing unused code)
  • 🧪 Test addition or modification
  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • ⚡ Performance improvement
  • 🔧 Configuration change

Related Issues

Changes Made

New Features:

  • Added web_search MCP tool that leverages Gemini CLI's built-in web search capabilities
  • Added support for gemini-2.5-flash-lite model (alias: flash-lite)
  • Added support for gemini-3.1-pro-preview model (alias: 3.1-pro)

Code Quality:

  • Migrated from old type hints (Optional[str], List[str]) to modern Python 3.9+ syntax (str | None, list[str])
  • Replaced os.path with pathlib.Path throughout the codebase for better cross-platform compatibility
  • Removed unnecessary typing imports

Documentation:

  • Updated README.md with new model options and web_search tool
  • Updated CLAUDE.md with complete model alias list
  • Updated CHANGELOG.md with 1.3.0 release notes
  • Updated AGENTS.md with model support section
  • Updated CONTRIBUTING.md with modern code style examples

Testing:

  • Added 5 new tests for model normalization and web_search functionality
  • All 27 tests passing

Version:

  • Bumped version from 1.2.0 to 1.3.0

Testing Performed

Manual Testing

  • Tested consult_gemini tool with basic queries
  • Tested consult_gemini_with_files tool with file attachments
  • Tested web_search tool with various queries
  • Tested error handling scenarios
  • Verified all model aliases work correctly

Test Environment

  • OS: Linux 5.15.0-160-generic
  • Python: 3.10 / 3.11
  • MCP: 1.26.0

Automated Tests

pytest tests/test_mcp_server.py -v
# All 27 tests passed

Test Cases

Test case 1: Model normalization for new models

python3 -c "from src.mcp_server import _normalize_model_name; \
print(_normalize_model_name('flash-lite')); \
print(_normalize_model_name('3.1-pro'))"

Expected: gemini-2.5-flash-lite, gemini-3.1-pro-preview
Actual: ✅ Passed

Test case 2: web_search tool functionality
Expected: Tool prepends search instruction to query
Actual: ✅ Passed

Test case 3: MCP Inspector shows 3 tools
Expected: consult_gemini, consult_gemini_with_files, web_search
Actual: ✅ All 3 tools visible

Breaking Changes

  • No breaking changes

Documentation Updates

  • Updated README.md
  • Updated CHANGELOG.md
  • Updated CONTRIBUTING.md
  • Updated CLAUDE.md
  • Updated AGENTS.md
  • Updated inline code comments (no changes needed)

Performance Impact

  • No performance impact
  • Performance improvement (describe below)
  • Performance regression (justify below)

Security Considerations

  • No security implications

Deployment Notes

  • No special deployment requirements

Checklist

Code Quality

  • Code follows the project's style guidelines
  • Self-review of the code has been performed
  • Code is well-commented, particularly in hard-to-understand areas
  • No unnecessary complexity added

Testing

  • Changes have been tested locally
  • All existing functionality still works
  • New functionality works as expected
  • Error cases are handled appropriately

Documentation

  • Documentation has been updated
  • CHANGELOG.md has been updated
  • Examples have been updated

Compatibility

  • Changes maintain backward compatibility
  • Works with all supported Python versions (3.10+)
  • Works with all Gemini models (flash, pro, flash-lite, 3-pro, 3-flash, 3.1-pro, auto)

Additional Notes

The web_search tool works by prepending a search instruction to the query, leveraging Gemini CLI's native web search capabilities. No external dependencies were added.

Screenshots/Logs

pytest tests/test_mcp_server.py -v
============================= test session starts ==============================
platform linux -- Python 3.11.14, pytest-9.0.2, pluggy-1.6.0
collected 27 items

tests/test_mcp_server.py::test_normalize_model_name_flash_lite PASSED    [ 11%]
tests/test_mcp_server.py::test_normalize_model_name_3_series PASSED      [ 14%]
tests/test_mcp_server.py::test_normalize_model_name_3_1_series PASSED    [ 18%]
tests/test_mcp_server.py::test_web_search_prepends_search_instruction PASSED [ 96%]
tests/test_mcp_server.py::test_web_search_passes_model_and_timeout PASSED [100%]

============================== 27 passed in 0.33s ===============================

For Reviewers

Review Checklist

  • Code review completed
  • Architecture/design review completed
  • Security review completed (no security implications)
  • Documentation review completed
  • Testing verification completed

Questions for Author

  • None at this time

Thank you for contributing to Gemini Bridge! 🙏

- Add web_search MCP tool for web queries via Gemini CLI
- Add support for gemini-2.5-flash-lite and gemini-3.1-pro-preview models
- Migrate to modern Python type hints (str | None, list[str])
- Replace os.path with pathlib.Path for better cross-platform support
- Update documentation (README, CLAUDE.md, CHANGELOG, AGENTS, CONTRIBUTING)
- Bump version to 1.3.0
- Add 5 new tests for models and web_search tool
@eLyiN
eLyiN commented Apr 15, 2026
Copy link
Copy Markdown
Owner

@FojleRabbiRabib thank you so much for the pr, sorry for the delay. Will take a look tomorrow

10000

Copilot AI left a comment
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new MCP web_search tool and extends Gemini model alias support while modernizing the codebase’s typing/path handling and updating docs/tests accordingly.

Changes:

  • Add web_search MCP tool (implemented as a prompt pattern over Gemini CLI).
  • Extend model normalization with new aliases (flash-lite, 3.1-pro) and add/adjust tests.
  • Modernize Python code (PEP 604 type unions, built-in generics, pathlib.Path) and bump version to 1.3.0 with documentation updates.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/mcp_server.py Adds web_search, new model aliases, and migrates path/type usage to modern Python.
tests/test_mcp_server.py Adds tests for new model normalization and web_search behavior.
pyproject.toml Bumps project version to 1.3.0.
src/__init__.py Bumps package __version__ to 1.3.0.
README.md Documents third tool and expanded model alias list.
CONTRIBUTING.md Updates style guidance/examples for modern typing/path conventions.
CLAUDE.md Expands documented model alias list and adds web_search section.
CHANGELOG.md Adds 1.3.0 release notes.
AGENTS.md Updates testing guidance and documents model support.
Comments suppressed due to low confidence (1)

src/mcp_server.py:166

  • When a file exceeds MAX_INLINE_FILE_BYTES, _read_file_for_inline reads INLINE_CHUNK_HEAD_BYTES plus INLINE_CHUNK_TAIL_BYTES without capping their combined size to MAX_INLINE_FILE_BYTES. If those env vars are configured too large, the “max inline bytes per file” safeguard can be exceeded and the total-bytes accounting (bytes_counted) will undercount what’s actually sent.
    head_bytes = max(INLINE_CHUNK_HEAD_BYTES, 1)
    tail_bytes = max(INLINE_CHUNK_TAIL_BYTES, 0)

    with abs_path_obj.open("rb") as handle:
        head = handle.read(head_bytes)
        tail = b""
        if tail_bytes > 0 and size > head_bytes:
            handle.seek(max(size - tail_bytes, 0))
            tail = handle.read(tail_bytes)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread CHANGELOG.md Outdated
- **Extended model aliases**: Full list now includes flash, pro, flash-lite, 3-pro, 3-flash, 3.1-pro, and auto router

### Changed
- **Modern Python syntax**: Migrated to Python 3.9+ type hints (`str | None`, `list[str]`) throughout codebase
Copilot AI Apr 15, 2026
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changelog claims the codebase migrated to “Python 3.9+ type hints (str | None, list[str])”, but str | None requires Python 3.10+. Since pyproject.toml sets requires-python = ">=3.10", this entry should say 3.10+ (or adjust the code to be 3.9-compatible).

Suggested change
- **Modern Python syntax**: Migrated to Python 3.9+ type hints (`str | None`, `list[str]`) throughout codebase
- **Modern Python syntax**: Migrated to Python 3.10+ type hints (`str | None`, `list[str]`) throughout codebase

Copilot uses AI. Check for mistakes.
Comment thread README.md Resolved
Comment thread CONTRIBUTING.md Outdated
### Example code style:
```python
from typing import Optional, List
from pathlib import Path
Copilot AI Apr 15, 2026
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the CONTRIBUTING example snippet, from pathlib import Path is imported but not used. Consider either using Path in the example (e.g., for directory handling) or removing the import to keep the style example clean.

Suggested change
from pathlib import Path

Copilot uses AI. Check for mistakes.
@eLyiN eLyiN left a comment
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, thanks for putting this together — solid work overall, the pathlib/type hints cleanup is clean and the tests are well structured.

Two things I need fixed before merging:

1. Python 3.9 compatibility is broken

str | None and list[str] as runtime annotations require Python 3.10+, but pyproject.toml still says requires-python = ">=3.9". Anyone on 3.9 will get a TypeError at import time.

Either bump requires-python = ">=3.10" in pyproject.toml (and update CONTRIBUTING.md/CHANGELOG which already quietly dropped 3.9 from the testing matrix), or add from __future__ import annotations at the top of mcp_server.py to keep 3.9 support. I'd go with bumping the requirement — the __future__ import is a bit of a hack and 3.9 is EOL anyway.

2. web_search doesn't actually do web search

Right now it just prepends a natural language instruction to the prompt and calls execute_gemini_simple. Whether Gemini actually searches the web depends entirely on the model's mood — there's no CLI flag being passed to enable it. The Gemini CLI has a --tools flag for this (e.g. google_search), that's what should be used here.

The test also only checks that the prompt string is present, not that search actually happens. And the docstring saying "Returns: Gemini's search response with web sources" is overpromising.

Either wire up the actual flag, or if that's not feasible, rename the tool to something more honest like ask_gemini_with_search_hint and update the docs to reflect that it's best-effort.


A couple of smaller things Copilot also flagged that are worth fixing while you're at it:

  • README says directory defaults to current directory for consult_gemini, but the MCP wrapper doesn't have that default — either add the default or fix the docs
  • The CONTRIBUTING.md code example imports Path but never uses it

The model aliases and the modernization pass look good to me, happy to merge once the two main issues are sorted.

@FojleRabbiRabib
Copy link
Copy Markdown
Contributor Author

Thanks for the thoughtful review and clear feedback — really appreciate it. I’ll go through these points and get everything fixed tomorrow.

Model Support:
- Add support for gemini-3.1-flash-lite-preview (3.1-flash-lite alias)
- Fix 2.5-lite alias to correctly map to gemini-2.5-flash-lite
- Update all documentation to include new model aliases

Error Handling:
- Improve error messages with helpful suggestions
- Add specific guidance for model availability issues
- Add authentication error prompts with gemini auth login
- Enhance timeout and missing CLI error messages

Documentation:
- Fix Python version requirement (3.10+ instead of 3.9+)
- Update web_search description to be honest about best-effort nature
- Remove false "default" parameter claims from tool descriptions
- Remove unused Path import from CONTRIBUTING example
- Update CHANGELOG to reflect 34 tests and all improvements

Testing:
- Add 7 new tests for model support and error handling
- All 34 tests passing

Resolves PR review feedback for web search accuracy and model support.
@FojleRabbiRabib
FojleRabbiRabib requested a review from eLyiN April 18, 2026 10:51
@eLyiN eLyiN left a comment
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image

@eLyiN
eLyiN merged commit b660cb6 into eLyiN:master Apr 18, 2026
4 checks passed
@eLyiN
eLyiN commented Apr 18, 2026
Copy link
Copy Markdown
Owner

@FojleRabbiRabib thanks for the contribution!

@eLyiN eLyiN linked an issue Apr 18, 2026 that may be closed by this pull request
3 of 11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Web search (gemini cli already supports this)

3 participants

0