feat(server): backport MCP Apps UI support to v20241105 - #4057
pjmsmithgoogle wants to merge 2 commits into
Conversation
## Description MCP Apps (interactive UI resources and tool metadata) was introduced only under the latest protocol version (`2026-07-28`). Many production MCP clients and host integrations, such as Gemini Enterprise, currently negotiate earlier MCP protocol versions (e.g., `2024-11-05`). When connecting with these clients, MCP Apps metadata and UI resource fetching were previously unavailable or stripped from tool manifests and resource handlers. In earlier MCP schemas (such as `2024-11-05`), the protocol did not define an `extensions` capability block on `ServerCapabilities`. Conforming with the specification and existing Toolbox convention for older schemas (see googleapis#3300), tools preserve and transmit their UI metadata via `_meta.ui` on `tools/list`. This change backports MCP Apps support to `v20241105`: - Preserves and serializes `_meta.ui` on tools in tool manifests (`tools/list`). - Supports reading registered UI resources via `resources/read`. - Shares UI metadata resolution logic in `internal/server/mcp/util/ui.go`. - Adds unit tests verifying UI metadata generation and serialization for `v20241105`. ## PR Checklist - [x] Make sure you reviewed [CONTRIBUTING.md](https://github.com/googleapis/mcp-toolbox/blob/main/CONTRIBUTING.md) - [x] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/mcp-toolbox/issues/new/choose) before writing your code! - [x] Ensure you have manually reviewed the entire diff before requesting a review - [x] Ensure the tests and linter pass - [x] Code coverage does not decrease (if any source code was changed) - [x] Appropriate docs were updated (if necessary) Fixes googleapis#4055
There was a problem hiding this comment.
Code Review
This pull request introduces support for UI metadata in tools and resources. It adds a utility function to resolve a tool's UI resource, updates tool manifest generation to include UI metadata, and enhances resource reading to attach UI metadata to resource contents. Additionally, UI resources and templates are now globally accessible. The review feedback suggests improving error handling in ResolveToolUIMetadata by returning a descriptive error when a specified UI resource is not registered, rather than silently returning an empty URI, and avoiding unnecessary defensive nil checks.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces support for UI metadata in tools and resources. It adds a utility function ResolveToolUIMetadata to resolve UI resources and templates, and updates the tool manifest generation to include this UI metadata under the "ui" key. Additionally, it updates resource resolution and reading handlers to globally support UI resources and templates, attaching UI metadata to the resource read results and contents. Unit tests have been updated to cover these changes. No review comments were provided, so there is no additional feedback.
Description
MCP Apps (interactive UI resources and tool metadata) was introduced only under the latest protocol version (
2026-07-28). Many production MCP clients and host integrations, such as Gemini Enterprise, currently negotiate earlier MCP protocol versions (e.g.,2024-11-05). When connecting with these clients, MCP Apps metadata and UI resource fetching were previously unavailable or stripped from tool manifests and resource handlers.In earlier MCP schemas (such as
2024-11-05), the protocol did not define anextensionscapability block onServerCapabilities. Conforming with the specification and existing Toolbox convention for older schemas (see #3300), tools preserve and transmit their UI metadata via_meta.uiontools/list.This change backports MCP Apps support to
v20241105:_meta.uion tools in tool manifests (tools/list).resources/read.internal/server/mcp/util/ui.go.v20241105.PR Checklist
🛠️ Fixes #4055