MCP 日期时间
模型上下文协议 (MCP) 服务器的 TypeScript 实现,为代理系统和聊天 REPL 提供日期时间和时区信息。
概述
MCP DateTime 是一个简单的服务器,它实现了模型上下文协议 (MCP Protocol) ,用于向 AI 代理和聊天界面提供日期时间和时区信息。它允许 AI 系统:
- 获取本地系统时区的当前时间
- 获取任何有效时区的当前时间
- 列出所有可用的时区
- 通过 URI 资源访问时区信息
安装
来自 npm
从源头
用法
命令行
MCP DateTime 可以以两种模式运行:
1. 标准I/O模式(默认)
此模式非常适合通过标准输入/输出与支持 MCP 协议的 AI 系统集成:
2. 服务器发送事件(SSE)模式
此模式启动一个为 MCP 协议提供 SSE 传输的 HTTP 服务器:
您还可以指定自定义端口和 URI 前缀:
环境变量
PORT
:设置 SSE 模式的端口(默认值:3000)URI_PREFIX
:设置 SSE 模式的 URI 前缀(默认值:无)
可用工具
MCP DateTime 提供以下工具:
get-current-time
返回系统本地时区的当前时间。
get-current-timezone
返回当前系统时区。
get-time-in-timezone
返回指定时区的当前时间。
参数:
timezone
:获取当前时间的时区(例如“America/New_York”)
list-timezones
返回所有可用时区的列表。
资源 URI
MCP DateTime 还通过资源 URI 提供对时区信息的访问:
datetime://{timezone}
返回指定时区的当前时间。
例如: datetime://America/New_York
datetime://list
返回所有可用时区的列表。
常见时区
以下常见时区始终可用:
- 世界标准时间
- 欧洲/伦敦
- 欧洲/巴黎
- 欧洲/柏林
- 美国/纽约
- 美国/芝加哥
- 美国/丹佛
- 美国/洛杉矶
- 亚洲/东京
- 亚洲/上海
- 亚洲/加尔各答
- 澳大利亚/悉尼
- 太平洋/奥克兰
SSE 终端节点
在 SSE 模式下运行时,以下端点可用:
/sse
:SSE 连接端点/message
:客户端到服务器通信的消息端点/info
:基本服务器信息
如果指定了 URI 前缀,它将被添加到所有端点的前面。
与人工智能系统集成
MCP DateTime 可以与支持模型上下文协议 (MCP Protocol) 的 AI 系统集成。这使得 AI 代理能够访问准确的时区和日期时间信息。
发展
先决条件
- Node.js 14.16 或更高版本
- npm
设置
建造
以开发模式运行
执照
该项目根据 Mozilla 公共许可证 2.0 获得许可 - 有关详细信息,请参阅LICENSE文件。
You must be authenticated.
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.
实现模型上下文协议 (MCP) 的 TypeScript 服务器,为 AI 代理和聊天界面提供日期时间和时区信息,使它们能够访问各个时区的当前时间。
Related Resources
Related MCP Servers
- AsecurityAlicenseAqualityA TypeScript-based server that allows calling other MCP clients from your own MCP client, facilitating task delegation and context window offloading for enhanced multi-agent interactions.Last updated -314JavaScriptMIT License
- -securityFlicense-qualityA Claude Model Configuration Protocol (MCP) server that provides real-time timezone-aware date and time information.Last updated -Python
- -securityFlicense-qualityA TypeScript framework for building Model Context Protocol (MCP) servers with automatic discovery and loading of tools, resources, and prompts.Last updated -67TypeScript
- -securityFlicense-qualityA simple TypeScript library for creating Model Context Protocol (MCP) servers with features like type safety, parameter validation, and a minimal code API.Last updated -1TypeScriptMIT License