Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions docs/tools-custom/mcp-tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ This section demonstrates how to integrate tools from external MCP (Model Contex

The `McpToolset` class is ADK's primary mechanism for integrating tools from an MCP server. When you include an `McpToolset` instance in your agent's `tools` list, it automatically handles the interaction with the specified MCP server. Here's how it works:

1. **Connection Management:** On initialization, `McpToolset` establishes and manages the connection to the MCP server. This can be a local server process (using `StdioConnectionParams` for communication over standard input/output) or a remote server (using `SseConnectionParams` for Server-Sent Events). The toolset also handles the graceful shutdown of this connection when the agent or application terminates.
1. **Connection Management:** On initialization, `McpToolset` establishes and manages the connection to the MCP server. This can be a local server process (using `StdioConnectionParams` for communication over standard input/output), a remote server using `SseConnectionParams` for Server-Sent Events, or a stateless HTTP-based connection with `StreamableHTTPConnectionParams`. The toolset also handles the graceful shutdown of this connection when the agent or application terminates. For better stability in production, you can configure timeouts like `timeout` and `sse_read_timeout` in the connection parameters.
2. **Tool Discovery & Adaptation:** Once connected, `McpToolset` queries the MCP server for its available tools (via the `list_tools` MCP method). It then converts the schemas of these discovered MCP tools into ADK-compatible `BaseTool` instances.
3. **Exposure to Agent:** These adapted tools are then made available to your `LlmAgent` as if they were native ADK tools.
4. **Proxying Tool Calls:** When your `LlmAgent` decides to use one of these tools, `McpToolset` transparently proxies the call (using the `call_tool` MCP method) to the MCP server, sends the necessary arguments, and returns the server's response back to the agent.
Expand Down Expand Up @@ -870,7 +870,6 @@ if __name__ == '__main__':
asyncio.run(async_main())
except Exception as e:
print(f"An error occurred: {e}")
```


## Key considerations
Expand Down Expand Up @@ -1279,4 +1278,4 @@ McpToolset(

* [Model Context Protocol Documentation](https://modelcontextprotocol.io/ )
* [MCP Specification](https://modelcontextprotocol.io/specification/)
* [MCP Python SDK & Examples](https://github.com/modelcontextprotocol/)
* [MCP Python SDK & Examples](https://github.com/modelcontextprotocol/)
Loading