Repository navigation
Description
Summary
Any tool transform that goes through Tool.from_tool() — i.e. both Tool.from_tool(...) directly and mcp.add_transform(ToolTransform({...})) (whose ToolTransformConfig.apply() calls it) — silently strips background-task support from task-enabled tools. A tool registered with task=True that is renamed or rewrapped by a transform comes out with TaskConfig(mode="forbidden") and execution=None, so:
- The wire tool no longer advertises task execution (
to_mcp_tool().execution is None), so an opted-in client can never get aCreateTaskResultfor it. - The tasks extension interceptor (
fastmcp_tasks/extension.py) checkstool.task_config.supports_tasks()before tasking a call, so the transformed tool always runs in the foreground. get_tasks()/ Docket registration (fastmcp_slim/fastmcp/server/providers/base.py,_apply_task_transforms) filters onc.task_config.supports_tasks()after applying the provider's transforms, so the renamed task tool silently disappears from task registration even though it remains callable.
Repro
import asyncio
from fastmcp import FastMCP
from fastmcp.server.transforms import ToolTransform
from fastmcp.tools import Tool
from fastmcp.tools.tool_transform import ToolTransformConfig
async def slow(x: int) -> int:
return x
async def main() -> None:
# Minimal path: Tool.from_tool
tool = Tool.from_function(slow, task=True)
transformed = Tool.from_tool(tool, name="slow_v2")
print("parent mode:", tool.task_config.mode)
print("transformed mode:", transformed.task_config.mode)
print("parent execution:", tool.to_mcp_tool().execution)
print("transformed execution:", transformed.to_mcp_tool().execution)
# Server-level path: ToolTransform + get_tasks
mcp = FastMCP("repro")
mcp.add_transform(ToolTransform({"slow": ToolTransformConfig(name="slow_v2")}))
mcp.add_tool(Tool.from_function(slow, task=True))
print("get_tasks():", [c.name for c in await mcp.get_tasks()])
asyncio.run(main())Output on current main (commit fb52bd3):
parent mode: optional
transformed mode: forbidden
parent execution: task_support='optional'
transformed execution: None
get_tasks(): []
Expected: a pure rename preserves the parent's task capability — mode='optional', execution=task_support='optional', and get_tasks() == ['slow_v2'].
Root cause
TransformedTool.from_tool (fastmcp_slim/fastmcp/tools/tool_transform.py, the cls(...) call around line 611) threads name, version, title, description, parameters, output_schema, tags, annotations, meta and auth from the parent — but not task_config or execution. The FastMCPComponent default TaskConfig(mode="forbidden") then applies.
The mounting path already does the right thing: FastMCPProviderTool.wrap (fastmcp_slim/fastmcp/server/providers/fastmcp_provider.py:72-73) passes task_config=tool.task_config, execution=tool.execution, so a task-enabled tool mounted from a child server keeps task support. Transforms are the only path that loses it.
Evidence / fix
- Reproduced on main at commit
fb52bd3(v4.1.1.dev5); the snippet above is exactly what it prints there. - Threading the two missing fields in
from_tool'scls(...)call — addingtask_config=tool.task_config, execution=tool.execution, mirroringFastMCPProviderTool.wrap— makes the repro printoptional/task_support='optional'/['slow_v2']. Two focused unit tests (transformed toolsupports_tasks()andto_mcp_tool().execution is not None) go red on main and green with that change. - With the fix, the surrounding suites all pass:
tests/tools/,tests/tasks/,tests/server/transforms/, andtests/server/. - I have this minimal fix plus the regression tests ready and am happy to open a PR.
Related
#5687 (transformed tools lose their icons) is the same family — fields not threaded through TransformedTool.from_tool — but distinct fields; this issue covers the task_config/execution loss.
Activity
Keep task config and execution on transformed tools
Keep task config and execution on transformed tools (PrefectHQ#5793)