Integrations
Supports containerized deployment with Docker, allowing the time server to run in isolated containers with proper port mapping.
Provides tools for time-related queries including getting the current time in various IANA timezones and converting times between timezones.
Offers timezone conversion functionality and current time retrieval across different IANA timezones through a TypeScript implementation.
MCP 时间服务器 ( mcp-time-srv
)
用 TypeScript 实现的简单模型上下文协议 (MCP) 服务器,提供与时间相关的查询工具,包括获取各个时区的当前时间以及在时区之间转换时间。
该服务器支持现代 Streamable HTTP 和传统 HTTP+SSE MCP 传输协议。
特征
提供以下 MCP 工具:
get_current_time
:返回指定 IANA 时区的当前时间。convert_time
:将给定时间从源 IANA 时区转换为目标 IANA 时区。
先决条件
设置
- 克隆存储库(如果还没有):Copy
- 安装依赖项:Copy
本地运行
- 构建 TypeScript 代码:这会将Copy
src/
中的 TypeScript 源编译为dist/
中的 JavaScript。 - **运行服务器:**您可以使用
ts-node
(用于开发)运行服务器,或者在构建后直接使用node
运行服务器。- 使用
ts-node
:Copy - 使用
node
(构建后):Copy
- 使用
服务器将启动,通常监听端口 3000。
使用 Docker 运行(可选)
提供了Dockerfile
用于在容器中构建和运行服务器。
- 构建 Docker 镜像:Copy
- 运行容器:Copy
-d
:以分离模式运行(在后台)。-p 3000:3000
:将主机上的端口 3000 映射到容器中的端口 3000。--name my-mcp-server
:为容器分配一个名称,以便于管理。
服务器将在容器内运行,可通过http://localhost:3000
访问。
要停止容器:
查看日志:
与客户端一起测试
包含一个简单的测试客户端脚本( src/client.ts
)来演示与服务器工具的交互。
- 确保服务器正在运行(本地或在 Docker 中)。
- 运行客户端:Copy
客户端将连接到服务器(默认使用 SSE 传输),列出可用的工具,使用示例参数调用每个工具(包括一些用于测试错误处理的参数),并打印结果。
工具详细信息
get_current_time
返回指定时区的当前时间。
- 输入参数:
timezone
(字符串,可选):IANA 时区名称 (例如,America/New_York
、Europe/London
)。如果省略,则默认为服务器本地时区。
- **输出:**一个 JSON 对象,包含以下内容:
timezone
(字符串):使用的有效时区。datetime
(字符串):带有偏移量的 ISO 8601 格式的当前时间(例如,2025-04-26T01:39:15Z
)。
convert_time
将时间从源时区转换为目标时区。
- 输入参数:
source_timezone
(字符串,可选):源 IANA 时区名称。如果省略,则默认为服务器本地时区。time
(字符串,必需):以 24 小时 HH:MM 格式转换的时间(例如14:30
)。target_timezone
(字符串,可选):目标 IANA 时区名称。如果省略,则默认为服务器本地时区。
- **输出:**一个 JSON 对象,包含以下内容:
source
(对象):源时区中的时间详细信息(timezone
,datetime
)。target
(对象):目标时区(timezone
,datetime
)中转换时间的详细信息。time_difference
(字符串):目标时区和源时区偏移之间的差异(例如+8h
、-5h
、+5.75h
)。
执照
该项目根据 MIT 许可证获得许可 - 有关详细信息,请参阅LICENSE文件。
This server cannot be installed
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
一个 TypeScript 服务器,通过模型上下文协议提供与时间相关的工具,允许用户获取各个时区的当前时间并在不同的 IANA 时区之间转换时间。
Related MCP Servers
- AsecurityAlicenseAqualityA production-ready template for creating Model Context Protocol servers with TypeScript, providing tools for efficient testing, development, and deployment.Last updated -11512JavaScriptMIT License
- AsecurityAlicenseAqualityA Model Context Protocol server that extracts embedded data (such as i18n translations or key/value configurations) from TypeScript/JavaScript source code into structured JSON configuration files.Last updated -2142JavaScriptMIT License
- AsecurityAlicenseAqualityA TypeScript server implementing the Model Context Protocol (MCP) that provides datetime and timezone information to AI agents and chat interfaces, allowing them to access current time in various timezones.Last updated -42TypeScriptMozilla Public License 2.0
- AsecurityFlicenseAqualityA Model Context Protocol server that provides time and timezone conversion capabilities, enabling LLMs to get current time information and perform timezone conversions using IANA timezone names.Last updated -21Python