Skip to content

Commit e342034

Browse files
authored
fix: update adapter to latest MCP Apps spec (#163)
1 parent c91e533 commit e342034

10 files changed

Lines changed: 217 additions & 121 deletions

File tree

docs/src/guide/mcp-apps.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ server.registerTool(
180180
| `link` | `ui/open-link` | Open a URL in a new tab |
181181
| `notify` | `notifications/message` | Log a message to the host |
182182
| `intent` | `ui/message` | Send an intent (translated to message) |
183-
| `ui-size-change` | `ui/notifications/size-change` | Request widget resize |
183+
| `ui-size-change` | `ui/notifications/size-changed` | Request widget resize |
184184

185185
### Host → Widget (Incoming)
186186

@@ -190,6 +190,9 @@ server.registerTool(
190190
| `ui/notifications/tool-input-partial` | `ui-lifecycle-iframe-render-data` | Streaming partial arguments |
191191
| `ui/notifications/tool-result` | `ui-lifecycle-iframe-render-data` | Tool execution result |
192192
| `ui/notifications/host-context-changed` | `ui-lifecycle-iframe-render-data` | Theme, locale, viewport changes |
193+
| `ui/notifications/size-changed` | `ui-lifecycle-iframe-render-data` | Host informs of size constraints |
194+
| `ui/notifications/tool-cancelled` | `ui-lifecycle-tool-cancelled` | Tool execution was cancelled |
195+
| `ui/resource-teardown` | `ui-lifecycle-teardown` | Host notifies UI before teardown |
193196

194197
## Configuration Options
195198

@@ -210,7 +213,7 @@ createUIResource({
210213

211214
## MIME Type
212215

213-
When the MCP Apps adapter is enabled, the resource MIME type is automatically set to `text/html;profile=mcp`. This is the expected MIME type for MCP Apps-compliant hosts.
216+
When the MCP Apps adapter is enabled, the resource MIME type is automatically set to `text/html;profile=mcp-app`, the MCP Apps equivalent to `text/html`.
214217

215218
## Receiving Data in Your Widget
216219

pnpm-lock.yaml

Lines changed: 66 additions & 42 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdks/typescript/server/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
},
7474
"license": "Apache-2.0",
7575
"dependencies": {
76+
"@modelcontextprotocol/ext-apps": "^0.0.7",
7677
"@modelcontextprotocol/sdk": "^1.22.0"
7778
}
7879
}

sdks/typescript/server/scripts/bundle-adapter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ async function bundleAdapter(adapterName) {
1010
try {
1111
const result = await build({
1212
entryPoints: [join(__dirname, `../src/adapters/${adapterName}/adapter-runtime.ts`)],
13-
bundle: false,
13+
bundle: false, // Don't bundle - types are compile-time only
1414
write: false,
1515
format: 'esm',
1616
platform: 'browser',

sdks/typescript/server/src/__tests__/adapters/adapter-integration.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -482,14 +482,14 @@ describe('Adapter Integration', () => {
482482
});
483483

484484
describe('getAdapterMimeType with MCP Apps', () => {
485-
it('should return text/html;profile=mcp for MCP Apps adapter', () => {
485+
it('should return text/html;profile=mcp-app for MCP Apps adapter', () => {
486486
const result = getAdapterMimeType({
487487
mcpApps: {
488488
enabled: true,
489489
},
490490
});
491491

492-
expect(result).toBe('text/html;profile=mcp');
492+
expect(result).toBe('text/html;profile=mcp-app');
493493
});
494494
});
495495

@@ -555,7 +555,7 @@ describe('Adapter Integration', () => {
555555
expect(getAdapterMimeType({ appsSdk: { enabled: true } })).toBe('text/html+skybridge');
556556

557557
// MCP Apps adapter
558-
expect(getAdapterMimeType({ mcpApps: { enabled: true } })).toBe('text/html;profile=mcp');
558+
expect(getAdapterMimeType({ mcpApps: { enabled: true } })).toBe('text/html;profile=mcp-app');
559559

560560
// No adapter
561561
expect(getAdapterMimeType({})).toBeUndefined();

sdks/typescript/server/src/__tests__/utils.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,20 @@ describe('getAdapterMimeType', () => {
176176
});
177177
expect(result).toBeUndefined();
178178
});
179+
180+
it('should return mcp-app mime type when mcpApps adapter is enabled', () => {
181+
const result = getAdapterMimeType({
182+
mcpApps: { enabled: true },
183+
});
184+
expect(result).toBe('text/html;profile=mcp-app');
185+
});
186+
187+
it('should return undefined when mcpApps is disabled', () => {
188+
const result = getAdapterMimeType({
189+
mcpApps: { enabled: false },
190+
});
191+
expect(result).toBeUndefined();
192+
});
179193
});
180194

181195
describe('wrapHtmlWithAdapters', () => {

0 commit comments

Comments
 (0)