Skip to content

time: an invalid timezone that names a tzdata directory returns an error with the host's filesystem path #5559

Closed

Description

@cliffhall

Problem

get_zoneinfo (src/time/src/mcp_server_time/server.py) turns any exception from loading a zone into ToolError(f"Invalid timezone: {e!s}"). For most bad names that is a clean "No time zone found" message, but a name that is a directory in the tz database (for example America) raises an OSError whose text includes the host's absolute path to the tzdata install, e.g.:

Invalid timezone: [Errno 21] Is a directory: '/Users/<user>/.../site-packages/tzdata/zoneinfo/America'

That leaks host filesystem details (including a home-directory user name) into tool output, and it is inconsistent with startup, where serve() already hides these messages.

Expected behavior

An invalid timezone always produces a fixed, clean message naming the input, such as Invalid timezone: America, with no exception text, whatever exception the zone loader raised.

Acceptance criteria

  • get_current_time and convert_time called with a tz-database directory name (America) return a clean Invalid timezone error containing no filesystem path.
  • Existing error messages for unknown names are unchanged or equally clean.
  • Tests cover the directory case at the protocol level.

Activity

  1. added this to the v2.6.0 milestone on Nov 18, 2026
  2. added
    bug
    server-time
    on Nov 18, 2026
  3. self-assigned this
    on Nov 18, 2026
  4. cliffhall commented on Nov 18, 2026

    @cliffhall
    MemberAuthor

    Fixed by #5615, merged into v2/main as 328d411.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugserver-timev2

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions