| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Add google.genai.mcp.with_allowed_tools so callers can expose a subset of MCP session tools to the model and AFC map without changing bare ClientSession behavior. Fixes googleapis#1089.
|
@Venkaiahbabuneelam hey — opened this for #1089. Passing an MCP session in tools= currently expands every tool from list_tools() into the model schemas + AFC map. allowed_function_names only limits what the model can pick on the wire, so unused tools still show up, which isnt really what people want here. Went with an opt-in wrapper instead so bare sessions stay the same: from google.genai import mcp as genai_mcp
tools=[genai_mcp.with_allowed_tools(session, ["tool_a", "tool_b"])]Filters in list_tools() and blocks disallowed call_tool() calls, so the declarations and adapter map dont get out of sync. Happy to tweak the API if youd rather it live somewhere else. |
Sorry, something went wrong.
Make is_mcp_client_session a TypeGuard and accept allowlist wrappers in McpToGenAiToolAdapter so list_tools calls type-check under mypy.
|
@Venkaiahbabuneelam quick follow-up — mypy was failing because is_mcp_client_session() didnt narrow the union, so tool.list_tools() looked unsafe. Pushed a fix that makes that check a TypeGuard and lets the adapter accept the allowlist wrapper. Local mypy (same as CI) is clean now (Success: no issues found in 36 source files). Looks like the new workflow run is waiting on approval to start — whenever you can re-run / approve checks thatd be great. |
Sorry, something went wrong.
|
@Venkaiahbabuneelam sorry about the mypy noise on this one — that was on me. I missed that the session check wasnt narrowing the type, so CI blew up on list_tools(). Just pushed a fix for it. If you get a sec, could you re-approve / re-run the checks? Appreciate it. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Summary
Usage
Test plan