Repository navigation
Description
What happened?
LocalProvider.get_tasks() never applies the provider's own transforms, so with a provider-level transform — including the documented provider.add_transform(Namespace("api")) example — the task-registration keys don't match the names the server actually dispatches.
Discovery uses the transformed name: mcp.get_tool("api_square").key is tool:api_square@, the key the callable is registered and dispatched under. But get_tasks() yields the untransformed tool:square@, so registering/enqueuing a background task for that tool fails with KeyError: 'tool:api_square@' instead of running.
Expected: get_tasks() returns the same transformed keys as discovery, as the base implementation and the sibling overrides (wrapped_provider.py, fastmcp_provider.py, server.py) do. The same namespace routed through mcp.add_provider(provider, namespace="api") works, so the add_transform path silently produces an unusable task registration.
Example Code
import asyncio
from fastmcp import FastMCP
from fastmcp.server.providers import LocalProvider
from fastmcp.server.transforms import Namespace
async def main():
provider = LocalProvider()
@provider.tool(task=True)
async def square(n: int) -> int:
return n * n
provider.add_transform(Namespace("api"))
mcp = FastMCP("demo", providers=[provider])
tool = await mcp.get_tool("api_square")
print("get_tool('api_square').key =", tool.key)
print("get_tasks() keys =", [c.key for c in await mcp.get_tasks()])
asyncio.run(main())Actual output:
get_tool('api_square').key = tool:api_square@
get_tasks() keys = ['tool:square@']
Submitting the task (repo task harness) then fails; the same namespace routed through the provider works:
[add_transform] dispatched_key='tool:api_square@' get_tasks_keys=['tool:square@']
[add_transform] run_task FAILED KeyError: 'tool:api_square@'
[add_provider ] dispatched_key='tool:api_square@' get_tasks_keys=['tool:api_square@']
[add_provider ] run_task status=completed
The non-obvious part: LocalProvider.get_tasks (fastmcp_slim/fastmcp/server/providers/local_provider/local_provider.py:456) builds its list straight from self._components and is the only get_tasks implementation that skips the for transform in self.transforms loop the others apply.
Version Information
FastMCP version: 4.0.4.dev12+58d903c8 (commit 58d903c84b0a3fe7596a15f9810ac138bda713dd)
MCP version: 2.0.0
Python version: 3.12.14
Platform: macOS-26.6.2-arm64
Happy to open a PR if useful. Related: open PR #5062 also touches local_provider.py (unrelated MCP Apps property); merged PR #2729 last changed Provider.get_tasks().
Activity
fix(local-provider): apply transforms in get_tasks (PrefectHQ#5117)