Skip to content

feat: add execution parameter to add_tool() for task support declaration#2157

Open
jief123 wants to merge 1 commit intomodelcontextprotocol:mainfrom
jief123:feat/add-tool-execution-param
Open

feat: add execution parameter to add_tool() for task support declaration#2157
jief123 wants to merge 1 commit intomodelcontextprotocol:mainfrom
jief123:feat/add-tool-execution-param

Conversation

@jief123
Copy link

@jief123 jief123 commented Feb 27, 2026

Summary

Add execution 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.

Motivation and Context

The MCP spec (2025-11-25) requires tools to declare task support via execution.taskSupport in the tools/list response:

In the result of tools/list, tools declare support for tasks via execution.taskSupport, which if present can have a value of "required", "optional", or "forbidden".

While server.experimental.enable_tasks() correctly handles server-level capabilities and task handler registration, there is currently no way to set execution.taskSupport on individual tools through the high-level API. This means tools always appear as taskSupport: "forbidden" to clients, even when the server supports tasks.

Usage

from mcp.types import ToolExecution, TASK_OPTIONAL

mcp.add_tool(
    my_handler,
    name="long_running_tool",
    description="A tool that takes a while",
    execution=ToolExecution(taskSupport=TASK_OPTIONAL),
)

Changes

  • src/mcp/server/mcpserver/tools/base.py — Add execution field to Tool model and execution parameter to Tool.from_function()
  • src/mcp/server/mcpserver/tools/tool_manager.py — Add execution parameter to ToolManager.add_tool() and pass through to Tool.from_function()
  • src/mcp/server/mcpserver/server.py — Add execution parameter to MCPServer.add_tool(), pass through to ToolManager.add_tool(), and include execution=info.execution in list_tools() conversion

Breaking Changes

None. The execution parameter is optional and defaults to None, preserving existing behavior.

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
  • 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

References

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
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.add_tool() missing execution parameter for task support declaration (spec compliance gap)

1 participant