Commit graph ext-apps/src
Author SHA1 Message Date
Anton Pidkuiko
d97ae07849
Merge pull request #88 from modelcontextprotocol/ochafik/theme-layout-enums
types: add McpUiTheme, McpUiDisplayMode
2025-12-08 15:33:06 +00:00
Anton Pidkuiko
5ae292106c
Remove temporary JSON-RPC envelope unwrapping hack (#90)
The host implementation has been fixed to return the correct result
format, so this workaround is no longer needed.

Reverts the hack added in #82.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-08 16:32:15 +01:00
Olivier Chafik
cb571bf0e5
add McpUiTheme, McpUiDisplayMode 2025-12-08 15:37:28 +01:00
Olivier Chafik
3aa93db3c3
Add AppBridge.sendHostContextChange + reexport RESOURCE_URI_META_KEY (#87)
* Export  RESOURCE_URI_META_KEY from app-bridge

* add sendHostContextChange

* nit
2025-12-08 15:28:21 +01:00
Liad Yosef
ba1a27e465
fix: change size-changed to be in correct tense (#83)
* fix: change size-changed to be in correct tense

* sdk changes
2025-12-08 12:14:56 +01:00
Jerome
a09354bdf2
Fix compatibility with @modelcontextprotocol/sdk 1.23+ (#84)
* Fix compatibility with @modelcontextprotocol/sdk 1.23+

Implement required abstract methods `assertTaskCapability` and
`assertTaskHandlerCapability` in App and AppBridge classes. These
were added to the Protocol base class in SDK 1.23+.

Also regenerates package-lock.json with valid npm registry versions
(previously had non-existent vite@6.4.1).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Add pkg-pr-new workflow for PR/commit publishing

Enables automatic publishing of any commit or PR to pkg.pr.new,
allowing consumers to install directly from git commits:

npm install https://pkg.pr.new/modelcontextprotocol/ext-apps/@modelcontextprotocol/ext-apps@<commit-or-pr>

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-08 12:13:07 +01:00
Anton Pidkuiko
47d1b37ba3
fix: remove 'system' from theme type (#79)
Remove 'system' option from theme, leaving only 'light' | 'dark'.

This aligns the SDK with:
- The spec (which already only has light/dark)
- OpenAI Apps SDK compatibility

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-08 03:14:33 +02:00
Anton Pidkuiko
19b9360f40
Merge pull request #82 from modelcontextprotocol/fix-callservertool-unwrap
Temporal fix: Handle wrapped JSON-RPC responses in callServerTool
2025-12-05 23:15:14 +00:00
Jonathan Hefner
3d0a39b9b0
Merge pull request #74 from modelcontextprotocol/docs/safe-area-insets-comment
docs: remove "Mobile" from safeAreaInsets comment
2025-12-05 17:13:11 -06:00
Anton Pidkuiko MacBook
9743051f06
Fix callServerTool to handle wrapped JSON-RPC responses
Some host implementations incorrectly return the full JSON-RPC envelope
(with result, jsonrpc, id fields) instead of just the unwrapped result.
This causes apps using callServerTool() to fail when accessing result.content.

This fix detects wrapped responses and unwraps them automatically.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-05 23:12:26 +00:00
Jonathan Hefner
97310d50c5 Add basic-host and basic-server-react examples
Introduce new example implementations to replace simple-host and
simple-server:

- basic-host: Reference host implementation with double-iframe sandbox
  pattern for secure UI isolation (outer iframe validates and relays
  messages, inner iframe renders untrusted tool UI via srcdoc)

- basic-server-react: MCP server example demonstrating tool registration
  with linked UI resources and React UI using the useApp() hook

Build infrastructure updates:
- Add build:all script and simplify CI/pre-commit to use it
- Add examples:dev for watch-mode development workflow

Also change PostMessageTransport logging from info to debug level.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 14:28:27 -06:00
Anton Pidkuiko MacBook
2e0a7b41ff
docs: remove "Mobile" from safeAreaInsets comment
Safe area insets apply on web as well, not just mobile devices.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 11:30:16 +00:00
Anton Pidkuiko
781adf16e0
feat: add UI resource metadata types for CSP and rendering config (#65)
Add types for parsing `_meta.ui` field from resources/read responses:

- McpUiResourceCspSchema: CSP domain declarations (connectDomains for
  fetch/XHR/WebSocket, resourceDomains for scripts/images/fonts)
- McpUiResourceMetaSchema: Full metadata including CSP, dedicated domain
  for widget sandbox, and border preference

Hosts need these to construct CSP headers and configure iframe sandboxing.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-03 17:21:42 +00:00
Jonathan Hefner
1a6f237501
Fix iframe sizing to use actual content dimensions (#57)
The previous approach measured html/body elements which expand to fill
the viewport, causing the iframe to be larger than necessary.

Fix by using CSS fit-content to measure the true minimum content size:
- Temporarily set html to fit-content to shrink it to content
- This automatically includes body margins
- Cache last sent size to prevent feedback loops from style changes
- Simplify scrollbar compensation (already 0 when no scrollbar)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-01 23:04:09 +00:00
Olivier Chafik
cf4492df89
Add App <-> AppBridge tests, setHostContext & sendToolInputPartial (#55)
* Add App <-> AppBridge integration tests

- Add minimalistic tests validating communication between App (guest) and AppBridge (host)
- Test initialization handshake flow
- Test Host -> App notifications (toolInput, toolInputPartial, toolResult, hostContext)
- Test App -> Host notifications (sizeChange, log)
- Test App -> Host requests (sendMessage, sendOpenLink)
- Test ping functionality
- Add setHostContext and sendToolInputPartial to AppBridge
- Add test script to package.json

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* docs: add JSDoc for setHostContext and sendToolInputPartial

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* fix: add @types/bun for test type checking

- Add @types/bun devDependency for bun:test types
- Fix mock client request return type

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-01 22:18:31 +00:00
Anton Pidkuiko
9d8b705598
fix: remove "system" from theme options (#40)
The host should resolve "system" to either "light" or "dark" before
passing the theme to the app. Apps only need to know the actual
resolved theme value.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Olivier Chafik <ochafik@anthropic.com>
2025-12-01 20:31:08 +00:00
Ido Salomon
a9b96cd365
fix: remove carousel display mode (#56) 2025-12-01 22:29:49 +02:00
Jonathan Hefner
1cf95e53e4
Fix iframe size feedback loop on Linux/Windows (#54)
Compensate for viewport scrollbar width in size change notifications.
On Linux/Windows, scrollbars consume space from the content area, causing
a feedback loop where the iframe progressively shrinks to zero.

- Use window.innerWidth - clientWidth to detect scrollbar width
- Use max of getBoundingClientRect (CSS transforms) and scroll dimensions
  (content overflow) to report accurate size

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-01 20:05:35 +00:00
Jonathan Hefner
16a9e6f034
Add API docs (#29)
* Refactor types.ts to use explicit interfaces with JSDoc

Replace z.infer<typeof Schema> patterns with explicit interface
definitions for all MCP UI types. Add VerifySchemaMatches helper
type to ensure compile-time verification that schemas match their
interfaces.

Add comprehensive JSDoc documentation to all exported types including:
- Clear descriptions of purpose and usage
- @see references to related types and methods
- Code examples where helpful
- @internal markers for implementation details

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Add JSDoc documentation and TypeDoc tooling

Add comprehensive JSDoc documentation to:
- AppBridge class and all methods
- App class and all methods
- PostMessageTransport class and callbacks
- React hooks (useApp, useAutoResize)
- React module index

Set up TypeDoc for API documentation generation:
- Add typedoc.json configuration
- Add docs and docs:watch npm scripts
- Add typedoc dev dependency
- Update .gitignore to exclude generated docs

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Add JSDoc documentation for callback handler setters

Document all notification and request handler setters in AppBridge
and App classes with comprehensive JSDoc comments including:
- Clear descriptions of when handlers are called
- Parameter documentation and types
- Practical code examples with error handling
- Cross-references to related types and methods
- Security considerations where relevant

Also update types.ts to document optional isError fields in result
types and make McpUiInitializedNotification params optional.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Add JSDoc for new App methods and fix result type compatibility

Document new public APIs introduced in merge commit 74a7b1f:
- getHostCapabilities() - getter for host capabilities after connect
- getHostVersion() - getter for host implementation info after connect
- oncalltool setter - convenience handler for tool call requests
- onlisttools setter - convenience handler for tool listing requests
- RESOURCE_URI_META_KEY constant - metadata key for resource URIs

Add index signatures to McpUiMessageResult and McpUiOpenLinkResult
for MCP SDK Protocol class compatibility, matching the existing
pattern in McpUiInitializeResult.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Add comprehensive JSDoc documentation across library

- Document App methods with detailed descriptions and examples
- Add JSDoc to AppBridge methods including getters and setters
- Document PostMessageTransport callback properties
- Improve React hook documentation (useApp, useAutoResize)
- Add documentation for types.ts result and notification types
- Add @see cross-references between related methods
- Fix code examples to use correct syntax and patterns
- Clarify error handling behavior in method descriptions

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Fix TypeDoc cross-module link resolution warnings

Replace unqualified @link references with module-qualified syntax to fix
"Failed to resolve link" warnings during docs generation. TypeDoc cannot
resolve links like {@link App.sendOpenLink} without imports, so use the
module-qualified format {@link app.App.sendOpenLink} instead.

Changes:
- types.ts: Fix 9 cross-module links to App and AppBridge methods
- app-bridge.ts: Fix 2 references to App.sendSizeChange
- message-transport.ts: Fix 2 references to App.connect and AppBridge.connect

This eliminates all "Failed to resolve link" warnings without requiring
circular imports or removing documentation cross-references.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Remove TypeDoc links to undocumented external types

Remove @link references to types that are either:
- Not exported (AppOptions) - internal implementation detail
- From external packages (@modelcontextprotocol/sdk) - not included in docs

This eliminates warnings about resolved but undocumented types. The type
information is still available through TypeScript's type system and parameter
documentation, but without broken links in the generated documentation.

Removed links to:
- AppOptions (internal type)
- Implementation, CallToolRequest, CallToolResult (MCP SDK types)
- ListToolsRequest, LoggingMessageNotification (MCP SDK types)

Reduces warnings from 12 to 4 (remaining are about missing example files).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Bump @modelcontextprotocol/sdk to ^1.23.0

Update SDK dependency to fix CI build failures caused by version
mismatch. CI was installing 1.23.0 (latest compatible with ^1.22.0)
while local builds used 1.22.0.

Note: package-lock.json is gitignored, which prevents reproducible
builds. Consider committing it to ensure CI uses the same versions
as local development.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Fix Zod type compatibility with @modelcontextprotocol/sdk

The SDK imports Zod from 'zod/v4' while this package imported from
'zod'. Although both resolve to the same version (3.25.x), TypeScript
sees them as separate modules with incompatible type declarations.

This caused type errors when:
- Extending SDK schemas like RequestSchema.extend()
- Passing SDK schemas to setRequestHandler/setNotificationHandler
- Using ZodObject/ZodLiteral types from different import paths

Changes:
- Import zod from 'zod/v4' to match SDK import path
- Update z.record() calls to use Zod v4 signature (requires both
  key and value schemas)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Add GitHub Actions workflow to deploy docs to gh-pages

Adds a workflow with manual trigger (workflow_dispatch) that generates
TypeDoc documentation and publishes it to the gh-pages branch using
peaceiris/actions-gh-pages.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Add docs index.html redirect to API documentation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Revise README for clarity and audience focus

- Add API documentation badge linking to GitHub Pages
- Reorganize content around two audiences: App Developers and Host Developers
- Convert relative links to absolute GitHub URLs for better portability
- Simplify installation and examples sections
- Add Resources section with links to docs, spec, and discussion

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Update src/app-bridge.ts

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Olivier Chafik <ochafik@anthropic.com>
2025-11-27 22:09:22 +00:00
Olivier Chafik
8ac79a9731
lib: add capabilities & version getters (#24)
* add App{,Bridge}.get{App,Host}{Version,Capabilities}()

* Add App.{oncalltool,onlisttools}
2025-11-25 04:05:33 +00:00
Olivier Chafik
ca09c415bf
setup ci & presubmit (#20)
* ci & presubmit

* Update ci.yml
2025-11-25 02:40:48 +00:00
Olivier Chafik
3df49c38dc
fix iframe resizing (#19)
* reshuffle build / start scripts

* fix resize logic

* prettier

* extract RESOURCE_URI_META_KEY constant

* Update message-transport.ts

* Update package.json
2025-11-25 02:39:33 +00:00
Olivier Chafik
1fc5e3439e
Merge pull request #18 from modelcontextprotocol/fix/resources-requests
Add ReadResourceRequestSchema forwarding for resources capability
2025-11-25 00:53:45 +00:00
Anton Pidkuiko MacBook
a5e47b2e13
Add ReadResourceRequestSchema forwarding for resources capability
The resources capability was forwarding ListResourcesRequestSchema and
ListResourceTemplatesRequestSchema, but missing ReadResourceRequestSchema.
This meant clients could list resources but not actually read them.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-24 22:58:31 +00:00
Anton Pidkuiko MacBook
8b0c34cda9
Make params optional in McpUiInitializedNotificationSchema
Notifications sent without params (e.g., `{ method: "ui/notifications/initialized" }`)
were being rejected by the schema validation because params was required.
This makes params optional so notifications without explicit params are accepted.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-24 22:48:24 +00:00
Olivier Chafik
54a48a4a13
rename: AppRenderer 2025-11-24 16:20:45 +00:00
Olivier Chafik
14740aacea
fix build 2025-11-24 16:07:10 +00:00
Olivier Chafik
ac3863092a
setup notification handlers in App & AppBridge 2025-11-24 14:59:58 +00:00
ochafik
00023ba3e9 npm run prettier:fix 2025-11-23 03:15:06 +00:00
ochafik
873075e690 ditch McpUiHostInfoSchema in favour of ImplementationSchema 2025-11-21 21:54:03 +00:00
ochafik
8189a674e2 Update app-bridge.ts 2025-11-21 21:51:00 +00:00
Olivier Chafik
fba664d2dd
AppHost -> AppBridge 2025-11-21 17:51:33 +00:00
Olivier Chafik
f2766edb40
ui/notifications/tool-input* (singular to match inputSchema) 2025-11-21 14:03:20 +00:00
Olivier Chafik
a0039ef150
update build 2025-11-21 13:13:46 +00:00
Olivier Chafik
1398aaf9df
add AppHost 2025-11-21 12:05:44 +00:00
Olivier Chafik
92f42cf533
Initial commit 2025-11-21 11:56:27 +00:00