Skip to content

Commit c0be919

Browse files
cliffhallclaude
andcommitted
fix(time): report an empty convert_time timezone as a missing argument
convert_time passed an empty source_timezone (or target_timezone) straight to zoneinfo, so the client saw zoneinfo's raw "ZoneInfo keys must be normalized relative paths" text. get_current_time already reports an empty timezone as "Missing required argument: timezone"; convert_time now does the same for both of its timezone arguments. The pinning test asserts the new message for both cases, and its KNOWN BUG modelcontextprotocol#5003 marker is gone. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: cliffhall <[email protected]>
1 parent 571e2b3 commit c0be919

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

‎src/time/src/mcp_server_time/server.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,9 @@ async def call_tool(
211211
raise ValueError( # pragma: no cover # unreachable: the SDK rejects a missing key against inputSchema first
212212
"Missing required arguments"
213213
)
214+
for key in ["source_timezone", "target_timezone"]:
215+
if not arguments[key]:
216+
raise ValueError(f"Missing required argument: {key}")
214217

215218
result = time_server.convert_time(
216219
arguments["source_timezone"],

‎src/time/tests/test_protocol.py‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,6 @@ async def test_convert_time_ignores_extra_arguments() -> None:
811811
assert result["target"]["timezone"] == "UTC"
812812

813813

814-
# KNOWN BUG #5003: an empty source_timezone surfaces zoneinfo's raw message, unlike get_current_time's "Missing required argument"; the fix changes this assertion.
815814
@pytest.mark.parametrize(
816815
"arguments,expected",
817816
[
@@ -843,13 +842,15 @@ async def test_convert_time_ignores_extra_arguments() -> None:
843842
{"source_timezone": "UTC", "time": "12:00", "target_timezone": "Bad/Zone"},
844843
handler_error("Invalid timezone: 'No time zone found with key Bad/Zone'"),
845844
),
846-
# Unlike get_current_time, an empty timezone is not special-cased and
847-
# surfaces zoneinfo's own message.
845+
# Like get_current_time, an empty timezone is reported as a missing
846+
# argument rather than as zoneinfo's own message.
848847
(
849848
{"source_timezone": "", "time": "12:00", "target_timezone": "UTC"},
850-
handler_error(
851-
"Invalid timezone: ZoneInfo keys must be normalized relative paths, got: "
852-
),
849+
handler_error("Missing required argument: source_timezone"),
850+
),
851+
(
852+
{"source_timezone": "UTC", "time": "12:00", "target_timezone": ""},
853+
handler_error("Missing required argument: target_timezone"),
853854
),
854855
],
855856
)

0 commit comments

Comments
 (0)