Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

time server not working #489

Open
robotdad opened this issue Jan 6, 2025 · 1 comment
Open

time server not working #489

robotdad opened this issue Jan 6, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@robotdad
Copy link
Contributor

robotdad commented Jan 6, 2025

The MCP time server is not working on Windows. Logs below.

Installed 22 packages in 3.65s
Traceback (most recent call last):
File "C:\Users\mgoodner\AppData\Local\Programs\Python\Python311\Lib\zoneinfo_common.py", line 12, in load_tzdata
return resources.files(package_name).joinpath(resource_name).open("rb")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\mgoodner\AppData\Local\Programs\Python\Python311\Lib\pathlib.py", line 1044, in open
return io.open(self, mode, buffering, encoding, errors, newline)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'C:\Users\mgoodner\AppData\Local\uv\cache\archive-v0\ffmqKEu2d_J95JnRz3Y0o\Lib\site-packages\tzdata\zoneinfo\Pacific Standard Time'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "", line 198, in run_module_as_main
File "", line 88, in run_code
File "C:\Users\mgoodner\AppData\Local\uv\cache\archive-v0\ffmqKEu2d_J95JnRz3Y0o\Scripts\mcp-server-time.exe_main
.py", line 8, in
File "C:\Users\mgoodner\AppData\Local\uv\cache\archive-v0\ffmqKEu2d_J95JnRz3Y0o\Lib\site-packages\mcp_server_time_init
.py", line 15, in main
asyncio.run(serve(args.local_timezone))
File "C:\Users\mgoodner\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 190, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "C:\Users\mgoodner\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\mgoodner\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py", line 654, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "C:\Users\mgoodner\AppData\Local\uv\cache\archive-v0\ffmqKEu2d_J95JnRz3Y0o\Lib\site-packages\mcp_server_time\server.py", line 119, in serve
local_tz = str(get_local_tz(local_timezone))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\mgoodner\AppData\Local\uv\cache\archive-v0\ffmqKEu2d_J95JnRz3Y0o\Lib\site-packages\mcp_server_time\server.py", line 45, in get_local_tz
return ZoneInfo(str(tzinfo))
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\mgoodner\AppData\Local\Programs\Python\Python311\Lib\zoneinfo_common.py", line 24, in load_tzdata
raise ZoneInfoNotFoundError(f"No time zone found with key {key}")
zoneinfo._common.ZoneInfoNotFoundError: 'No time zone found with key Pacific Standard Time'

@robotdad robotdad added the bug Something isn't working label Jan 6, 2025
@g-votte
Copy link

g-votte commented Feb 6, 2025

The same error happens with macOS.

Repro

Run the following commands:

pip install mcp-server-time
python -m mcp_server_time

We can also reproduce with uvx:

uvx mcp-server-time

I saw the problem with mcp-server-time==0.6.2:

pip freeze | grep mcp-server-time
mcp-server-time==0.6.2

Analysis

This error occurs during server launch, specifically when --local-timezone is not specified.

The issue is in these lines:

tzinfo = datetime.now().astimezone(tz=None).tzinfo
if tzinfo is not None:
return ZoneInfo(str(tzinfo))

datetime.now().astimezone().tzinfo returns a non-IANA format on macOS and Windows, which causes an error when passed to ZoneInfo(str(tzinfo)).

Workaround

We can avoid this issue by using Docker:

"mcpServers": {
  "time": {
    "command": "docker",
    "args": ["run", "-i", "--rm", "mcp/time"]
  }
}

Possible Solutions

While this issue isn't critical thanks to the official Docker image, we should either implement a platform-independent solution or explicitly document the supported platforms.

Possible approaches:

  • Document that running via uvx/python on macOS/Windows is not supported
  • Introduce a package to reliably get IANA timezone format (e.g., tzlocal)
  • Fall back to UTC as the default timezone

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants