Skip to content

MCPServer.add_tool() missing execution parameter for task support declaration (spec compliance gap) #2156

@jief123

Description

@jief123

Description

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 no way to set execution.taskSupport on individual tools through the high-level API.

Current behavior

MCPServer.add_tool() (and the internal Tool model in mcp/server/mcpserver/tools/base.py) does not accept an execution parameter. Tools registered via add_tool() will always have execution: null in the tools/list response, which per spec means taskSupport defaults to "forbidden".

This means even when enable_tasks() is called and the server declares tasks.requests.tools.call capability, clients like the MCP Inspector see taskSupport as "forbidden" and disable the "Run as task" option.

Expected behavior

MCPServer.add_tool() should accept an optional execution parameter (of type ToolExecution) so developers can declare taskSupport per tool:

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),
)

Workaround

Currently the only workaround is to monkey-patch the tools/list handler to inject execution.taskSupport into the response:

server = mcp._lowlevel_server
original = server._request_handlers.get("tools/list")

async def patched(ctx, params):
    result = await original(ctx, params)
    for tool in result.tools:
        tool.execution = ToolExecution(taskSupport=TASK_OPTIONAL)
    return result

server._request_handlers["tools/list"] = patched

Affected files

  • src/mcp/server/mcpserver/tools/base.pyTool model and Tool.from_function() missing execution field
  • src/mcp/server/mcpserver/tools/tool_manager.pyToolManager.add_tool() missing execution parameter
  • src/mcp/server/mcpserver/server.pyMCPServer.add_tool() missing execution parameter

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions