Skip to content

Conversation

@ochafik
Copy link
Collaborator

@ochafik ochafik commented Dec 16, 2025

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 URI
  • registerAppResource(server, name, uri, config, callback) - registers a resource with default MIME type text/html;profile=mcp-app

The helpers will allow transparent migrations, e.g. making #131 backwards-compatible + more type-safe (ui can be defined as a key on McpUiAppToolConfig._meta, which otherwise only accepts indexed keys)

Optional Transport in App.connect()

The transport parameter in App.connect() is now optional:

  • Defaults to PostMessageTransport(window.parent) when not provided
  • Simplifies app initialization: await app.connect() just works

Example Updates

Updated all examples to use the new helpers and package imports (@modelcontextprotocol/ext-apps/server).

Test plan

  • Unit tests for registerAppTool and registerAppResource
  • Build passes (npm run build:all)
  • All existing tests pass

🤖 Generated with Claude Code

@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 16, 2025

Open in StackBlitz

npm i https://pkg.pr.new/modelcontextprotocol/ext-apps/@modelcontextprotocol/ext-apps@165

commit: 82322a7

@ochafik ochafik force-pushed the ochafik/server-helpers branch 7 times, most recently from f6b87cb to b0e8518 Compare December 16, 2025 20:28
@ochafik ochafik changed the title feat: add server helpers and optional connect() transport feat: add server helpers, make connect() to default to parent post transport Dec 16, 2025
@ochafik ochafik marked this pull request as ready for review December 16, 2025 20:30
@ochafik ochafik force-pushed the ochafik/server-helpers branch from b0e8518 to 163b09e Compare December 16, 2025 20:30
antonpk1
antonpk1 previously approved these changes Dec 16, 2025
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]>
Co-authored-by: Jonathan Hefner <[email protected]>
@ochafik ochafik force-pushed the ochafik/server-helpers branch from b855340 to c5fc927 Compare December 16, 2025 21:03
Copy link
Member

@jonathanhefner jonathanhefner left a 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]>
@ochafik ochafik merged commit bea0ae2 into main Dec 16, 2025
18 of 19 checks passed
@ochafik ochafik deleted the ochafik/server-helpers branch December 16, 2025 21:25
@ochafik ochafik mentioned this pull request Dec 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants