Google GenAI Adapter
This module implements the Google GenAI adapter.
Example Usage:
with MCPAdapt(StdioServerParameters(command="uv", args=["run", "src/echo.py"]), GoogleGenAIAdapter()) as tools: print(tools)
GoogleGenAIAdapter
Bases: ToolAdapter
Adapter for the google.genai
package.
Note that the google.genai
package do not support async tools at this time so we
write only the adapt method.
Source code in src/mcpadapt/google_genai_adapter.py
adapt
adapt(
func: Callable[[dict | None], CallToolResult],
mcp_tool: Tool,
) -> tuple[
Tool,
tuple[str, Callable[[dict | None], CallToolResult]],
]
Adapt a MCP tool to a Google GenAI tool.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
func
|
Callable[[dict | None], CallToolResult]
|
The function to adapt. |
required |
mcp_tool
|
Tool
|
The MCP tool to adapt. |
required |
Returns:
Type | Description |
---|---|
tuple[Tool, tuple[str, Callable[[dict | None], CallToolResult]]]
|
A Google GenAI tool. |
Source code in src/mcpadapt/google_genai_adapter.py
async_adapt
async_adapt(
func: Callable[
[dict | None], Coroutine[Any, Any, CallToolResult]
],
mcp_tool: Tool,
) -> tuple[
Tool,
tuple[
str,
Callable[
[dict | None],
Coroutine[Any, Any, CallToolResult],
],
],
]
Adapt a MCP tool to a Google GenAI tool.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
func
|
Callable[[dict | None], Coroutine[Any, Any, CallToolResult]]
|
The function to adapt. |
required |
mcp_tool
|
Tool
|
The MCP tool to adapt. |
required |
Returns:
Type | Description |
---|---|
tuple[Tool, tuple[str, Callable[[dict | None], Coroutine[Any, Any, CallToolResult]]]]
|
A Google GenAI tool. |