Repository navigation
feat: Add web search tool, new Gemini models (flash-lite, 3.1-pro), and modern Python syntax - #5
Conversation
- 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
|
@FojleRabbiRabib thank you so much for the pr, sorry for the delay. Will take a look tomorrow |
There was a problem hiding this comment.
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_searchMCP 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_inlinereadsINLINE_CHUNK_HEAD_BYTESplusINLINE_CHUNK_TAIL_BYTESwithout capping their combined size toMAX_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.
| - **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 |
There was a problem hiding this comment.
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).
| - **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 |
| ### Example code style: | ||
| ```python | ||
| from typing import Optional, List | ||
| from pathlib import Path |
There was a problem hiding this comment.
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.
| from pathlib import Path |
There was a problem hiding this comment.
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
directorydefaults to current directory forconsult_gemini, but the MCP wrapper doesn't have that default — either add the default or fix the docs - The CONTRIBUTING.md code example imports
Pathbut never uses it
The model aliases and the modernization pass look good to me, happy to merge once the two main issues are sorted.
|
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 thanks for the contribution! |
Pull Request Description
Summary
Enhances gemini-bridge with web search capability, additional Gemini model support, and modern Python code quality improvements.
Type of Change
Related Issues
Changes Made
New Features:
web_searchMCP tool that leverages Gemini CLI's built-in web search capabilitiesgemini-2.5-flash-litemodel (alias:flash-lite)gemini-3.1-pro-previewmodel (alias:3.1-pro)Code Quality:
Optional[str],List[str]) to modern Python 3.9+ syntax (str | None,list[str])os.pathwithpathlib.Paththroughout the codebase for better cross-platform compatibilitytypingimportsDocumentation:
Testing:
Version:
Testing Performed
Manual Testing
consult_geminitool with basic queriesconsult_gemini_with_filestool with file attachmentsweb_searchtool with various queriesTest Environment
Automated Tests
pytest tests/test_mcp_server.py -v # All 27 tests passedTest Cases
Test case 1: Model normalization for new models
Expected:
gemini-2.5-flash-lite,gemini-3.1-pro-previewActual: ✅ 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_searchActual: ✅ All 3 tools visible
Breaking Changes
Documentation Updates
Performance Impact
Security Considerations
Deployment Notes
Checklist
Code Quality
Testing
Documentation
Compatibility
Additional Notes
The
web_searchtool works by prepending a search instruction to the query, leveraging Gemini CLI's native web search capabilities. No external dependencies were added.Screenshots/Logs
For Reviewers
Review Checklist
Questions for Author
Thank you for contributing to Gemini Bridge! 🙏