Feature Request: Support MCP Task Mode (SEP-1686) for Background Tool Execution
Feature Request: Support MCP Task Mode (SEP-1686) for Background Tool Execution
Summary
Add client-side support for SEP-1686 Tasks, enabling MCP tools to run in background mode similar to how Bash commands support run_in_background.
Problem
Currently, MCP tool calls in Claude Code are synchronous and blocking. When Claude calls a long-running MCP tool (e.g., executing a Jupyter notebook cell that trains a model for 10 minutes), the entire conversation blocks until completion.
This is inconsistent with how Bash commands work - they support run_in_background: true which returns immediately and notifies when complete. MCP tools have no equivalent mechanism, even though the protocol now supports it.
Use Case: Research Workflows with Jupyter/IPython
I use an MCP server (scribe-notebook) that provides Jupyter kernel execution. Common workflow:
- Claude executes a cell that runs an experiment (5-30 minutes)
- Currently: Claude is blocked, I wait, context is wasted
- Desired: Claude continues working on other tasks, gets notified when cell completes
This pattern applies to any MCP server wrapping long-running operations:
- ML training/inference
- CI/CD pipelines
- Database migrations
- Browser automation
- External API workflows
Solution: Implement SEP-1686 Client Support
SEP-1686 ("Tasks") is an accepted MCP specification that adds:
- Task-augmented mode: Client requests a task ID instead of blocking
- Progress notifications: Server streams status updates
- Result retrieval: Client fetches results when ready
FastMCP 2.14+ already implements server-side support via @mcp.tool(task=True):
@mcp.tool(task=True)
async def execute_code(session_id: str, code: str, progress: Progress = Progress()):
await progress.set_message("Executing cell...")
result = await run_cell(session_id, code)
await progress.set_message("Done")
return result
The server is ready - Claude Code just needs to:
- Send
progressTokenin tool requests to opt into task mode - Handle task IDs returned instead of blocking
- Display progress notifications (like Bash background tasks do)
- Allow continuing conversation while task runs
Proposed UX
Similar to Bash background commands:
Claude: I'll execute this training cell in the background.
[MCP tool running in background with ID: abc123]
Claude: While that runs, let me review your test file...
[Task notification: abc123 completed]
Claude: The training finished. Let me check the results...
Why This Matters
- Consistency: Bash has
run_in_background, MCP tools should too - Efficiency: Don't waste context window on blocking waits
- Protocol alignment: SEP-1686 is accepted, servers are implementing it
- Research workflows: Long-running experiments are common in ML/research
Related Issues
- #1478 - MCP Notification-Driven Auto-Resume (closed as not planned, but predates SEP-1686)
- #1759 - Implementing background tasks via MCP servers
- #8712 - Background execution of MCP tools
References
This issue has 9 comments on GitHub. Read the full discussion on GitHub ↗