Skip to content

fix(server): add icons field to registerTool and registerToolTask#1881

Open
sainathreddyb wants to merge 1 commit intomodelcontextprotocol:mainfrom
sainathreddyb:fix/register-tool-icons-support
Open

fix(server): add icons field to registerTool and registerToolTask#1881
sainathreddyb wants to merge 1 commit intomodelcontextprotocol:mainfrom
sainathreddyb:fix/register-tool-icons-support

Conversation

@sainathreddyb
Copy link
Copy Markdown

Summary

Add icons field support to registerTool() and registerToolTask() APIs, matching the ToolSchema spec definition which includes IconsSchema.shape. Icons are now included in tools/list responses and can be updated via tool.update().

Fixes #1864

Motivation and Context

The MCP spec's ToolSchema includes IconsSchema.shape, making icons a valid top-level property on tool definitions. However, McpServer.registerTool() did not accept icons in its config, and the tools/list handler did not serialize it. This closes the gap between the spec and the SDK.

How Has This Been Tested?

  • All 425 existing integration tests pass
  • Added 4 new integration tests:
    • Register tool with icons → verify icons appear in tools/list
    • Register tool with icons and annotations → verify both are returned
    • Update tool icons via tool.update() → verify updated icons in listing
    • Register tool without icons → verify icons is undefined in listing

Breaking Changes

None. This is a purely additive change — icons is optional in all APIs.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the [MCP Documentation](https://modelcontextprotocol.io)
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

This addresses the same issue as #1873 but additionally includes integration tests covering registration, update, and listing behavior for the icons field.

Add icons support to the registerTool() and registerToolTask() APIs,
matching the ToolSchema spec definition which includes IconsSchema.shape.

- Add icons?: Icon[] to registerTool() config parameter type
- Add icons to _createRegisteredTool() signature and object construction
- Add icons to tools/list handler toolDefinition object
- Add icons to RegisteredTool type and its update() method
- Add icons to all registerToolTask() overload signatures
- Add integration tests for icons registration, update, and listing

Ref modelcontextprotocol#1864
@sainathreddyb sainathreddyb requested a review from a team as a code owner April 12, 2026 02:22
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 12, 2026

🦋 Changeset detected

Latest commit: 2d0cb9c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@modelcontextprotocol/server Patch
@modelcontextprotocol/express Patch
@modelcontextprotocol/fastify Patch
@modelcontextprotocol/hono Patch
@modelcontextprotocol/node Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 12, 2026

Open in StackBlitz

@modelcontextprotocol/client

npm i https://pkg.pr.new/@modelcontextprotocol/client@1881

@modelcontextprotocol/server

npm i https://pkg.pr.new/@modelcontextprotocol/server@1881

@modelcontextprotocol/express

npm i https://pkg.pr.new/@modelcontextprotocol/express@1881

@modelcontextprotocol/fastify

npm i https://pkg.pr.new/@modelcontextprotocol/fastify@1881

@modelcontextprotocol/hono

npm i https://pkg.pr.new/@modelcontextprotocol/hono@1881

@modelcontextprotocol/node

npm i https://pkg.pr.new/@modelcontextprotocol/node@1881

commit: 2d0cb9c

Copy link
Copy Markdown

@auapwllc-dev auapwllc-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

McpServer.registerTool() does not support icons field from ToolScheme

2 participants