Skip to content

Commit 8a7baaa

Browse files
committed
Merge main into kotlin-sdk
2 parents 82e5473 + 3e95d64 commit 8a7baaa

File tree

55 files changed

+1428
-149
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1428
-149
lines changed

build.bun.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,20 @@ function buildJs(entrypoint: string, opts: Record<string, any> = {}) {
2323
}
2424

2525
await Promise.all([
26-
buildJs("src/app.ts", { outdir: "dist/src" }),
26+
buildJs("src/app.ts", {
27+
outdir: "dist/src",
28+
external: ["@modelcontextprotocol/sdk"],
29+
}),
2730
buildJs("src/app-bridge.ts", {
2831
outdir: "dist/src",
2932
external: ["@modelcontextprotocol/sdk"],
3033
}),
3134
buildJs("src/react/index.tsx", {
3235
outdir: "dist/src/react",
33-
external: ["react", "react-dom"],
36+
external: ["react", "react-dom", "@modelcontextprotocol/sdk"],
37+
}),
38+
buildJs("src/server/index.ts", {
39+
outdir: "dist/src/server",
40+
external: ["@modelcontextprotocol/sdk"],
3441
}),
3542
]);

docs/quickstart.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,10 @@ Create `server.ts`:
9797
```typescript
9898
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
9999
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
100-
import { RESOURCE_URI_META_KEY } from "@modelcontextprotocol/ext-apps";
100+
import {
101+
RESOURCE_MIME_TYPE,
102+
type McpUiToolMeta,
103+
} from "@modelcontextprotocol/ext-apps";
101104
import cors from "cors";
102105
import express from "express";
103106
import fs from "node:fs/promises";
@@ -119,7 +122,7 @@ server.registerTool(
119122
description: "Returns the current server time.",
120123
inputSchema: {},
121124
outputSchema: { time: z.string() },
122-
_meta: { [RESOURCE_URI_META_KEY]: resourceUri }, // Links tool to UI
125+
_meta: { ui: { resourceUri } as McpUiToolMeta }, // Links tool to UI
123126
},
124127
async () => {
125128
const time = new Date().toISOString();

examples/basic-host/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
},
1313
"dependencies": {
1414
"@modelcontextprotocol/ext-apps": "../..",
15-
"@modelcontextprotocol/sdk": "^1.22.0",
15+
"@modelcontextprotocol/sdk": "^1.24.0",
1616
"react": "^19.2.0",
1717
"react-dom": "^19.2.0",
1818
"zod": "^4.1.13"

examples/basic-host/src/implementation.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { RESOURCE_MIME_TYPE, RESOURCE_URI_META_KEY, type McpUiSandboxProxyReadyNotification, AppBridge, PostMessageTransport } from "@modelcontextprotocol/ext-apps/app-bridge";
1+
import { RESOURCE_MIME_TYPE, getToolUiResourceUri, type McpUiSandboxProxyReadyNotification, AppBridge, PostMessageTransport } from "@modelcontextprotocol/ext-apps/app-bridge";
22
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
33
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
44
import type { CallToolResult, Tool } from "@modelcontextprotocol/sdk/types.js";
@@ -77,7 +77,7 @@ export function callTool(
7777

7878
const toolCallInfo: ToolCallInfo = { serverInfo, tool, input, resultPromise };
7979

80-
const uiResourceUri = getUiResourceUri(tool);
80+
const uiResourceUri = getToolUiResourceUri(tool);
8181
if (uiResourceUri) {
8282
toolCallInfo.appResourcePromise = getUiResource(serverInfo, uiResourceUri);
8383
}
@@ -86,16 +86,6 @@ export function callTool(
8686
}
8787

8888

89-
function getUiResourceUri(tool: Tool): string | undefined {
90-
const uri = tool._meta?.[RESOURCE_URI_META_KEY];
91-
if (typeof uri === "string" && uri.startsWith("ui://")) {
92-
return uri;
93-
} else if (uri !== undefined) {
94-
throw new Error(`Invalid UI resource URI: ${JSON.stringify(uri)}`);
95-
}
96-
}
97-
98-
9989
async function getUiResource(serverInfo: ServerInfo, uri: string): Promise<UiResourceData> {
10090
log.info("Reading UI resource:", uri);
10191
const resource = await serverInfo.client.readResource({ uri });

examples/basic-host/src/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ function AppIFramePanel({ toolCallInfo, isDestroying, onTeardownComplete }: AppI
289289
}
290290

291291
log.info("Sending teardown notification to MCP App");
292-
appBridgeRef.current.sendResourceTeardown({})
292+
appBridgeRef.current.teardownResource({})
293293
.catch((err) => {
294294
log.warn("Teardown request failed (app may have already closed):", err);
295295
})

examples/basic-server-react/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ An MCP App example with a React UI.
99

1010
- Tool registration with a linked UI resource
1111
- React UI using the [`useApp()`](https://modelcontextprotocol.github.io/ext-apps/api/functions/_modelcontextprotocol_ext-apps_react.useApp.html) hook
12-
- App communication APIs: [`callServerTool`](https://modelcontextprotocol.github.io/ext-apps/api/classes/app.App.html#callservertool), [`sendMessage`](https://modelcontextprotocol.github.io/ext-apps/api/classes/app.App.html#sendmessage), [`sendLog`](https://modelcontextprotocol.github.io/ext-apps/api/classes/app.App.html#sendlog), [`sendOpenLink`](https://modelcontextprotocol.github.io/ext-apps/api/classes/app.App.html#sendopenlink)
12+
- App communication APIs: [`callServerTool`](https://modelcontextprotocol.github.io/ext-apps/api/classes/app.App.html#callservertool), [`sendMessage`](https://modelcontextprotocol.github.io/ext-apps/api/classes/app.App.html#sendmessage), [`sendLog`](https://modelcontextprotocol.github.io/ext-apps/api/classes/app.App.html#sendlog), [`openLink`](https://modelcontextprotocol.github.io/ext-apps/api/classes/app.App.html#openlink)
1313

1414
## Key Files
1515

examples/basic-server-react/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
},
1313
"dependencies": {
1414
"@modelcontextprotocol/ext-apps": "../..",
15-
"@modelcontextprotocol/sdk": "^1.22.0",
15+
"@modelcontextprotocol/sdk": "^1.24.0",
1616
"react": "^19.2.0",
1717
"react-dom": "^19.2.0",
1818
"zod": "^4.1.13"

examples/basic-server-react/server.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
33
import type { CallToolResult, ReadResourceResult } from "@modelcontextprotocol/sdk/types.js";
44
import fs from "node:fs/promises";
55
import path from "node:path";
6-
import { RESOURCE_MIME_TYPE, RESOURCE_URI_META_KEY } from "../../dist/src/app";
6+
import { registerAppTool, registerAppResource, RESOURCE_MIME_TYPE, RESOURCE_URI_META_KEY } from "@modelcontextprotocol/ext-apps/server";
77
import { startServer } from "../shared/server-utils.js";
88

99
const DIST_DIR = path.join(import.meta.dirname, "dist");
@@ -22,7 +22,7 @@ function createServer(): McpServer {
2222
// MCP Apps require two-part registration: a tool (what the LLM calls) and a
2323
// resource (the UI it renders). The `_meta` field on the tool links to the
2424
// resource URI, telling hosts which UI to display when the tool executes.
25-
server.registerTool(
25+
registerAppTool(server,
2626
"get-time",
2727
{
2828
title: "Get Time",
@@ -38,7 +38,7 @@ function createServer(): McpServer {
3838
},
3939
);
4040

41-
server.registerResource(
41+
registerAppResource(server,
4242
RESOURCE_URI,
4343
RESOURCE_URI,
4444
{ mimeType: RESOURCE_MIME_TYPE },

examples/basic-server-react/src/mcp-app.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ function GetTimeAppInner({ app, toolResult }: GetTimeAppInnerProps) {
110110

111111
const handleOpenLink = useCallback(async () => {
112112
log.info("Sending open link request to Host:", linkUrl);
113-
const { isError } = await app.sendOpenLink({ url: linkUrl });
113+
const { isError } = await app.openLink({ url: linkUrl });
114114
log.info("Open link request", isError ? "rejected" : "accepted");
115115
}, [app, linkUrl]);
116116

examples/basic-server-vanillajs/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ An MCP App example with a vanilla JavaScript UI (no framework).
99

1010
- Tool registration with a linked UI resource
1111
- Vanilla JS UI using the [`App`](https://modelcontextprotocol.github.io/ext-apps/api/classes/app.App.html) class directly
12-
- App communication APIs: [`callServerTool`](https://modelcontextprotocol.github.io/ext-apps/api/classes/app.App.html#callservertool), [`sendMessage`](https://modelcontextprotocol.github.io/ext-apps/api/classes/app.App.html#sendmessage), [`sendLog`](https://modelcontextprotocol.github.io/ext-apps/api/classes/app.App.html#sendlog), [`sendOpenLink`](https://modelcontextprotocol.github.io/ext-apps/api/classes/app.App.html#sendopenlink)
12+
- App communication APIs: [`callServerTool`](https://modelcontextprotocol.github.io/ext-apps/api/classes/app.App.html#callservertool), [`sendMessage`](https://modelcontextprotocol.github.io/ext-apps/api/classes/app.App.html#sendmessage), [`sendLog`](https://modelcontextprotocol.github.io/ext-apps/api/classes/app.App.html#sendlog), [`openLink`](https://modelcontextprotocol.github.io/ext-apps/api/classes/app.App.html#openlink)
1313

1414
## Key Files
1515

@@ -52,5 +52,5 @@ button.addEventListener("click", () => {
5252
});
5353

5454
// Connect to host
55-
app.connect(new PostMessageTransport(window.parent));
55+
app.connect();
5656
```

0 commit comments

Comments
 (0)