Skip to content

WebMCP convergence #797

Description

@ochafik

Option 2 below seems best, as discussed at today's meeting (I'll send a PR along its lines)

Option 1: Support new WebMCP mime type for resources

Strawman proposal we've just brainstormed on w/ @liady (as alternative to #796)

  • New mime type: text/html;profile=webmcp
  • Tool._meta.ui.resourceUri points to an WebMcp page
  • Tool result CAN have structuredContent, which gets encoded as url fragment params of the iframe URL, e.g. in this case #query=...
import { registerAppTool, registerAppResource } from "@modelcontextprotocol/ext-apps/server";
import { McpServer } from "@modelcontextprotocol/sdk/...";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/...";

const server = new McpServer({name: 'Example Server', version: '1.0.0', webMcp: 'required'});

const uiHtml = `
  document.modelContext.registerTool({ name: 'start', description: ..., inputSchema: ..., execute: ... }) 
`;

const resourceUri = 'ui://example';

registerAppResource(server, {
  uri: resourceUri,
  mimeType: 'text/html;profile=webmcp',
  content: uiHtml,
  _meta: {
    ui: {
      csp: {
        connectDomains: ['api.myhost.com']
      }
    }
  }
})
registerAppTool(server, 'show-embed', {
  inputSchema: z.object({q: z.string()}).shape,
  _meta: {
    ui: { resourceUri }
  }
}, ({message}) => {
   let query = '...';
   return {
     content: [],
     structuredContent: {query}
   }
})
  
server.server.connect(new StdioServerTransport())
.then(() => console.error('Server is running');

Option 2: Remove MCP App Tools from draft spec / just adopt WebMCP

Might be a winner haha

Pros

  • No host implemented app tools yet
  • Sandbox wrapper can poke at view's document.modelContext directly (same origin) so host can inject polyfill in html payload of view

Cons

  • What about elicitation, etc? -> Liad: responsibility of WebMCP :-D

Option 3: Thin interop layer

#796

Potential blockers:

  • Polyfill (left to web page) and their (lack of standard) protocol w/ host
  • Two techs coexisting in same page w/ slight

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions