Skip to content

Revamping of MCP Tools page - #2081

Open
zyantw wants to merge 10 commits into
mainfrom
zyantw-patch-7
Open

Revamping of MCP Tools page#2081
zyantw wants to merge 10 commits into
mainfrom
zyantw-patch-7

Conversation

@zyantw

@zyantw zyantw commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

This PR consolidates several pending documentation updates into a unified, restructured mcp-tools.md guide. It improves the Information Architecture (IA) by grouping deployment, authentication, and transport types. Grounds abstract concepts with concrete code examples separated by language.
It also applies some UX principles to improve readability and searchability.

Rendered view: https://deploy-preview-2081--adk-docs-preview.netlify.app/tools-custom/mcp-tools-2/


PR Consolidation Mapping

The following table maps the specific lines from the previous disparate PRs to their new homes in the revamped draft:

PR Reference Original Lines (PR) New Lines (Draft) Change Description
#1232 49-74 514-551 Added Accessing MCP Resources section, detailing how to use list_resources() and read_resource(name).
#1443 51 600-660 Added Experimental UI Rendering section, including the Mermaid sequence diagram and code examples for meta.ui.resourceUri.
#1188 & #1186 43 556-596 Integrated connection timeouts (timeout, sse_read_timeout) into StreamableHTTPConnectionParams for production stability.

--

Jetski report

  1. High-Level Agent Export (to_mcp_server)
    Lines 300–316 correctly implement the ADK agent-to-MCP pattern verified against
    google.adk.tools.mcp_tool._agent_to_mcp.py and google.adk.tools.mcp_tool.init.py

  2. Streamable HTTP & SSE Remote Authentication
    Lines 473–504 and 574–584 properly configure headers across both Python and TypeScript, matching
    MCPSessionManager

  3. UI Rendering Tool Registration
    Lines 624–662 declare UI widgets inside list_tools() using meta={"ui": {"resourceUri": "..."}}. This accurately reflects how MCPTool inspects tool schema definitions to emit UiWidget actions to the client.


1. Key Improvements Made in the Revamp

A. Information Architecture & Readability

  • Halved Page Length (1,279 lines → ~650 lines): Removed redundant explanations, boilerplate code, and deeply nested text blocks in favor of scannable, structured tables and steps. That info is already in the draft of PR Create advanced-mcp-tools page to split content #2122
  • Mermaid Visualizations:
    • Core Architecture Flow: Replaced text-heavy handshake explanations with an interactive Mermaid sequence diagram (LlmAgent $\leftrightarrow$ McpToolset $\leftrightarrow$ MCP Server).
    • Experimental UI Rendering Flow: Added a sequence diagram illustrating the MCP App metadata flow from tool schema detection to client UI widget rendering.
  • Architectural Decision Matrix: Added the "Compare tools" comparison table contrasting:
    1. Direct MCP Integration (McpToolset)
    2. Sub-Agent Delegation (AgentTool)
    3. Agent-Exposed MCP Server (to_mcp_server)

B. New Features & Modernized APIs

Feature Production (adk.dev) PR #2081 (Revamped)
Agent-to-MCP Export Not covered; only showed manual low-level MCP server creation with mcp.server.lowlevel.Server. Added native to_mcp_server(agent): Demonstrates one-line compilation of an LlmAgent into a standard FastMCP server.
MCP Resources Only briefly mentioned use_mcp_resources=True. Full Resource Discovery & Reading Guide: Demonstrates direct use of list_resources() and read_resource(name) across Python and TypeScript.
UI Rendering / MCP Apps Not covered. Added Experimental UI Widgets: Explains meta.ui.resourceUri declaration in tool registration schemas and how the ADK Web UI renders interactive widgets.
Modern Transports & Timeouts Relied primarily on legacy SseConnectionParams without connection timeouts. Standardized StreamableHTTPConnectionParams: Includes explicit timeout and sse_read_timeout settings.
Environment-Aware Transport Not covered. Production vs. Local Branching: Practical snippet demonstrating automatic switching between StreamableHTTPConnectionParams (Cloud Run K_SERVICE) and StdioConnectionParams (local dev).
CLI & Framework Syntax Included deprecated CLI flags (--staging_bucket). Modernized CLI Options: Cleaned adk deploy commands for Agent Engine and Cloud Run.

