Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-register-tool-icons.md
Original file line number Diff line number Diff line change
@@ -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.
12 changes: 9 additions & 3 deletions packages/server/src/server/mcp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ export class McpServer {
: EMPTY_OBJECT_JSON_SCHEMA,
annotations: tool.annotations,
execution: tool.execution,
icons: tool.icons,
_meta: tool._meta
};

Expand Down Expand Up @@ -773,7 +774,8 @@ export class McpServer {
annotations: ToolAnnotations | undefined,
execution: ToolExecution | undefined,
_meta: Record<string, unknown> | undefined,
handler: AnyToolHandler<StandardSchemaWithJSON | undefined>
handler: AnyToolHandler<StandardSchemaWithJSON | undefined>,
icons?: Tool['icons'],
): RegisteredTool {
// Validate tool name according to SEP specification
validateAndWarnToolName(name);
Expand All @@ -788,6 +790,7 @@ export class McpServer {
outputSchema,
annotations,
execution,
icons,
_meta,
handler: handler,
executor: createToolExecutor(inputSchema, handler),
Expand Down Expand Up @@ -870,6 +873,7 @@ export class McpServer {
inputSchema?: InputArgs;
outputSchema?: OutputArgs;
annotations?: ToolAnnotations;
icons?: Tool['icons'];
_meta?: Record<string, unknown>;
},
cb: ToolCallback<InputArgs>
Expand All @@ -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,
Expand All @@ -889,7 +893,8 @@ export class McpServer {
annotations,
{ taskSupport: 'forbidden' },
_meta,
cb as ToolCallback<StandardSchemaWithJSON | undefined>
cb as ToolCallback<StandardSchemaWithJSON | undefined>,
icons,
);
}

Expand Down Expand Up @@ -1096,6 +1101,7 @@ export type RegisteredTool = {
outputSchema?: StandardSchemaWithJSON;
annotations?: ToolAnnotations;
execution?: ToolExecution;
icons?: Tool['icons'];
_meta?: Record<string, unknown>;
handler: AnyToolHandler<StandardSchemaWithJSON | undefined>;
/** @hidden */
Expand Down
Loading