From 4434bab19235d1f87f90c6dd006be37202003fcf Mon Sep 17 00:00:00 2001 From: Yanhu007 Date: Sun, 12 Apr 2026 00:21:26 +0000 Subject: [PATCH 1/2] fix: support icons in registerTool config and tools/list response The MCP spec's ToolSchema includes icons (via IconsSchema), but McpServer.registerTool() did not accept icons in its config parameter, and the tools/list handler did not include icons in the tool definition. - Add icons to registerTool config type - Pass icons through _createRegisteredTool - Include icons in the tools/list response toolDefinition - Add icons to RegisteredTool type Fixes #1864 --- packages/server/src/server/mcp.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/server/src/server/mcp.ts b/packages/server/src/server/mcp.ts index 6c2699997..bd0a52fc8 100644 --- a/packages/server/src/server/mcp.ts +++ b/packages/server/src/server/mcp.ts @@ -146,6 +146,7 @@ export class McpServer { : EMPTY_OBJECT_JSON_SCHEMA, annotations: tool.annotations, execution: tool.execution, + icons: tool.icons, _meta: tool._meta }; @@ -773,7 +774,8 @@ export class McpServer { annotations: ToolAnnotations | undefined, execution: ToolExecution | undefined, _meta: Record | undefined, - handler: AnyToolHandler + handler: AnyToolHandler, + icons?: Tool['icons'], ): RegisteredTool { // Validate tool name according to SEP specification validateAndWarnToolName(name); @@ -788,6 +790,7 @@ export class McpServer { outputSchema, annotations, execution, + icons, _meta, handler: handler, executor: createToolExecutor(inputSchema, handler), @@ -870,6 +873,7 @@ export class McpServer { inputSchema?: InputArgs; outputSchema?: OutputArgs; annotations?: ToolAnnotations; + icons?: Tool['icons']; _meta?: Record; }, cb: ToolCallback @@ -878,7 +882,7 @@ export class McpServer { throw new Error(`Tool ${name} is already registered`); } - const { title, description, inputSchema, outputSchema, annotations, _meta } = config; + const { title, description, inputSchema, outputSchema, annotations, icons, _meta } = config; return this._createRegisteredTool( name, @@ -889,7 +893,8 @@ export class McpServer { annotations, { taskSupport: 'forbidden' }, _meta, - cb as ToolCallback + cb as ToolCallback, + icons, ); } @@ -1096,6 +1101,7 @@ export type RegisteredTool = { outputSchema?: StandardSchemaWithJSON; annotations?: ToolAnnotations; execution?: ToolExecution; + icons?: Tool['icons']; _meta?: Record; handler: AnyToolHandler; /** @hidden */ From 8c763a271408af3c60fd0625da1a3d3a9d4c1c47 Mon Sep 17 00:00:00 2001 From: Yanhu007 Date: Sun, 12 Apr 2026 02:04:24 +0000 Subject: [PATCH 2/2] chore: add changeset for icons fix --- .changeset/fix-register-tool-icons.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/fix-register-tool-icons.md diff --git a/.changeset/fix-register-tool-icons.md b/.changeset/fix-register-tool-icons.md new file mode 100644 index 000000000..30adf5c89 --- /dev/null +++ b/.changeset/fix-register-tool-icons.md @@ -0,0 +1,5 @@ +--- +'@modelcontextprotocol/server': patch +--- + +Support `icons` in `McpServer.registerTool()` config and include it in `tools/list` responses. The MCP spec's `ToolSchema` includes `icons` via `IconsSchema`, but the high-level API did not accept or serialize it.