mirror of
https://github.com/modelcontextprotocol/servers.git
synced 2026-02-19 11:54:58 -05:00
fix(time): Fix McpError constructor usage in time server
Fixes CI failures in PR #3220. PR #3220 updated `mcp` library from 1.0.0 to 1.23.0, which caused test failures due to a breaking change in `McpError` constructor API. The `McpError` constructor now expects an `ErrorData` object instead of a plain string message. This commit fixes the usage in `get_zoneinfo()` function to use `ErrorData(code=INVALID_PARAMS, message=...)`. ```console Error before fix: AttributeError: 'str' object has no attribute 'message' ``` Also updates `mcp` dependency to >=1.23.0 in pyproject.toml to ensure compatibility with the new API.
This commit is contained in:
@@ -17,10 +17,10 @@ classifiers = [
|
||||
"Programming Language :: Python :: 3.10",
|
||||
]
|
||||
dependencies = [
|
||||
"mcp>=1.0.0",
|
||||
"mcp>=1.23.0",
|
||||
"pydantic>=2.0.0",
|
||||
"tzdata>=2024.2",
|
||||
"tzlocal>=5.3.1"
|
||||
"tzlocal>=5.3.1",
|
||||
]
|
||||
|
||||
[project.scripts]
|
||||
|
||||
@@ -8,7 +8,7 @@ from tzlocal import get_localzone_name # ← returns "Europe/Paris", etc.
|
||||
|
||||
from mcp.server import Server
|
||||
from mcp.server.stdio import stdio_server
|
||||
from mcp.types import Tool, TextContent, ImageContent, EmbeddedResource
|
||||
from mcp.types import Tool, TextContent, ImageContent, EmbeddedResource, ErrorData, INVALID_PARAMS
|
||||
from mcp.shared.exceptions import McpError
|
||||
|
||||
from pydantic import BaseModel
|
||||
@@ -54,7 +54,7 @@ def get_zoneinfo(timezone_name: str) -> ZoneInfo:
|
||||
try:
|
||||
return ZoneInfo(timezone_name)
|
||||
except Exception as e:
|
||||
raise McpError(f"Invalid timezone: {str(e)}")
|
||||
raise McpError(ErrorData(code=INVALID_PARAMS, message=f"Invalid timezone: {str(e)}"))
|
||||
|
||||
|
||||
class TimeServer:
|
||||
|
||||
818
src/time/uv.lock
generated
818
src/time/uv.lock
generated
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user