Skip to content

Commit 4b7e42a

Browse files
committed
Add RESOURCE_MIME_TYPE constant
1 parent f712008 commit 4b7e42a

File tree

10 files changed

+25
-18
lines changed

10 files changed

+25
-18
lines changed

examples/basic-host/src/implementation.ts

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

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

examples/basic-server-react/server.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ 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,
9+
RESOURCE_URI_META_KEY } from "../../dist/src/app";
910

1011
const PORT = process.env.PORT ? parseInt(process.env.PORT, 10) : 3001;
1112
const DIST_DIR = path.join(import.meta.dirname, "dist");
@@ -50,7 +51,7 @@ const server = new McpServer({
5051
contents: [
5152
// Per the MCP App specification, "text/html;profile=mcp-app" signals
5253
// to the Host that this resource is indeed for an MCP App UI.
53-
{ uri: resourceUri, mimeType: "text/html;profile=mcp-app", text: html },
54+
{ uri: resourceUri, mimeType: RESOURCE_MIME_TYPE, text: html },
5455
],
5556
};
5657
},

examples/basic-server-vanillajs/server.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ 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,
9+
RESOURCE_URI_META_KEY } from "../../dist/src/app";
910

1011
const PORT = process.env.PORT ? parseInt(process.env.PORT, 10) : 3001;
1112
const DIST_DIR = path.join(import.meta.dirname, "dist");
@@ -50,7 +51,7 @@ const server = new McpServer({
5051
contents: [
5152
// Per the MCP App specification, "text/html;profile=mcp-app" signals
5253
// to the Host that this resource is indeed for an MCP App UI.
53-
{ uri: resourceUri, mimeType: "text/html;profile=mcp-app", text: html },
54+
{ uri: resourceUri, mimeType: RESOURCE_MIME_TYPE, text: html },
5455
],
5556
};
5657
},

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.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,11 @@ export * from "./types";
7676
*/
7777
export const RESOURCE_URI_META_KEY = "ui/resourceUri";
7878

79+
/**
80+
* MIME type for MCP UI resources.
81+
*/
82+
export const RESOURCE_MIME_TYPE = "text/html;profile=mcp";
83+
7984
/**
8085
* Options for configuring App behavior.
8186
*

0 commit comments

Comments
 (0)