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/add-tool-icons-support.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@modelcontextprotocol/server': patch
---

Added `icons` field support to `registerTool()` and `registerToolTask()` APIs, matching the `ToolSchema` spec definition. Icons are now included in `tools/list` responses.
7 changes: 6 additions & 1 deletion packages/server/src/experimental/tasks/mcpServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @experimental
*/

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

import type { AnyToolHandler, McpServer, RegisteredTool } from '../../server/mcp.js';
import type { ToolTaskHandler } from './interfaces.js';
Expand All @@ -21,6 +21,7 @@ interface McpServerInternal {
description: string | undefined,
inputSchema: StandardSchemaWithJSON | undefined,
outputSchema: StandardSchemaWithJSON | undefined,
icons: Icon[] | undefined,
annotations: ToolAnnotations | undefined,
execution: ToolExecution | undefined,
_meta: Record<string, unknown> | undefined,
Expand Down Expand Up @@ -82,6 +83,7 @@ export class ExperimentalMcpServerTasks {
title?: string;
description?: string;
outputSchema?: OutputArgs;
icons?: Icon[];
annotations?: ToolAnnotations;
execution?: TaskToolExecution;
_meta?: Record<string, unknown>;
Expand All @@ -96,6 +98,7 @@ export class ExperimentalMcpServerTasks {
description?: string;
inputSchema: InputArgs;
outputSchema?: OutputArgs;
icons?: Icon[];
annotations?: ToolAnnotations;
execution?: TaskToolExecution;
_meta?: Record<string, unknown>;
Expand All @@ -110,6 +113,7 @@ export class ExperimentalMcpServerTasks {
description?: string;
inputSchema?: InputArgs;
outputSchema?: OutputArgs;
icons?: Icon[];
annotations?: ToolAnnotations;
execution?: TaskToolExecution;
_meta?: Record<string, unknown>;
Expand All @@ -130,6 +134,7 @@ export class ExperimentalMcpServerTasks {
config.description,
config.inputSchema,
config.outputSchema,
config.icons,
config.annotations,
execution,
config._meta,
Expand Down
11 changes: 10 additions & 1 deletion packages/server/src/server/mcp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type {
CreateTaskResult,
CreateTaskServerContext,
GetPromptResult,
Icon,
Implementation,
ListPromptsResult,
ListResourcesResult,
Expand Down Expand Up @@ -144,6 +145,7 @@ export class McpServer {
inputSchema: tool.inputSchema
? (standardSchemaToJsonSchema(tool.inputSchema, 'input') as Tool['inputSchema'])
: EMPTY_OBJECT_JSON_SCHEMA,
icons: tool.icons,
annotations: tool.annotations,
execution: tool.execution,
_meta: tool._meta
Expand Down Expand Up @@ -770,6 +772,7 @@ export class McpServer {
description: string | undefined,
inputSchema: StandardSchemaWithJSON | undefined,
outputSchema: StandardSchemaWithJSON | undefined,
icons: Icon[] | undefined,
annotations: ToolAnnotations | undefined,
execution: ToolExecution | undefined,
_meta: Record<string, unknown> | undefined,
Expand All @@ -786,6 +789,7 @@ export class McpServer {
description,
inputSchema,
outputSchema,
icons,
annotations,
execution,
_meta,
Expand Down Expand Up @@ -822,6 +826,7 @@ export class McpServer {
}

if (updates.outputSchema !== undefined) registeredTool.outputSchema = updates.outputSchema;
if (updates.icons !== undefined) registeredTool.icons = updates.icons;
if (updates.annotations !== undefined) registeredTool.annotations = updates.annotations;
if (updates._meta !== undefined) registeredTool._meta = updates._meta;
if (updates.enabled !== undefined) registeredTool.enabled = updates.enabled;
Expand Down Expand Up @@ -869,6 +874,7 @@ export class McpServer {
description?: string;
inputSchema?: InputArgs;
outputSchema?: OutputArgs;
icons?: Icon[];
annotations?: ToolAnnotations;
_meta?: Record<string, unknown>;
},
Expand All @@ -878,14 +884,15 @@ export class McpServer {
throw new Error(`Tool ${name} is already registered`);
}

const { title, description, inputSchema, outputSchema, annotations, _meta } = config;
const { title, description, inputSchema, outputSchema, icons, annotations, _meta } = config;

return this._createRegisteredTool(
name,
title,
description,
inputSchema,
outputSchema,
icons,
annotations,
{ taskSupport: 'forbidden' },
_meta,
Expand Down Expand Up @@ -1094,6 +1101,7 @@ export type RegisteredTool = {
description?: string;
inputSchema?: StandardSchemaWithJSON;
outputSchema?: StandardSchemaWithJSON;
icons?: Icon[];
annotations?: ToolAnnotations;
execution?: ToolExecution;
_meta?: Record<string, unknown>;
Expand All @@ -1109,6 +1117,7 @@ export type RegisteredTool = {
description?: string;
paramsSchema?: StandardSchemaWithJSON;
outputSchema?: StandardSchemaWithJSON;
icons?: Icon[];
annotations?: ToolAnnotations;
_meta?: Record<string, unknown>;
callback?: ToolCallback<StandardSchemaWithJSON>;
Expand Down
Loading