Repository navigation
Replies: 1 comment
|
+1, and a second reason for it: confinement, not only routing. I maintain an open-source MCP gateway and shipped MCP Apps relaying this week. I hit the routing problem you describe from the other side: I prefix tool names ( The same missing field has a security consequence. The spec defines With Two details that would matter for the second use:
What I do today, and where it stops: https://github.com/wellknownmcp/cortex-gateway/blob/main/docs/mcp-apps.md |
Uh oh!
There was an error while loading. Please reload this page.
Pre-submission Checklist
Your Idea
MCP Apps Spec Enhancement Proposal: Server Context in App Tool Calls
Summary
This proposal suggests adding an optional
contextfield totools/callrequests originating from MCP App Views. This enables deterministic tool routing in proxy/gateway scenarios without requiring session-based state tracking.Key Design Principle: Zero Developer Burden
The Host automatically injects the
contextfield - MCP Server developers don't need to change anything.app.callServerTool({ name: "save-color", arguments: {...} })context.resourceUribefore forwardingProblem Statement
When an MCP App iframe calls a tool using its original name (e.g.,
save-color), proxy servers that aggregate multiple MCP servers cannot determine which backend server should handle the request.Current Situation
MCP App developers use original tool names - The MCP Apps SDK calls tools by their original names:
Proxies enhance tool names - To avoid collisions, proxies prefix tool names with server identifiers:
save-colorcolor_picker_save-colorRouting ambiguity - When
tools/callarrives withname: "save-color", the proxy doesn't know which server to route to if multiple servers have tools with the same original name.Current Workaround
Proxies must track "active MCP App server" state using session IDs:
This works but has drawbacks:
Proposed Solution
Add an optional
contextfield totools/callparams when originating from MCP App Views:Example Flow
Host loads View from UI resource:
App developer writes normal code (no changes required):
Host automatically injects context before forwarding:
Proxy routes deterministically by parsing server identity from
context.resourceUri:Benefits
Specification Changes
1. Update
tools/callparams typeIn the spec's "Standard MCP Messages" section, add:
2. Host Behavior (Automatic Injection)
Add to the spec's Host behavior section:
3. Server/Proxy Behavior
Add guidance for proxy implementations:
Backward Compatibility
contextis optional - existing implementations continue to workcontextis absentDeveloper Experience
For MCP Server/App Developers
No changes required. Developers continue to write:
The Host handles context injection transparently.
For Host Implementers (Claude Desktop, VS Code, etc.)
Hosts need to:
resourceUrieach View was instantiated fromcontext.resourceUriwhen forwardingtools/callfrom ViewsThis is straightforward since Hosts already have this information from:
resources/readcall that loaded the ViewtoolInfopassed during View initializationFor Proxy/Gateway Implementers
Proxies can now route deterministically:
context.resourceUriin incomingtools/callui://server-name/path→"server-name"contextis absent (backward compatibility)Implementation Example
References
Next Steps
This proposal was drafted based on real-world experience implementing MCP Apps support in a proxy/gateway service (AI Proxy).
Scope
All reactions