Skip to content

Commit 3ac7c79

Browse files
authored
Add RESOURCE_MIME_TYPE constant (#108)
* Add RESOURCE_MIME_TYPE constant * Update app-bridge.ts * update syntax
1 parent f712008 commit 3ac7c79

File tree

11 files changed

+24
-20
lines changed

11 files changed

+24
-20
lines changed

examples/basic-host/src/implementation.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { RESOURCE_URI_META_KEY, type McpUiSandboxProxyReadyNotification } from "@modelcontextprotocol/ext-apps";
2-
import { AppBridge, PostMessageTransport } from "@modelcontextprotocol/ext-apps/app-bridge";
1+
import { RESOURCE_MIME_TYPE, RESOURCE_URI_META_KEY, type McpUiSandboxProxyReadyNotification, AppBridge, PostMessageTransport } from "@modelcontextprotocol/ext-apps/app-bridge";
32
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
43
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
54
import type { CallToolResult, Tool } from "@modelcontextprotocol/sdk/types.js";
@@ -111,7 +110,7 @@ async function getUiResourceHtml(serverInfo: ServerInfo, uri: string): Promise<s
111110

112111
// Per the MCP App specification, "text/html;profile=mcp-app" signals this
113112
// resource is indeed for an MCP App UI.
114-
if (content.mimeType !== "text/html;profile=mcp-app") {
113+
if (content.mimeType !== RESOURCE_MIME_TYPE) {
115114
throw new Error(`Unsupported MIME type: ${content.mimeType}`);
116115
}
117116

examples/basic-server-react/server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import cors from "cors";
55
import express, { type Request, type Response } from "express";
66
import fs from "node:fs/promises";
77
import path from "node:path";
8-
import { RESOURCE_URI_META_KEY } from "../../dist/src/app";
8+
import { RESOURCE_MIME_TYPE, RESOURCE_URI_META_KEY } from "../../dist/src/app";
99

1010
const PORT = process.env.PORT ? parseInt(process.env.PORT, 10) : 3001;
1111
const DIST_DIR = path.join(import.meta.dirname, "dist");
@@ -50,7 +50,7 @@ const server = new McpServer({
5050
contents: [
5151
// Per the MCP App specification, "text/html;profile=mcp-app" signals
5252
// to the Host that this resource is indeed for an MCP App UI.
53-
{ uri: resourceUri, mimeType: "text/html;profile=mcp-app", text: html },
53+
{ uri: resourceUri, mimeType: RESOURCE_MIME_TYPE, text: html },
5454
],
5555
};
5656
},

examples/basic-server-vanillajs/server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import cors from "cors";
55
import express, { type Request, type Response } from "express";
66
import fs from "node:fs/promises";
77
import path from "node:path";
8-
import { RESOURCE_URI_META_KEY } from "../../dist/src/app";
8+
import { RESOURCE_MIME_TYPE, RESOURCE_URI_META_KEY } from "../../dist/src/app";
99

1010
const PORT = process.env.PORT ? parseInt(process.env.PORT, 10) : 3001;
1111
const DIST_DIR = path.join(import.meta.dirname, "dist");
@@ -50,7 +50,7 @@ const server = new McpServer({
5050
contents: [
5151
// Per the MCP App specification, "text/html;profile=mcp-app" signals
5252
// to the Host that this resource is indeed for an MCP App UI.
53-
{ uri: resourceUri, mimeType: "text/html;profile=mcp-app", text: html },
53+
{ uri: resourceUri, mimeType: RESOURCE_MIME_TYPE, text: html },
5454
],
5555
};
5656
},

examples/budget-allocator-server/server.ts

100644100755
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import express, { type Request, type Response } from "express";
1616
import fs from "node:fs/promises";
1717
import path from "node:path";
1818
import { z } from "zod";
19-
import { RESOURCE_URI_META_KEY } from "../../dist/src/app";
19+
import { RESOURCE_MIME_TYPE, RESOURCE_URI_META_KEY } from "../../dist/src/app";
2020

2121
const PORT = process.env.PORT ? parseInt(process.env.PORT, 10) : 3001;
2222
const DIST_DIR = path.join(import.meta.dirname, "dist");
@@ -286,7 +286,7 @@ server.registerResource(
286286
);
287287
return {
288288
contents: [
289-
{ uri: resourceUri, mimeType: "text/html;profile=mcp-app", text: html },
289+
{ uri: resourceUri, mimeType: RESOURCE_MIME_TYPE, text: html },
290290
],
291291
};
292292
},

examples/cohort-heatmap-server/server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import express, { type Request, type Response } from "express";
77
import fs from "node:fs/promises";
88
import path from "node:path";
99
import { z } from "zod";
10-
import { RESOURCE_URI_META_KEY } from "../../dist/src/app";
10+
import { RESOURCE_MIME_TYPE, RESOURCE_URI_META_KEY } from "../../dist/src/app";
1111

1212
const PORT = process.env.PORT ? parseInt(process.env.PORT, 10) : 3001;
1313
const DIST_DIR = path.join(import.meta.dirname, "dist");
@@ -196,7 +196,7 @@ const server = new McpServer({
196196
contents: [
197197
{
198198
uri: resourceUri,
199-
mimeType: "text/html;profile=mcp-app",
199+
mimeType: RESOURCE_MIME_TYPE,
200200
text: html,
201201
},
202202
],

examples/customer-segmentation-server/server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import express, { type Request, type Response } from "express";
1010
import fs from "node:fs/promises";
1111
import path from "node:path";
1212
import { z } from "zod";
13-
import { RESOURCE_URI_META_KEY } from "../../dist/src/app";
13+
import { RESOURCE_MIME_TYPE, RESOURCE_URI_META_KEY } from "../../dist/src/app";
1414
import {
1515
generateCustomers,
1616
generateSegmentSummaries,
@@ -95,7 +95,7 @@ const server = new McpServer({
9595
contents: [
9696
{
9797
uri: resourceUri,
98-
mimeType: "text/html;profile=mcp-app",
98+
mimeType: RESOURCE_MIME_TYPE,
9999
text: html,
100100
},
101101
],

examples/scenario-modeler-server/server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import express, { type Request, type Response } from "express";
1010
import fs from "node:fs/promises";
1111
import path from "node:path";
1212
import { z } from "zod";
13-
import { RESOURCE_URI_META_KEY } from "../../dist/src/app";
13+
import { RESOURCE_MIME_TYPE, RESOURCE_URI_META_KEY } from "../../dist/src/app";
1414

1515
const PORT = process.env.PORT ? parseInt(process.env.PORT, 10) : 3001;
1616
const DIST_DIR = path.join(import.meta.dirname, "dist");
@@ -299,7 +299,7 @@ const server = new McpServer({
299299
contents: [
300300
{
301301
uri: resourceUri,
302-
mimeType: "text/html;profile=mcp-app",
302+
mimeType: RESOURCE_MIME_TYPE,
303303
text: html,
304304
},
305305
],

examples/system-monitor-server/server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import os from "node:os";
1212
import path from "node:path";
1313
import si from "systeminformation";
1414
import { z } from "zod";
15-
import { RESOURCE_URI_META_KEY } from "../../dist/src/app";
15+
import { RESOURCE_MIME_TYPE, RESOURCE_URI_META_KEY } from "../../dist/src/app";
1616

1717
const PORT = process.env.PORT ? parseInt(process.env.PORT, 10) : 3001;
1818

@@ -167,7 +167,7 @@ const server = new McpServer({
167167
contents: [
168168
{
169169
uri: resourceUri,
170-
mimeType: "text/html;profile=mcp-app",
170+
mimeType: RESOURCE_MIME_TYPE,
171171
text: html,
172172
},
173173
],

examples/threejs-server/server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import express, { type Request, type Response } from "express";
1212
import fs from "node:fs/promises";
1313
import path from "node:path";
1414
import { z } from "zod";
15-
import { RESOURCE_URI_META_KEY } from "../../dist/src/app";
15+
import { RESOURCE_MIME_TYPE, RESOURCE_URI_META_KEY } from "../../dist/src/app";
1616

1717
const PORT = process.env.PORT ? parseInt(process.env.PORT, 10) : 3001;
1818
const DIST_DIR = path.join(import.meta.dirname, "dist");
@@ -176,7 +176,7 @@ const server = new McpServer({
176176
contents: [
177177
{
178178
uri: resourceUri,
179-
mimeType: "text/html;profile=mcp-app",
179+
mimeType: RESOURCE_MIME_TYPE,
180180
text: html,
181181
},
182182
],

src/app-bridge.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ import {
6060
McpUiSizeChangedNotificationSchema,
6161
} from "./types";
6262
export * from "./types";
63-
export { RESOURCE_URI_META_KEY } from "./app";
63+
export { RESOURCE_URI_META_KEY, RESOURCE_MIME_TYPE } from "./app";
6464
export { PostMessageTransport } from "./message-transport";
6565

6666
/**

0 commit comments

Comments
 (0)