This PR consolidates several pending documentation updates into a unified, restructured `mcp-tools.md` guide. It improves the Information Architecture (IA) by grouping deployment, authentication, and transport types. Grounds abstract concepts with concrete, production-ready code examples.

-  Key Improvements
* **Feature Completeness:** Integrated documentation for MCP Resources, Experimental UI Widgets, and Connection Timeouts.
* **Technical Accuracy:** Standardized authentication examples to use native ADK parameters (`AuthScheme`, `AuthCredential`) instead of manual headers. Corrected Cloud Run transport examples to utilize `StreamableHTTPConnectionParams`.
* **Better UX & IA:** Replaced text-heavy descriptions with Mermaid sequence diagrams (e.g., UI rendering flow). Elevated critical deployment requirements (like absolute paths and environment-aware connections) for better scannability.

---

## PR Consolidation Mapping

The following table maps the specific lines from the previous disparate PRs to their new homes in the revamped draft:

| PR Reference | Original Lines (PR) | New Lines (Draft) | Change Description |
| :--- | :--- | :--- | :--- |
| **#1234** | 49-74 | 343-436 | Added **Accessing MCP Resources** section, detailing how to use `list_resources()` and `read_resource(name)`. |
| **#1443** | 51 | 472-509 | Added **Experimental UI Rendering** section, including the Mermaid sequence diagram and code examples for `meta.ui.resourceUri`. |
| **#1188 & #1186** | 43 | 93-100 | Integrated connection timeouts (`timeout`, `sse_read_timeout`) into `StreamableHTTPConnectionParams` for production stability. |

## Review Notes
All code snippets have been verified for consistency with Jetski. The environment-aware transport selector now correctly branches between `StdioConnectionParams` (local) and `StreamableHTTPConnectionParams` (production).
@zyantw zyantw self-assigned this Aug 5, 2026
@netlify

netlify Bot commented Aug 5, 2026

Copy link
Copy Markdown

Deploy Preview for adk-docs-preview ready!

Name Link
🔨 Latest commit a0490ce
🔍 Latest deploy log https://app.netlify.com/projects/adk-docs-preview/deploys/6a7ba06eb7e2fe0009f3740a
😎 Deploy Preview https://deploy-preview-2081--adk-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@zyantw
zyantw marked this pull request as draft August 6, 2026 22:10
@zyantw zyantw changed the title Revamping of MCP Tools page [Still a draft] Revamping of MCP Tools page Aug 6, 2026
@zyantw
zyantw requested a review from joefernandez August 7, 2026 22:34
@zyantw
zyantw marked this pull request as ready for review August 11, 2026 22:37

## Further resources

Once you understand the basics, explore [Advanced use cases](/advanced-mcp-tools) for complex implementations and custom integrations.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I can update this section once the page for PR #2122 is approved. @joefernandez

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@zyantw - to publish this properly, you should combine the changes of this PR and PR 2122 so that we don't have a temporary loss of content when publishing this cut-down version

