local-time-mcp
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@local-time-mcpWhat's the current time in New York?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Local Time MCP Server (Node.js)
一个用于学习 MCP(Model Context Protocol)的入门级 Server,提供本地时间相关的工具。
📖 MCP 文档:
mcp核心概念.md —— MCP 是什么
mcp端到端流程.md —— MCP 完整流程
mcp从零编写到发布上线.md —— 从零编写 → 发布 npm → 使用的完整实战
这个仓库是做什么的?
MCP(Model Context Protocol)是一种让 AI 助手调用外部工具的协议。本仓库从零实现了一个 Node.js 的 MCP Server,演示了完整的 "编写 → 发布到 npm → 配置到 AI 助手 → 实际使用" 流程,可作为学习和参考的范本。
它提供 8 个时间相关工具(Tools):
工具 | 功能 | 示例调用 |
| 获取当前时间(支持时区) | "现在几点?""东京现在几点?" |
| 格式化指定时间点 | "把 2026-01-01 格式化一下" |
| 计算两个时间点的差值 | "距离春节还有多久?" |
| 列出可用时区 | "有哪些亚洲时区?" |
| 把一个时区的墙钟时间换算成另一时区 | "北京时间 2026-01-01 中午 12 点是纽约几点?" |
| Unix 时间戳 → 可读时间(秒/毫秒自动识别) | "时间戳 1767225600 是什么时间?" |
| ISO 时间 → Unix 时间戳 | "把 2026-01-01 08:00+08:00 转成时间戳" |
| 查询时区的偏移与夏令时状态 | "纽约现在是否夏令时?" |
除 Tools 外,还演示了 MCP 的另外两种能力:
Resource:
local-time://now—— 只读资源,每次读取即时返回服务器当前时间;Prompt:
compare_timezones—— 可复用提示词模板,生成"对比多个城市当前时间"的指令。
已发布到 npm:local-time-mcp-server(需 Node.js 18+)。
Related MCP server: Time & Location MCP Server
怎么使用
方式一:配置到 AI 助手(WorkBuddy / CodeBuddy)—— 最推荐
编辑 MCP 配置文件 ~/.workbuddy/mcp.json(不存在则新建),通过 npx 一键运行,无需克隆仓库:
{
"mcpServers": {
"local-time": {
"type": "stdio",
"command": "npx",
"args": ["local-time-mcp-server@latest"]
}
}
}配置完成后,在 AI 助手的连接器管理页面找到 local-time 并点击 Trust(信任),即可在对话中使用。
方式二:npx 一键运行(推荐,无需克隆仓库)
npx local-time-mcp-server@latest或全局安装:
npm install -g local-time-mcp-server
local-time-mcp-server安装之后:
local-time-mcp-server是一个 stdio 类型的 MCP Server,直接运行时会挂起等待标准输入(它本身不提供交互界面)。它的作用是作为子进程被 AI 客户端启动,所以安装后下一步是把它配置到 AI 助手(见下方"方式一"),然后在对话中就能调用时间工具了。
试试看
在 AI 助手中直接问:
"现在本地几点了?"
"纽约现在几点?"
"距离 2026 年 12 月 31 日还有多少天?"
"列出所有亚洲时区"
"北京时间 2026 年 1 月 1 日中午 12 点是纽约几点?"
"纽约时区现在有没有在实行夏令时?"
发布到 npm
本仓库已配置 CI/CD 自动发布:打一个 v* 版本 tag 并推送,即自动测试、改版本号并发布到 npm。
git add . && git commit -m "改动" && git push
git tag v1.0.5 && git push origin v1.0.5详细的发布步骤、2FA 处理、跨平台修复、CI/CD 配置等,见 mcp从零编写到发布上线.md。
项目结构
local-time-mcp/
├── server.js # MCP Server 主程序(npm bin 入口)
├── test_server.js # 工具逻辑测试脚本
├── package.json # 依赖与发布配置(bin/files/engines)
├── mcp_config_example.json # MCP 配置示例
├── .github/workflows/ # CI/CD(测试 + 自动发布)
├── docs/ # MCP 概念与实战文档
├── .gitignore
└── README.mdThis server cannot be deployed
Maintenance
Related MCP Connectors
Related MCP Servers
- AlicenseAqualityCmaintenanceAn MCP server that allows checking local time on the client machine or current UTC time from an NTP server234MIT
- FlicenseBqualityDmaintenanceAn MCP server that automatically detects and provides current time and location information based on system timezone and IP geolocation.2-
- FlicenseNot gradedqualityDmaintenanceA minimal MCP server that provides current time information with configurable timezone support set on the client side.-
- FlicenseNot gradedqualityDmaintenanceThis MCP server provides the current server time through a basic resource and tool, following the MCP Apps quickstart.-