feat: add execution parameter to add_tool() for task support declaration#2157
Open
jief123 wants to merge 1 commit intomodelcontextprotocol:mainfrom
Open
feat: add execution parameter to add_tool() for task support declaration#2157jief123 wants to merge 1 commit intomodelcontextprotocol:mainfrom
execution parameter to add_tool() for task support declaration#2157jief123 wants to merge 1 commit intomodelcontextprotocol:mainfrom
Conversation
Add ToolExecution parameter to MCPServer.add_tool(), ToolManager.add_tool(), and Tool.from_function() to allow declaring execution.taskSupport per tool as required by MCP spec 2025-11-25. Also pass execution through in MCPServer.list_tools() when converting internal Tool to MCP types.Tool. Fixes modelcontextprotocol#2156
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add
executionparameter toMCPServer.add_tool(),ToolManager.add_tool(), andTool.from_function()to allow declaringexecution.taskSupportper tool as required by MCP spec 2025-11-25.Also pass
executionthrough inMCPServer.list_tools()when converting internalToolto MCPtypes.Tool.Motivation and Context
The MCP spec (2025-11-25) requires tools to declare task support via
execution.taskSupportin thetools/listresponse:While
server.experimental.enable_tasks()correctly handles server-level capabilities and task handler registration, there is currently no way to setexecution.taskSupporton individual tools through the high-level API. This means tools always appear astaskSupport: "forbidden"to clients, even when the server supports tasks.Usage
Changes
src/mcp/server/mcpserver/tools/base.py— Addexecutionfield toToolmodel andexecutionparameter toTool.from_function()src/mcp/server/mcpserver/tools/tool_manager.py— Addexecutionparameter toToolManager.add_tool()and pass through toTool.from_function()src/mcp/server/mcpserver/server.py— Addexecutionparameter toMCPServer.add_tool(), pass through toToolManager.add_tool(), and includeexecution=info.executioninlist_tools()conversionBreaking Changes
None. The
executionparameter is optional and defaults toNone, preserving existing behavior.Types of changes
Checklist
References
executionparameter for task support declaration (spec compliance gap) #2156