Remove Tasks (SEP-1686) from the SDK

Merged
MA
5mo ago
+63-12963

Tasks (SEP-1686) have been removed from the MCP specification (modelcontextprotocol/modelcontextprotocol#2663) and will return as a separate extension. This removes all task-related code, types, examples, tests, and documentation from the SDK.

Motivation and Context

The original Tasks SEP that landed in the 2025-11-25 spec has been pulled from the draft schema and is moving to an extension. Keeping the experimental implementation around would mean maintaining ~13k lines against a moving target that no longer matches the spec, so this strips it entirely. When the extension lands it can be re-added against the new shape.

How Has This Been Tested?

  • ./scripts/test — full suite, 100% coverage, strict-no-cover clean
  • pyright, ruff, pre-commit hooks all pass
  • uv lock regenerated to drop the four simple-task* workspace members

Breaking Changes

Yes (v2 only — main is already a breaking-change branch). Documented in docs/migration.md:

  • All Task* / *TasksCapability types, ToolExecution, and Tool.execution removed from mcp.types
  • RequestParams.task, ClientCapabilities.tasks, ServerCapabilities.tasks removed
  • mcp.{client,server,shared}.experimental and mcp.server.lowlevel.experimental packages removed
  • experimental properties removed from ClientSession / ServerSession / Server; experimental field removed from ServerRequestContext
  • BaseSession.add_response_router and mcp.shared.response_router removed

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

Additional context

A few non-obvious decisions:

  • CancelledNotificationParams.request_id stays RequestId | None. The Tasks PR made it optional, but the draft schema kept it that way after removing tasks, so only the task-referencing docstring was changed.
  • BaseSession._handle_response is kept (with the router-dispatch loop stripped). The extraction from _receive_loop plus the null-ID error handling is a standalone improvement that doesn't depend on tasks.
  • server/validation.py is kept. It's a non-task refactor of sampling-tools validation that #1645 happened to extract; only the "task-augmented" wording in the module docstring was dropped.
  • ResponseRouter, ServerSession.send_message, and the _build_*_request helpers are deleted rather than kept as "generic plumbing" — they had zero non-task callers, and keeping them would have required either pragmas or synthetic tests for the 100% coverage requirement.
  • Added tests/server/test_session.py::test_check_client_capability because the experimental task tests were the only thing exercising that public method.

AI Disclaimer