refactor(time): port to MCP Python SDK v2 - #4602
Open
KarlLeen wants to merge 3 commits into
Open
Conversation
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
force-pushed
the
fix/time-sdk-v2-port
branch
2 times, most recently
from
August 1, 2026 08:15
70700a2 to
86ad391
Compare
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
src/timeto the MCP Python SDK v2 low-levelServerAPI (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.mcp>=2,<3and refreshuv.lockso the server starts cleanly on SDK 2.0.0 (McpError→MCPError).MCPErrorthroughcall_tool(do not wrap asValueError), extractcreate_tool_handlersfor tests, and add handler coverage for list/call success and error paths.Fixes #4570.
Relation to #4572 / #4577: those PRs cap
mcp<2as a short-term workaround. This PR is the proper SDK v2 port fortime; 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 testmcp==2.0.0, server initializes andget_current_time/convert_timework over stdio