Skip to content

refactor(time): port to MCP Python SDK v2 - #4602

Open
KarlLeen wants to merge 3 commits into
modelcontextprotocol:mainfrom
KarlLeen:fix/time-sdk-v2-port
Open

refactor(time): port to MCP Python SDK v2#4602
KarlLeen wants to merge 3 commits into
modelcontextprotocol:mainfrom
KarlLeen:fix/time-sdk-v2-port

Conversation

@KarlLeen

@KarlLeen KarlLeen commented Aug 1, 2026

Copy link
Copy Markdown

Summary

  • Port src/time to the MCP Python SDK v2 low-level Server API (constructor callbacks, MCPError(code/message), ListToolsResult / CallToolResult, snake_case tool fields), matching the shape of fix(fetch): port to mcp SDK v2 #4565 / refactor(git): migrate lowlevel server to MCP Python SDK v2 #4564.
  • Require mcp>=2,<3 and refresh uv.lock so the server starts cleanly on SDK 2.0.0 (McpErrorMCPError).
  • Preserve MCPError through call_tool (do not wrap as ValueError), extract create_tool_handlers for tests, and add handler coverage for list/call success and error paths.

Fixes #4570.

Relation to #4572 / #4577: those PRs cap mcp<2 as a short-term workaround. This PR is the proper SDK v2 port for time; once merged, the time-specific cap is unnecessary. Prefer this over keeping time on the 1.x API.

Test plan

  • cd src/time && uv run pytest test/time_server_test.py -q (42 passed)
  • cd src/time && uv run ruff check src test
  • CI green on this PR
  • Spot-check: with mcp==2.0.0, server initializes and get_current_time / convert_time work over stdio

Migrate src/time to the v2 low-level Server API (same shape as modelcontextprotocol#4565):
constructor callbacks, MCPError(code/message), ListToolsResult /
CallToolResult, snake_case tool fields, mcp>=2,<3 + uv.lock.

Fixes modelcontextprotocol#4570 follow-up beyond the short-term dependency cap.
@KarlLeen
KarlLeen force-pushed the fix/time-sdk-v2-port branch 2 times, most recently from 70700a2 to 86ad391 Compare August 1, 2026 08:15
Re-raise MCPError instead of wrapping it as ValueError, extract
create_tool_handlers for unit tests, and cover list/call paths.
Narrow content[0] to TextContent before reading .text so Build time CI passes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

time: ImportError on startup with mcp SDK 2.0.0 (McpError renamed to MCPError)

1 participant