Skip to content

Commit c3e9d4d

Browse files
ochafikclaude
andauthored
fix(examples): use server.registerTool for non-UI tool + fix missing imports (#173)
* 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 <[email protected]> * 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 <[email protected]> --------- Co-authored-by: Claude <[email protected]>
1 parent 894f793 commit c3e9d4d

File tree

7 files changed

+16
-3
lines changed

7 files changed

+16
-3
lines changed

examples/budget-allocator-server/server.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import { z } from "zod";
1616
import {
1717
RESOURCE_MIME_TYPE,
1818
RESOURCE_URI_META_KEY,
19+
registerAppResource,
20+
registerAppTool,
1921
} from "@modelcontextprotocol/ext-apps/server";
2022
import { startServer } from "../shared/server-utils.js";
2123

examples/cohort-heatmap-server/server.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import { z } from "zod";
77
import {
88
RESOURCE_MIME_TYPE,
99
RESOURCE_URI_META_KEY,
10+
registerAppResource,
11+
registerAppTool,
1012
} from "@modelcontextprotocol/ext-apps/server";
1113
import { startServer } from "../shared/server-utils.js";
1214

examples/customer-segmentation-server/server.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import { z } from "zod";
1010
import {
1111
RESOURCE_MIME_TYPE,
1212
RESOURCE_URI_META_KEY,
13+
registerAppResource,
14+
registerAppTool,
1315
} from "@modelcontextprotocol/ext-apps/server";
1416
import { startServer } from "../shared/server-utils.js";
1517
import {

examples/scenario-modeler-server/server.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import { z } from "zod";
1010
import {
1111
RESOURCE_MIME_TYPE,
1212
RESOURCE_URI_META_KEY,
13+
registerAppResource,
14+
registerAppTool,
1315
} from "@modelcontextprotocol/ext-apps/server";
1416
import { startServer } from "../shared/server-utils.js";
1517

examples/system-monitor-server/server.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import { z } from "zod";
1212
import {
1313
RESOURCE_MIME_TYPE,
1414
RESOURCE_URI_META_KEY,
15+
registerAppResource,
16+
registerAppTool,
1517
} from "@modelcontextprotocol/ext-apps/server";
1618
import { startServer } from "../shared/server-utils.js";
1719

examples/threejs-server/server.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import { z } from "zod";
1212
import {
1313
RESOURCE_MIME_TYPE,
1414
RESOURCE_URI_META_KEY,
15+
registerAppResource,
16+
registerAppTool,
1517
} from "@modelcontextprotocol/ext-apps/server";
1618
import { startServer } from "../shared/server-utils.js";
1719

@@ -178,9 +180,8 @@ function createServer(): McpServer {
178180
},
179181
);
180182

181-
// Tool 2: learn_threejs
182-
registerAppTool(
183-
server,
183+
// Tool 2: learn_threejs (not a UI tool, just returns documentation)
184+
server.registerTool(
184185
"learn_threejs",
185186
{
186187
title: "Learn Three.js",

examples/wiki-explorer-server/server.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import { z } from "zod";
1111
import {
1212
RESOURCE_MIME_TYPE,
1313
RESOURCE_URI_META_KEY,
14+
registerAppResource,
15+
registerAppTool,
1416
} from "@modelcontextprotocol/ext-apps/server";
1517
import { startServer } from "../shared/server-utils.js";
1618

0 commit comments

Comments
 (0)