Skip to content

Commit a9a911f

Browse files
committed
Merge remote-tracking branch 'origin/main' into ochafik/bump-1.1.3
2 parents 580408f + 38e1f7a commit a9a911f

9 files changed

Lines changed: 148 additions & 240 deletions

File tree

docs/quickstart.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ Configure your [`package.json`](https://github.com/modelcontextprotocol/ext-apps
4646
```bash
4747
npm pkg set type=module
4848
npm pkg set scripts.build="tsc --noEmit && tsc -p tsconfig.server.json && cross-env INPUT=mcp-app.html vite build"
49-
npm pkg set scripts.start='concurrently "cross-env NODE_ENV=development INPUT=mcp-app.html vite build --watch" "tsx watch main.ts"'
49+
npm pkg set scripts.start='concurrently --raw "cross-env NODE_ENV=development INPUT=mcp-app.html vite build --watch" "tsx watch main.ts"'
5050
```
5151

5252
> [!NOTE]
53-
> Windows `cmd.exe` users will need to convert quotes in the above command: `npm pkg set scripts.start="concurrently ""cross-env NODE_ENV=development INPUT=mcp-app.html vite build --watch"" ""tsx watch main.ts"""`.
53+
> Windows `cmd.exe` users will need to convert quotes in the above command: `npm pkg set scripts.start="concurrently --raw ""cross-env NODE_ENV=development INPUT=mcp-app.html vite build --watch"" ""tsx watch main.ts"""`.
5454
5555
<details>
5656
<summary>Create <a href="https://github.com/modelcontextprotocol/ext-apps/blob/main/examples/quickstart/tsconfig.json"><code>tsconfig.json</code></a>:</summary>
@@ -113,7 +113,7 @@ npm pkg set scripts.start='concurrently "cross-env NODE_ENV=development INPUT=mc
113113

114114
<!-- prettier-ignore -->
115115
```ts source="../examples/quickstart/vite.config.ts"
116-
import { defineConfig } from "vite";
116+
import { createLogger, defineConfig } from "vite";
117117
import { viteSingleFile } from "vite-plugin-singlefile";
118118

119119
const INPUT = process.env.INPUT;
@@ -123,7 +123,14 @@ if (!INPUT) {
123123

124124
const isDevelopment = process.env.NODE_ENV === "development";
125125

126+
const prefixedLogger = createLogger();
127+
for (const level of ["info", "warn", "error"] as const) {
128+
const fn = prefixedLogger[level];
129+
prefixedLogger[level] = (msg, opts) => fn(msg.replace(/^/mg, "[vite] "), opts);
130+
}
131+
126132
export default defineConfig({
133+
customLogger: prefixedLogger,
127134
plugins: [viteSingleFile()],
128135
build: {
129136
sourcemap: isDevelopment ? "inline" : undefined,

examples/map-server/server.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,14 @@ import {
1717
registerAppTool,
1818
registerAppResource,
1919
RESOURCE_MIME_TYPE,
20-
RESOURCE_URI_META_KEY,
2120
} from "@modelcontextprotocol/ext-apps/server";
2221
import { randomUUID } from "crypto";
2322

2423
// Works both from source (server.ts) and compiled (dist/server.js)
2524
const DIST_DIR = import.meta.filename.endsWith(".ts")
2625
? path.join(import.meta.dirname, "dist")
2726
: import.meta.dirname;
28-
const RESOURCE_URI = "ui://cesium-map/mcp-app.html";
27+
const resourceUri = "ui://cesium-map/mcp-app.html";
2928

3029
// Nominatim API response type
3130
interface NominatimResult {
@@ -118,8 +117,8 @@ export function createServer(): McpServer {
118117
// Register the CesiumJS map resource with CSP for external tile sources
119118
registerAppResource(
120119
server,
121-
RESOURCE_URI,
122-
RESOURCE_URI,
120+
resourceUri,
121+
resourceUri,
123122
{ mimeType: RESOURCE_MIME_TYPE },
124123
async (): Promise<ReadResourceResult> => {
125124
const html = await fs.readFile(
@@ -130,7 +129,7 @@ export function createServer(): McpServer {
130129
contents: [
131130
// CSP metadata on the content item takes precedence over listing-level _meta
132131
{
133-
uri: RESOURCE_URI,
132+
uri: resourceUri,
134133
mimeType: RESOURCE_MIME_TYPE,
135134
text: html,
136135
_meta: cspMeta,
@@ -175,7 +174,7 @@ export function createServer(): McpServer {
175174
.optional()
176175
.describe("Optional label to display on the map"),
177176
},
178-
_meta: { [RESOURCE_URI_META_KEY]: RESOURCE_URI },
177+
_meta: { ui: { resourceUri } },
179178
},
180179
async ({ west, south, east, north, label }): Promise<CallToolResult> => ({
181180
content: [

examples/quickstart/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"license": "MIT",
1313
"scripts": {
1414
"build": "tsc --noEmit && tsc -p tsconfig.server.json && cross-env INPUT=mcp-app.html vite build",
15-
"start": "concurrently \"cross-env NODE_ENV=development INPUT=mcp-app.html vite build --watch\" \"tsx watch main.ts\""
15+
"start": "concurrently --raw \"cross-env NODE_ENV=development INPUT=mcp-app.html vite build --watch\" \"tsx watch main.ts\""
1616
},
1717
"dependencies": {
1818
"@modelcontextprotocol/ext-apps": "^1.0.0",

examples/quickstart/vite.config.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { defineConfig } from "vite";
1+
import { createLogger, defineConfig } from "vite";
22
import { viteSingleFile } from "vite-plugin-singlefile";
33

44
const INPUT = process.env.INPUT;
@@ -8,7 +8,14 @@ if (!INPUT) {
88

99
const isDevelopment = process.env.NODE_ENV === "development";
1010

11+
const prefixedLogger = createLogger();
12+
for (const level of ["info", "warn", "error"] as const) {
13+
const fn = prefixedLogger[level];
14+
prefixedLogger[level] = (msg, opts) => fn(msg.replace(/^/mg, "[vite] "), opts);
15+
}
16+
1117
export default defineConfig({
18+
customLogger: prefixedLogger,
1219
plugins: [viteSingleFile()],
1320
build: {
1421
sourcemap: isDevelopment ? "inline" : undefined,

examples/transcript-server/server.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,12 @@ import {
99
registerAppTool,
1010
registerAppResource,
1111
RESOURCE_MIME_TYPE,
12-
RESOURCE_URI_META_KEY,
1312
} from "@modelcontextprotocol/ext-apps/server";
1413
// Works both from source (server.ts) and compiled (dist/server.js)
1514
const DIST_DIR = import.meta.filename.endsWith(".ts")
1615
? path.join(import.meta.dirname, "dist")
1716
: import.meta.dirname;
18-
const RESOURCE_URI = "ui://transcript/mcp-app.html";
17+
const resourceUri = "ui://transcript/mcp-app.html";
1918

2019
/**
2120
* Creates a new MCP server instance with tools and resources registered.
@@ -35,7 +34,7 @@ export function createServer(): McpServer {
3534
description:
3635
"Opens a live speech transcription interface using the Web Speech API.",
3736
inputSchema: {},
38-
_meta: { [RESOURCE_URI_META_KEY]: RESOURCE_URI },
37+
_meta: { ui: { resourceUri } },
3938
},
4039
async (): Promise<CallToolResult> => {
4140
return {
@@ -55,8 +54,8 @@ export function createServer(): McpServer {
5554
// Register the UI resource
5655
registerAppResource(
5756
server,
58-
RESOURCE_URI,
59-
RESOURCE_URI,
57+
resourceUri,
58+
resourceUri,
6059
{ mimeType: RESOURCE_MIME_TYPE, description: "Transcript UI" },
6160
async (): Promise<ReadResourceResult> => {
6261
const html = await fs.readFile(
@@ -67,7 +66,7 @@ export function createServer(): McpServer {
6766
return {
6867
contents: [
6968
{
70-
uri: RESOURCE_URI,
69+
uri: resourceUri,
7170
mimeType: RESOURCE_MIME_TYPE,
7271
text: html,
7372
_meta: {

0 commit comments

Comments
 (0)