时间 MCP 服务器
提供时间和时区转换功能的模型上下文协议 (MLM) 服务器。该服务器使 LLM 能够获取当前时间信息,并使用 IANA 时区名称执行时区转换,并自动检测系统时区。
可用工具
get_current_time
- 获取特定时区或系统时区的当前时间。- 必需参数:
timezone
(字符串):IANA 时区名称(例如,“America/New_York”、“Europe/London”)
convert_time
- 在时区之间转换时间。- 必需参数:
source_timezone
(字符串):源 IANA 时区名称time
(字符串):24 小时格式的时间(HH:MM)target_timezone
(字符串):目标 IANA 时区名称
安装
使用 uv(推荐)
使用uv
时无需特殊安装。我们将使用uvx
直接运行mcp-server-time 。
使用 PIP
或者,您可以通过 pip 安装time-mcp-local
:
pip install time-mcp-local
安装后,您可以使用以下命令将其作为脚本运行:
配置
为 Claude.app 配置
添加到您的 Claude 设置:
"mcpServers": {
"time": {
"command": "uvx",
"args": ["time-mcp-local"]
}
}
"mcpServers": {
"time": {
"command": "python",
"args": ["-m", "time_mcp_local"]
}
}
为 Zed 配置
添加到您的 Zed settings.json:
"context_servers": [
"mcp-server-time": {
"command": "uvx",
"args": ["time-mcp-local"]
}
],
"context_servers": {
"mcp-server-time": {
"command": "python",
"args": ["-m", "time_mcp_local"]
}
},
自定义 - 系统时区
默认情况下,服务器会自动检测您系统的时区。您可以通过在配置文件的args
列表中添加参数--local-timezone
来覆盖此设置。
例子:
{
"command": "python",
"args": ["-m", "time_mcp_local", "--local-timezone=America/New_York"]
}
交互示例
- 获取当前时间:
{
"name": "get_current_time",
"arguments": {
"timezone": "Europe/Warsaw"
}
}
回复:
{
"timezone": "Europe/Warsaw",
"datetime": "2024-01-01T13:00:00+01:00",
"is_dst": false
}
- 在时区之间转换时间:
{
"name": "convert_time",
"arguments": {
"source_timezone": "America/New_York",
"time": "16:30",
"target_timezone": "Asia/Tokyo"
}
}
回复:
{
"source": {
"timezone": "America/New_York",
"datetime": "2024-01-01T12:30:00-05:00",
"is_dst": false
},
"target": {
"timezone": "Asia/Tokyo",
"datetime": "2024-01-01T12:30:00+09:00",
"is_dst": false
},
"time_difference": "+13.0h",
}
调试
您可以使用 MCP 检查器来调试服务器。对于 uvx 安装:
npx @modelcontextprotocol/inspector uvx time-mcp-local
或者,如果您已将软件包安装在特定目录中或正在其上进行开发:
cd path/to/servers/src/time
npx @modelcontextprotocol/inspector uv run time-mcp-local
克劳德的问题示例
- “现在几点?”(将使用系统时区)
- “东京现在几点?”
- “当纽约时间下午 4 点时,伦敦时间是几点?”
- “将东京时间上午 9:30 转换为纽约时间”
建造
uv build --wheel
uv publish --token xxx