Skip to content

fix(server): don't crash registerAppTool when config._meta is omitted - #775

Open
er-s-an wants to merge 1 commit into
modelcontextprotocol:mainfrom
er-s-an:fix/register-app-tool-optional-meta
Open

fix(server): don't crash registerAppTool when config._meta is omitted#775
er-s-an wants to merge 1 commit into
modelcontextprotocol:mainfrom
er-s-an:fix/register-app-tool-optional-meta

Conversation

@er-s-an

@er-s-an er-s-an commented Sep 10, 2026

Copy link
Copy Markdown

What

Guard the UI-metadata normalization in registerAppTool with config._meta ?? {}.

Why

ToolConfig._meta is typed optional (_meta?), but registerAppTool read config._meta.ui unconditionally. Registering a tool without UI metadata — a valid use, since not every tool on an MCP Apps server renders a view — crashed on the first request:

TypeError: Cannot read properties of undefined (reading 'ui')

Repro:

registerAppTool(server, "plain-tool", {
  title: "Plain Tool",
  description: "No UI metadata",
}, async () => ({ content: [{ type: "text", text: "ok" }] }));
// → TypeError when the server handles the first request

Changes

  • src/server/index.ts: default config._meta to {} before normalization
  • src/server/index.test.ts: regression test — registering without _meta succeeds and passes _meta: {} through

bun test src/server/index.test.ts → 16 pass, 0 fail.

ToolConfig._meta is optional (_meta?), but the UI-metadata normalization
read config._meta.ui unconditionally, so registering a UI-less tool via
registerAppTool threw TypeError: Cannot read properties of undefined
(reading 'ui') on the first request.

Default to {} before normalizing. Adds a regression test.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant