-
Notifications
You must be signed in to change notification settings - Fork 49
feat: add server helpers, make connect() to default to parent post transport #165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
commit: |
f6b87cb to
b0e8518
Compare
b0e8518 to
163b09e
Compare
Add `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 <[email protected]>
163b09e to
f2bbb77
Compare
Co-authored-by: Jonathan Hefner <[email protected]>
b855340 to
c5fc927
Compare
jonathanhefner
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
- 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 <[email protected]>
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