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 <noreply@anthropic.com>

* 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 <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Olivier Chafik 2025-12-17 00:17:45 +00:00 • committed by GitHub
commit c3e9d4d694
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 16 additions and 3 deletions

View file

@ -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";

View file

@ -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";

View file

@ -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 {

View file

@ -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";

View file

@ -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";

View file

@ -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",

View file

@ -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";