zyantw added a commit that referenced this pull request Aug 11, 2026
This PR introduces the new **Advanced MCP Configuration Guide** (`docs/tools-custom/advanced-mcp-tools.md`), extracting advanced integration patterns, low-level lifecycle hooks, and production deployment architectures into a dedicated reference. This complements the core MCP guide ([#2081](#2081)) by keeping the quickstart focused while providing enterprise patterns for advanced developers.

---

## Key Improvements & Information Architecture

### 1. Developer Decision Matrix
- Added a lookup table at the top that maps common engineering requirements (multi-tenant auth, destructive tool safety, progress bars, containerization) to specific ADK APIs.

### 2. Prioritization by Real-World Frequency
The guide is structured progressively from high-demand configurations to specialized edge cases:
1. **Dynamic Authentication & Per-User Headers (`header_provider`)** — Multi-tenant token injection using `ReadonlyContext`.
2. **Human-in-the-Loop & Tool Confirmations (`require_confirmation`)** — Guardrails for destructive database/file operations.
3. **Real-Time Progress Tracking (`progress_callback`)** — Both global functions and context-aware session factories (`ProgressCallbackFactory`).
4. **Standalone Runner Execution (Outside `adk web`)** — Embedding agents into FastAPI/CLI backends with graceful `await toolset.close()` teardown.
5. **Enterprise Cloud Deployment Architectures** — Cloud Run stateless services (`StreamableHTTPConnectionParams`), GKE Pod Sidecars, and Vertex AI Agent Runtime.
6. **Tool Namespacing & Disambiguation (`tool_name_prefix`)** — Resolving naming collisions when combining multiple MCP servers.
7. **Bi-directional Protocol Hooks** — Handlers for server-initiated sampling (`sampling_callback`) and authentication challenges (`elicitation_callback`).
8. **Diagnostic Logging (`errlog`)** — Subprocess STDERR redirection for troubleshooting.

---

## Technical Verification Report against `google/adk-python`

All code examples, class imports, and parameter signatures in this PR were verified against the latest `google/adk-python` codebase:

| Feature / Snippet | Verification in `google/adk-python` | Verification Status |
| :--- | :--- | :--- |
| **`header_provider`** | [`mcp_toolset.py:L113-L119`](file:///usr/local/google/home/zyanya/.gemini/jetski/scratch/adk_review/adk-python/src/google/adk/tools/mcp_tool/mcp_toolset.py#L113-L119) & [`L346-L352`](file:///usr/local/google/home/zyanya/.gemini/jetski/scratch/adk_review/adk-python/src/google/adk/tools/mcp_tool/mcp_toolset.py#L346-L352) | Verified: Accepts `Callable[[ReadonlyContext], dict[str, str] \| Awaitable[dict[str, str]]]` and injects headers dynamically on each session call. |
| **`require_confirmation`** | [`mcp_toolset.py:L112`](file:///usr/local/google/home/zyanya/.gemini/jetski/scratch/adk_review/adk-python/src/google/adk/tools/mcp_tool/mcp_toolset.py#L112) & [`function_tool.py:L278-L340`](file:///usr/local/google/home/zyanya/.gemini/jetski/scratch/adk_review/adk-python/src/google/adk/tools/function_tool.py#L278-L340) | Verified: Supports both boolean flags and callable predicates receiving tool arguments. |
| **`progress_callback` & Factory** | [`mcp_toolset.py:L120`](file:///usr/local/google/home/zyanya/.gemini/jetski/scratch/adk_review/adk-python/src/google/adk/tools/mcp_tool/mcp_toolset.py#L120) & [`mcp_tool.py:L496-L515`](file:///usr/local/google/home/zyanya/.gemini/jetski/scratch/adk_review/adk-python/src/google/adk/tools/mcp_tool/mcp_tool.py#L496-L515) | Verified: Supports standard `ProgressFnT` as well as `ProgressCallbackFactory` for modifying `ToolContext.state`. |
| **`Runner` Lifecycle Teardown** | [`mcp_toolset.py:L487-L499`](file:///usr/local/google/home/zyanya/.gemini/jetski/scratch/adk_review/adk-python/src/google/adk/tools/mcp_tool/mcp_toolset.py#L487-L499) | Verified: `await toolset.close()` safely terminates the underlying `MCPSessionManager` and closes open subprocesses/streams. |
| **`StreamableHTTPConnectionParams`** | [`mcp_session_manager.py:L312-L339`](file:///usr/local/google/home/zyanya/.gemini/jetski/scratch/adk_review/adk-python/src/google/adk/tools/mcp_tool/mcp_session_manager.py#L312-L339) | Verified: Matches Pydantic model definition with `url`, `headers`, `timeout`, and `sse_read_timeout`. |
| **`tool_name_prefix`** | [`mcp_toolset.py:L108`](file:///usr/local/google/home/zyanya/.gemini/jetski/scratch/adk_review/adk-python/src/google/adk/tools/mcp_tool/mcp_toolset.py#L108) | Verified: Passed through to `BaseToolset` to prefix all tool declarations and prevent namespace collisions. |
| **`sampling_callback` & `elicitation_callback`** | [`mcp_toolset.py:L122-L125`](file:///usr/local/google/home/zyanya/.gemini/jetski/scratch/adk_review/adk-python/src/google/adk/tools/mcp_tool/mcp_toolset.py#L122-L125) | Verified: Forwarded to `MCPSessionManager` for bi-directional protocol handling. |
| **CLI Deployment Commands** | [`cli_tools_click.py:L2229-L2770`](file:///usr/local/google/home/zyanya/.gemini/jetski/scratch/adk_review/adk-python/src/google/adk/cli/cli_tools_click.py#L2229-L2770) | Verified: Commands use active flags and omit deprecated arguments (such as `--staging_bucket`). |

---

## Verification Checklist

- [x] Code snippets follow canonical `from google.adk.agents import LlmAgent` imports.
- [x] Code blocks include multi-language tabs (Python, TypeScript, Java) where applicable.
- [x] All parameters match current Pydantic models in `google-adk` v2.x.
- [x] Tested markdown rendering, tables, and code block formatting.
<span class="lst-supported">Supported in ADK</span><span class="lst-python">Python v0.3.10</span><span class="lst-typescript">Typescript v0.2.0</span><span class="lst-go">Go v0.1.0</span><span class="lst-java">Java v0.1.0</span>
</div>

## What is Model Context Protocol (MCP)?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

remove. don't stack headers. The paragraph below is the intro


## What is Model Context Protocol (MCP)?

The **Model Context Protocol (MCP)** is an open standard for connecting Large Language Models (LLMs) to external data sources, tools, and systems. Think of it as a universal connection mechanism that simplifies how LLMs obtain context, execute actions, and interact with various systems.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LLMs --> generative AI models


## Core architecture and concepts

MCP follows a client-server architecture, defining how data or resources, interactive templates or prompts, and actionable functions or tools are exposed by an MCP server and consumed by an MCP client, which could be an LLM host application or an AI agent.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Add a sentence explaining that you use the McpToolset class as an interface between MCP Servers and ADK agents. Also mention that it's possible to configure an ADK server as an MCP server for use by other client systems.


Before you begin, ensure you have the following set up:

### Checklist

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

remove. you don't need this header


When you start building with the Model Context Protocol (MCP) and ADK, these key architectural differences will help you design more stable and efficient agents.

### Compare tools

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

remove; use the prior header to introduce this topic; you don't need a second one


### Compare tools

| Dimension | **Direct MCP Tool Integration** (`McpToolset`) | **Specialized Sub-Agent Delegation** (`AgentTool`) | **Agent-Exposed MCP Server** (`to_mcp_server`) |

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

  1. The names of these implementation options need to be carried through to the headings of later sections. Right now, it's hard to figure our what implementation guides match to these options.
  2. Recommend linking these implementation options to sections of the guide.

## Universal Setup Rules

1. **Absolute Paths**: File system MCP servers require absolute path arguments: `os.path.abspath(...)`. Relative paths cause runtime resolution errors in subprocesses.
2. **Package Discovery**: When running `adk web`, ensure an `__init__.py` file exists inside your agent folder so ADK can import the package.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

not clear what this has to do with MCP implementations


While your agent preserves its session state during lifecycle events, it **does not** automatically re-establish active MCP connections upon restoration. It will re-initialize the connection as needed.

## Universal Setup Rules

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this section seems out of place. Is this actually applicable to all MCP implementations?


## Further resources

Once you understand the basics, explore [Advanced use cases](/advanced-mcp-tools) for complex implementations and custom integrations.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@zyantw - to publish this properly, you should combine the changes of this PR and PR 2122 so that we don't have a temporary loss of content when publishing this cut-down version

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

after addressing the comments provided, and getting the right structure, let's overwrite the existing mcp-tools.md page with this updated content instead of having a separate page

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.

2 participants