Skip to content

Commit 55ded99

Browse files
committed
fix(server): add icons field to registerTool and registerToolTask (#1864)
1 parent 7ba58da commit 55ded99

3 files changed

Lines changed: 21 additions & 2 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@modelcontextprotocol/server': patch
3+
---
4+
5+
Added `icons` field support to `registerTool()` and `registerToolTask()` APIs, matching the `ToolSchema` spec definition. Icons are now included in `tools/list` responses.

packages/server/src/experimental/tasks/mcpServer.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* @experimental
66
*/
77

8-
import type { StandardSchemaWithJSON, TaskToolExecution, ToolAnnotations, ToolExecution } from '@modelcontextprotocol/core';
8+
import type { Icon, StandardSchemaWithJSON, TaskToolExecution, ToolAnnotations, ToolExecution } from '@modelcontextprotocol/core';
99

1010
import type { AnyToolHandler, McpServer, RegisteredTool } from '../../server/mcp.js';
1111
import type { ToolTaskHandler } from './interfaces.js';
@@ -21,6 +21,7 @@ interface McpServerInternal {
2121
description: string | undefined,
2222
inputSchema: StandardSchemaWithJSON | undefined,
2323
outputSchema: StandardSchemaWithJSON | undefined,
24+
icons: Icon[] | undefined,
2425
annotations: ToolAnnotations | undefined,
2526
execution: ToolExecution | undefined,
2627
_meta: Record<string, unknown> | undefined,
@@ -82,6 +83,7 @@ export class ExperimentalMcpServerTasks {
8283
title?: string;
8384
description?: string;
8485
outputSchema?: OutputArgs;
86+
icons?: Icon[];
8587
annotations?: ToolAnnotations;
8688
execution?: TaskToolExecution;
8789
_meta?: Record<string, unknown>;
@@ -96,6 +98,7 @@ export class ExperimentalMcpServerTasks {
9698
description?: string;
9799
inputSchema: InputArgs;
98100
outputSchema?: OutputArgs;
101+
icons?: Icon[];
99102
annotations?: ToolAnnotations;
100103
execution?: TaskToolExecution;
101104
_meta?: Record<string, unknown>;
@@ -110,6 +113,7 @@ export class ExperimentalMcpServerTasks {
110113
description?: string;
111114
inputSchema?: InputArgs;
112115
outputSchema?: OutputArgs;
116+
icons?: Icon[];
113117
annotations?: ToolAnnotations;
114118
execution?: TaskToolExecution;
115119
_meta?: Record<string, unknown>;
@@ -130,6 +134,7 @@ export class ExperimentalMcpServerTasks {
130134
config.description,
131135
config.inputSchema,
132136
config.outputSchema,
137+
config.icons,
133138
config.annotations,
134139
execution,
135140
config._meta,

packages/server/src/server/mcp.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import type {
88
CreateTaskResult,
99
CreateTaskServerContext,
1010
GetPromptResult,
11+
Icon,
1112
Implementation,
1213
ListPromptsResult,
1314
ListResourcesResult,
@@ -144,6 +145,7 @@ export class McpServer {
144145
inputSchema: tool.inputSchema
145146
? (standardSchemaToJsonSchema(tool.inputSchema, 'input') as Tool['inputSchema'])
146147
: EMPTY_OBJECT_JSON_SCHEMA,
148+
icons: tool.icons,
147149
annotations: tool.annotations,
148150
execution: tool.execution,
149151
_meta: tool._meta
@@ -770,6 +772,7 @@ export class McpServer {
770772
description: string | undefined,
771773
inputSchema: StandardSchemaWithJSON | undefined,
772774
outputSchema: StandardSchemaWithJSON | undefined,
775+
icons: Icon[] | undefined,
773776
annotations: ToolAnnotations | undefined,
774777
execution: ToolExecution | undefined,
775778
_meta: Record<string, unknown> | undefined,
@@ -786,6 +789,7 @@ export class McpServer {
786789
description,
787790
inputSchema,
788791
outputSchema,
792+
icons,
789793
annotations,
790794
execution,
791795
_meta,
@@ -822,6 +826,7 @@ export class McpServer {
822826
}
823827

824828
if (updates.outputSchema !== undefined) registeredTool.outputSchema = updates.outputSchema;
829+
if (updates.icons !== undefined) registeredTool.icons = updates.icons;
825830
if (updates.annotations !== undefined) registeredTool.annotations = updates.annotations;
826831
if (updates._meta !== undefined) registeredTool._meta = updates._meta;
827832
if (updates.enabled !== undefined) registeredTool.enabled = updates.enabled;
@@ -869,6 +874,7 @@ export class McpServer {
869874
description?: string;
870875
inputSchema?: InputArgs;
871876
outputSchema?: OutputArgs;
877+
icons?: Icon[];
872878
annotations?: ToolAnnotations;
873879
_meta?: Record<string, unknown>;
874880
},
@@ -878,14 +884,15 @@ export class McpServer {
878884
throw new Error(`Tool ${name} is already registered`);
879885
}
880886

881-
const { title, description, inputSchema, outputSchema, annotations, _meta } = config;
887+
const { title, description, inputSchema, outputSchema, icons, annotations, _meta } = config;
882888

883889
return this._createRegisteredTool(
884890
name,
885891
title,
886892
description,
887893
inputSchema,
888894
outputSchema,
895+
icons,
889896
annotations,
890897
{ taskSupport: 'forbidden' },
891898
_meta,
@@ -1094,6 +1101,7 @@ export type RegisteredTool = {
10941101
description?: string;
10951102
inputSchema?: StandardSchemaWithJSON;
10961103
outputSchema?: StandardSchemaWithJSON;
1104+
icons?: Icon[];
10971105
annotations?: ToolAnnotations;
10981106
execution?: ToolExecution;
10991107
_meta?: Record<string, unknown>;
@@ -1109,6 +1117,7 @@ export type RegisteredTool = {
11091117
description?: string;
11101118
paramsSchema?: StandardSchemaWithJSON;
11111119
outputSchema?: StandardSchemaWithJSON;
1120+
icons?: Icon[];
11121121
annotations?: ToolAnnotations;
11131122
_meta?: Record<string, unknown>;
11141123
callback?: ToolCallback<StandardSchemaWithJSON>;

0 commit comments

Comments
 (0)