Uh oh!
There was an error while loading. Please reload this page.
feat: add server helpers, make connect() to default to parent post transport - #165
Conversation
commit: |
f6b87cb to
b0e8518Compareb0e8518 to
163b09eCompareAdd `src/server/` with convenience functions for registering MCP App tools and resources: - `registerAppTool(server, name, config, handler)` - `registerAppResource(server, name, uri, config, callback)` The `transport` parameter in `App.connect()` is now optional, defaulting to `PostMessageTransport(window.parent)`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
163b09e to
f2bbb77CompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Jonathan Hefner <jonathan@hefner.pro>
b855340 to
c5fc927Compare
jonathanhefner
left a comment
There was a problem hiding this comment.
Food for thought: if there are other MCP extensions that similarly rely on _meta properties (on tools or resources), and they also want to define their own register*Tool() or register*Resource() helpers, those would clash ours.
A lighter-touch approach might be helper functions that accept and return preconfigured ToolConfig and ResourceMetadata objects. (Then you could write appToolConfig(fooToolConfig(barToolConfig({ ... }))).)
Anyway, not a blocker.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Make RESOURCE_URI_META_KEY required in McpUiAppToolConfig (tools need a UI resource) - Make _meta optional in McpUiAppResourceConfig (not all resources need custom metadata) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Uh oh!
There was an error while loading. Please reload this page.
Summary
Server Helpers (
src/server/)Add convenience functions for registering MCP App tools and resources:
registerAppTool(server, name, config, handler)- registers a tool with_meta[RESOURCE_URI_META_KEY]for the UI resource URIregisterAppResource(server, name, uri, config, callback)- registers a resource with default MIME typetext/html;profile=mcp-appThe helpers will allow transparent migrations, e.g. making #131 backwards-compatible + more type-safe (
uican be defined as a key onMcpUiAppToolConfig._meta, which otherwise only accepts indexed keys)Optional Transport in App.connect()
The
transportparameter inApp.connect()is now optional:PostMessageTransport(window.parent)when not providedawait app.connect()just worksExample Updates
Updated all examples to use the new helpers and package imports (
@modelcontextprotocol/ext-apps/server).Test plan
registerAppToolandregisterAppResourcenpm run build:all)🤖 Generated with Claude Code