](https://github.com/TheoBrigitte/mcp-time/releases)    ](https://www.npmjs.com/package/@theo.foobar/mcp-time) ](https://hub.docker.com/r/theo01/mcp-time)
时间MCP服务器
*模型上下文协议服务器,使AI助手能够与时间交互*
托管部署
托管部署可在 Frontier AI.
概述
时间MCP服务器是 模型上下文协议(MCP) 该服务器为AI助手和其他MCP客户端提供标准化的工具,以执行与时间和日期相关的操作。该服务器充当人工智能工具和强大的时间处理后端之间的桥梁,允许通过自然语言交互进行复杂的时间操作。
特性
- ⏰ 时间操纵 -获取当前时间,在时区之间进行转换,并添加或减去持续时间
- 🗣️ 自然语言解析 -理解相对时间表达式,如“昨天”或“下个月”
- ⚖️ 时间比较 -轻松比较两个不同的时间
- 🎨 灵活的格式 -支持多种预定义和自定义时间格式
- ✅ MCP合规性 -与模型上下文协议标准完全兼容
- 🔄 多个传输 -支持
stdio用于本地集成和HTTP stream用于网络访问
安装
🚀 一键安装(光标)
点击下面的按钮,在您的应用程序中使用Docker自动配置MCP服务器 光标 环境:
使用npx(JavaScript/Node.js)
此方法使用以下命令运行MCP服务器 npx,这需要安装Node.js。将以下JSON配置复制到MCP客户端设置中:
{
"mcpServers": {
"mcp-time": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"@theo.foobar/mcp-time"
]
}
}
}使用Docker
在隔离容器中运行MCP服务器。需要 码头工人 待安装。将此JSON配置复制到MCP客户端设置中:
{
"mcpServers": {
"mcp-time": {
"type": "stdio",
"command": "docker",
"args": [
"run",
"--rm",
"-i",
"theo01/mcp-time:latest"
]
}
}
}使用二进制
安装 mcp-time 二进制直接在您的系统上。选择以下安装方法之一,确保二进制文件放置在您的 PATH。然后将此JSON配置添加到MCP客户端设置中:
{
"mcpServers": {
"mcp-time": {
"type": "stdio",
"command": "mcp-time"
}
}
}选项1:从版本下载
从下载最新的预构建二进制文件 发布页面:
# Replace OS-ARCH with your platform (e.g., linux-amd64, darwin-arm64, windows-amd64)
curl -Lo mcp-time https://github.com/TheoBrigitte/mcp-time/releases/latest/download/mcp-time.OS-ARCH
install -D -m 755 ./mcp-time ~/.local/bin/mcp-time选项2:使用Go安装
对于Go开发人员,直接使用 go install:
go install github.com/TheoBrigitte/mcp-time/cmd/mcp-time@latest二进制文件将安装在您的 $GOPATH/bin 目录。
选项3:从源代码构建
使用克隆和构建项目 make:
git clone https://github.com/TheoBrigitte/mcp-time.git
cd mcp-time
make install二进制文件将安装在 ~/.local/bin/mcp-time.
用法
基本用法
从stdio传输开始 (默认值,适用于MCP客户端):
mcp-time从HTTP流传输开始 (用于网络访问):
mcp-time --transport stream --address "http://localhost:8080/mcp"命令行选项
服务器支持以下高级配置标志:
$ mcp-time --help
An MCP (Model Context Protocol) server which provides utilities to work with time and dates.
Usage:
mcp-time [flags]
Flags:
--address string Listen address for Stream HTTP Server (only for --transport stream) (default "http://localhost:8080/mcp")
-h, --help help for mcp-time
--log-file string Path to log file (logs is disabled if not specified)
-t, --transport string Transport layer: stdio, stream. (default "stdio")
--version Print version information and exit可用工具
current_time
获取任何时区和格式的当前时间。
参数:
format(可选)-输出格式(预定义为RFC3339,Kitchen,或自定义Go布局)timezone(可选)-IANA格式的目标时区(例如。,America/New_York).默认为UTC
例子: “东京现在几点了?”
relative_time
根据相对的自然语言表达式获取时间。
参数:
text(必填)-自然语言表达(例如。,yesterday,5 minutes ago,next month)time(可选)-表达式的参考时间。默认为当前时间timezone(可选)-输出的目标时区format(可选)-时间的输出格式
例子: “三周前的日期是什么?”
convert_timezone
在时区之间转换给定时间。
参数:
time(必填)-输入时间字符串(支持多种格式)input_timezone(可选)-输入时间的时区output_timezone(可选)-输出的目标时区format(可选)-时间的输出格式
例子: “将美国东部时间下午2:30转换为东京时间”
add_time
从给定时间中添加或减去持续时间。
参数:
time(必填)-输入时间字符串duration(必填)-加/减的持续时间(例如。,2h30m,-1h,24h)timezone(可选)-输出的目标时区format(可选)-时间的输出格式
例子: “45分钟后几点?”
compare_time
比较两次,确定它们的关系。支持时区感知比较。
参数:
time_a(必填)-第一次比较time_a_timezone(可选)-时区time_a以IANA格式(例如。,America/New_York)time_b(必填)-第二次比较time_b_timezone(可选)-时区time_b以IANA格式(例如。,Europe/London)
退货:
-1如果time_a在之前time_b0如果time_a等于time_b1如果time_a在...之后time_b
例子: “美国东部时间下午3点是格林尼治标准时间晚上8点之前吗?”
贡献
欢迎投稿!请随时提交拉取请求。对于重大更改,请先打开一个问题来讨论您想要更改的内容。
许可证
此项目根据MIT许可证获得许可-请参阅 许可证 文件以获取详细信息。
学分
使用这些优秀的库构建:
- araddon/dateparse -在不知道格式的情况下分析日期
- tj/go自然日期 -自然语言数据解析
- mark3labs/mcp go -Go的模型上下文协议SDK
