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

未关闭 适合新手
#5,559 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
76/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
python

调研方向

从src/time/src/mcp_server_time/server.py中的get_zoneinfo开始,然后检查get_current_time和convert_time的协议测试。使用America重现目录情况,并确认两个工具都返回不含文件系统路径的Invalid timezone错误;检查未知时区错误是否仍然简洁。

由索引模型根据 Issue 内容生成。

描述

bug server-time v2

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.
主要语言
TypeScript
星标
92k
派生
12k
平均合并
3 小时 12 分钟
30 天内合并 PR
174

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

modelcontextprotocol/servers 的其他 Issue

查看 modelcontextprotocol/servers 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。