Epic Overview
Migrate ContextForge from Python MCP SDK 1.x to 2.0.0, addressing all breaking changes, adopting new features, and ensuring full compatibility with the updated MCP specification.
Migration Guide Reference: https://py.sdk.modelcontextprotocol.io/v2/migration/
Background
MCP Python SDK v2.0.0 introduces significant breaking changes to improve API design, align with the MCP specification, and enhance type safety. This is a major version upgrade requiring comprehensive code changes and thorough testing.
Key Breaking Changes
1. Core Renames & Imports
FastMCP → MCPServer (main server class)
mcp.types → mcp-types package (standalone)
McpError → MCPError (exception class)
2. Field Naming Convention
- All fields changed from
camelCase to snake_case:
inputSchema → input_schema
isError → is_error
nextCursor → next_cursor
progressToken → progress_token
- Critical: Must use
by_alias=True when serializing models to JSON
3. Type System Changes
- Resource URIs now
str instead of AnyUrl
- Extra fields on MCP types no longer preserved (use
_meta instead)
RootModel unions replaced with TypeAdapter validation
- Stricter field validation across the board
4. Server Changes
- Constructor signature changed
- Context injection via
ctx parameter (not mcp.get_context())
- Sync handlers now run on worker threads
- Transport parameters moved from constructor to
run() method
MCPError raised in handlers surfaces as JSON-RPC error
5. Client Changes
- Connection mode defaults to
'auto' (use 'legacy' for old behavior)
get_server_capabilities() → properties: server_capabilities, server_info, protocol_version
cursor parameter removed (use params=PaginatedRequestParams(cursor=...))
- Timeouts now
float seconds instead of timedelta
- Request timeout error code:
408 → -32001 (REQUEST_TIMEOUT)
streamablehttp_client removed (use streamable_http_client)
- WebSocket transport removed entirely
Migration Phases
Phase 1: Dependency Updates & Core Renames (1 week)
Dependencies:
Core Renames:
Verification:
Phase 2: Field Name Migration (1-2 weeks)
Code Changes:
Verification:
Phase 3: Server Migration (2-3 weeks)
MCPServer Constructor:
Context Injection:
Handler Behavior:
Low-Level Server Changes:
Verification:
Phase 4: Client Migration (1-2 weeks)
Connection Mode:
API Changes:
Transport Changes:
Verification:
Phase 5: Type System Updates (1 week)
Resource URIs:
Extra Fields:
Verification:
Phase 6: New Features Adoption (1-2 weeks)
Multi-Round Requests:
Enhanced Security:
Protocol Improvements:
Verification:
Phase 7: Deprecation Handling (1 week)
Address Deprecations:
Verification:
Phase 8: Testing & Validation (2-3 weeks)
Unit Tests:
Integration Tests:
End-to-End Tests:
Performance Tests:
Verification:
Phase 9: Documentation & Deployment (1 week)
Documentation:
Deployment:
Verification:
Acceptance Criteria
Common Migration Issues & Fixes
Issue: AttributeError: 'Tool' object has no attribute 'inputSchema'
Fix: Use input_schema (snake_case)
Issue: ModuleNotFoundError: No module named 'mcp.server.fastmcp'
Fix: Import from mcp.server.mcpserver
Issue: TypeError: unsupported operand type(s) for +: 'float' and 'datetime.timedelta'
Fix: Replace timedelta(seconds=30) with 30 (plain float)
Issue: Sync handler raises RuntimeError from asyncio.get_running_loop()
Fix: Declare handler as async def or avoid asyncio calls (runs on worker thread)
Issue: Resource URI AttributeError: 'str' object has no attribute 'host'
Fix: URIs are now plain strings; use urllib.parse to parse them
Dependencies
- Python MCP SDK 2.0.0
- mcp-types package
- anyio ≥4.9
- pydantic ≥2.12
- sse-starlette ≥3.0
- Existing ContextForge codebase
Related Issues
Success Metrics
- 100% SDK 1.x code migrated to SDK 2.0.0
- Zero breaking changes for end users
- Test coverage >90%
- No performance regressions
- Successful production deployment
- Zero critical bugs in first 30 days
Timeline Estimate
- Phase 1: Dependency Updates & Core Renames (1 week)
- Phase 2: Field Name Migration (1-2 weeks)
- Phase 3: Server Migration (2-3 weeks)
- Phase 4: Client Migration (1-2 weeks)
- Phase 5: Type System Updates (1 week)
- Phase 6: New Features Adoption (1-2 weeks)
- Phase 7: Deprecation Handling (1 week)
- Phase 8: Testing & Validation (2-3 weeks)
- Phase 9: Documentation & Deployment (1 week)
Total: 11-16 weeks
Risks & Mitigation
Risk: Breaking Changes Impact Production
- Mitigation: Comprehensive testing, staged rollout, rollback plan
Risk: Performance Regressions
- Mitigation: Performance benchmarking, optimization, monitoring
Risk: Incomplete Migration
- Mitigation: Thorough code review, automated checks, migration checklist
Risk: User Impact
- Mitigation: Clear communication, migration guide, support resources
Notes
This is a major version upgrade with extensive breaking changes. The migration must be thorough and well-tested to avoid production issues. The phased approach ensures systematic migration with validation at each step.
References
Labels
epic, mcp-protocol, enhancement, breaking-change
Epic Overview
Migrate ContextForge from Python MCP SDK 1.x to 2.0.0, addressing all breaking changes, adopting new features, and ensuring full compatibility with the updated MCP specification.
Migration Guide Reference: https://py.sdk.modelcontextprotocol.io/v2/migration/
Background
MCP Python SDK v2.0.0 introduces significant breaking changes to improve API design, align with the MCP specification, and enhance type safety. This is a major version upgrade requiring comprehensive code changes and thorough testing.
Key Breaking Changes
1. Core Renames & Imports
FastMCP→MCPServer(main server class)mcp.types→mcp-typespackage (standalone)McpError→MCPError(exception class)2. Field Naming Convention
camelCasetosnake_case:inputSchema→input_schemaisError→is_errornextCursor→next_cursorprogressToken→progress_tokenby_alias=Truewhen serializing models to JSON3. Type System Changes
strinstead ofAnyUrl_metainstead)RootModelunions replaced withTypeAdaptervalidation4. Server Changes
ctxparameter (notmcp.get_context())run()methodMCPErrorraised in handlers surfaces as JSON-RPC error5. Client Changes
'auto'(use'legacy'for old behavior)get_server_capabilities()→ properties:server_capabilities,server_info,protocol_versioncursorparameter removed (useparams=PaginatedRequestParams(cursor=...))floatseconds instead oftimedelta408→-32001(REQUEST_TIMEOUT)streamablehttp_clientremoved (usestreamable_http_client)Migration Phases
Phase 1: Dependency Updates & Core Renames (1 week)
Dependencies:
mcp-typespackage dependencypyproject.tomlwith new version constraintsCore Renames:
FastMCP→MCPServerimportsMcpError→MCPErrorthroughout codebasemcp.types→mcp_typesimportsVerification:
Phase 2: Field Name Migration (1-2 weeks)
Code Changes:
camelCasefields tosnake_case:inputSchema→input_schemaisError→is_errornextCursor→next_cursorprogressToken→progress_tokenby_alias=Trueto all JSON serialization callsVerification:
Phase 3: Server Migration (2-3 weeks)
MCPServer Constructor:
FastMCP(name, desc)→MCPServer(name, instructions=desc)run()methodContext Injection:
mcp.get_context()withctx: Contextparameter injectionctxparameterctxparameterctxparameterHandler Behavior:
call_tool()returnsCallToolResultMCPErrornow surfaces as JSON-RPC errorLow-Level Server Changes:
on_*parameters(ctx, params)instead of unpacked argumentsrequest_contextproperty usage (use injectedctx)Verification:
Phase 4: Client Migration (1-2 weeks)
Connection Mode:
'auto')mode='legacy'where needed for backward compatibilityAPI Changes:
get_server_capabilities()with propertiescursorparameter, useparams=PaginatedRequestParams(cursor=...)timedeltatofloatseconds408→-32001Transport Changes:
streamablehttp_clientwithstreamable_http_clientget_session_idcallback usageVerification:
Phase 5: Type System Updates (1 week)
Resource URIs:
AnyUrl→strurllib.parsefor URI parsing where neededExtra Fields:
_metausageRootModelunions toTypeAdaptervalidationVerification:
Phase 6: New Features Adoption (1-2 weeks)
Multi-Round Requests:
InputRequiredResultfor tools requiring client inputInputRequiredResultfor resources requiring client inputInputRequiredResultfor prompts requiring client inputEnhanced Security:
Protocol Improvements:
_metaenvelope on every requestVerification:
Phase 7: Deprecation Handling (1 week)
Address Deprecations:
SUPPORTED_PROTOCOL_VERSIONSwithHANDSHAKE_PROTOCOL_VERSIONSVerification:
Phase 8: Testing & Validation (2-3 weeks)
Unit Tests:
Integration Tests:
End-to-End Tests:
Performance Tests:
Verification:
Phase 9: Documentation & Deployment (1 week)
Documentation:
Deployment:
Verification:
Acceptance Criteria
Common Migration Issues & Fixes
Issue:
AttributeError: 'Tool' object has no attribute 'inputSchema'Fix: Use
input_schema(snake_case)Issue:
ModuleNotFoundError: No module named 'mcp.server.fastmcp'Fix: Import from
mcp.server.mcpserverIssue:
TypeError: unsupported operand type(s) for +: 'float' and 'datetime.timedelta'Fix: Replace
timedelta(seconds=30)with30(plain float)Issue: Sync handler raises
RuntimeErrorfromasyncio.get_running_loop()Fix: Declare handler as
async defor avoid asyncio calls (runs on worker thread)Issue: Resource URI
AttributeError: 'str' object has no attribute 'host'Fix: URIs are now plain strings; use
urllib.parseto parse themDependencies
Related Issues
Success Metrics
Timeline Estimate
Total: 11-16 weeks
Risks & Mitigation
Risk: Breaking Changes Impact Production
Risk: Performance Regressions
Risk: Incomplete Migration
Risk: User Impact
Notes
This is a major version upgrade with extensive breaking changes. The migration must be thorough and well-tested to avoid production issues. The phased approach ensures systematic migration with validation at each step.
References
Labels
epic, mcp-protocol, enhancement, breaking-change