From c3e9d4d694ec0aa8240f7ed5ec1d4ac52efe7974 Mon Sep 17 00:00:00 2001 From: Olivier Chafik Date: Wed, 17 Dec 2025 00:17:45 +0000 Subject: [PATCH] fix(examples): use server.registerTool for non-UI tool + fix missing imports (#173) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(threejs-server): use server.registerTool for non-UI tool The learn_threejs tool doesn't have a UI component - it only returns documentation text. Using registerAppTool without _meta causes a runtime error when the function tries to access config._meta.ui. Fixes crash: "Cannot read property 'ui' of undefined" 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude * fix(examples): add missing registerAppTool and registerAppResource imports All example servers were using registerAppTool and registerAppResource but not importing them from @modelcontextprotocol/ext-apps/server, causing "ReferenceError: registerAppTool is not defined" at runtime. Affected servers: - budget-allocator-server - cohort-heatmap-server - customer-segmentation-server - scenario-modeler-server - system-monitor-server - threejs-server - wiki-explorer-server 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --------- Co-authored-by: Claude --- examples/budget-allocator-server/server.ts | 2 ++ examples/cohort-heatmap-server/server.ts | 2 ++ examples/customer-segmentation-server/server.ts | 2 ++ examples/scenario-modeler-server/server.ts | 2 ++ examples/system-monitor-server/server.ts | 2 ++ examples/threejs-server/server.ts | 7 ++++--- examples/wiki-explorer-server/server.ts | 2 ++ 7 files changed, 16 insertions(+), 3 deletions(-) diff --git a/examples/budget-allocator-server/server.ts b/examples/budget-allocator-server/server.ts index fd7618e..a6bd782 100755 --- a/examples/budget-allocator-server/server.ts +++ b/examples/budget-allocator-server/server.ts @@ -16,6 +16,8 @@ import { z } from "zod"; import { RESOURCE_MIME_TYPE, RESOURCE_URI_META_KEY, + registerAppResource, + registerAppTool, } from "@modelcontextprotocol/ext-apps/server"; import { startServer } from "../shared/server-utils.js"; diff --git a/examples/cohort-heatmap-server/server.ts b/examples/cohort-heatmap-server/server.ts index 9d3c9cb..1df2d12 100644 --- a/examples/cohort-heatmap-server/server.ts +++ b/examples/cohort-heatmap-server/server.ts @@ -7,6 +7,8 @@ import { z } from "zod"; import { RESOURCE_MIME_TYPE, RESOURCE_URI_META_KEY, + registerAppResource, + registerAppTool, } from "@modelcontextprotocol/ext-apps/server"; import { startServer } from "../shared/server-utils.js"; diff --git a/examples/customer-segmentation-server/server.ts b/examples/customer-segmentation-server/server.ts index 0bbbbba..8296751 100644 --- a/examples/customer-segmentation-server/server.ts +++ b/examples/customer-segmentation-server/server.ts @@ -10,6 +10,8 @@ import { z } from "zod"; import { RESOURCE_MIME_TYPE, RESOURCE_URI_META_KEY, + registerAppResource, + registerAppTool, } from "@modelcontextprotocol/ext-apps/server"; import { startServer } from "../shared/server-utils.js"; import { diff --git a/examples/scenario-modeler-server/server.ts b/examples/scenario-modeler-server/server.ts index c382493..75f7358 100644 --- a/examples/scenario-modeler-server/server.ts +++ b/examples/scenario-modeler-server/server.ts @@ -10,6 +10,8 @@ import { z } from "zod"; import { RESOURCE_MIME_TYPE, RESOURCE_URI_META_KEY, + registerAppResource, + registerAppTool, } from "@modelcontextprotocol/ext-apps/server"; import { startServer } from "../shared/server-utils.js"; diff --git a/examples/system-monitor-server/server.ts b/examples/system-monitor-server/server.ts index b439c5a..9d43143 100644 --- a/examples/system-monitor-server/server.ts +++ b/examples/system-monitor-server/server.ts @@ -12,6 +12,8 @@ import { z } from "zod"; import { RESOURCE_MIME_TYPE, RESOURCE_URI_META_KEY, + registerAppResource, + registerAppTool, } from "@modelcontextprotocol/ext-apps/server"; import { startServer } from "../shared/server-utils.js"; diff --git a/examples/threejs-server/server.ts b/examples/threejs-server/server.ts index e920854..e97bd36 100644 --- a/examples/threejs-server/server.ts +++ b/examples/threejs-server/server.ts @@ -12,6 +12,8 @@ import { z } from "zod"; import { RESOURCE_MIME_TYPE, RESOURCE_URI_META_KEY, + registerAppResource, + registerAppTool, } from "@modelcontextprotocol/ext-apps/server"; import { startServer } from "../shared/server-utils.js"; @@ -178,9 +180,8 @@ function createServer(): McpServer { }, ); - // Tool 2: learn_threejs - registerAppTool( - server, + // Tool 2: learn_threejs (not a UI tool, just returns documentation) + server.registerTool( "learn_threejs", { title: "Learn Three.js", diff --git a/examples/wiki-explorer-server/server.ts b/examples/wiki-explorer-server/server.ts index 15c93c2..6d5e790 100644 --- a/examples/wiki-explorer-server/server.ts +++ b/examples/wiki-explorer-server/server.ts @@ -11,6 +11,8 @@ import { z } from "zod"; import { RESOURCE_MIME_TYPE, RESOURCE_URI_META_KEY, + registerAppResource, + registerAppTool, } from "@modelcontextprotocol/ext-apps/server"; import { startServer } from "../shared/server-utils.js";