Skip to main content
Glama
gouxinjie

local-time-mcp

by gouxinjie

Local Time MCP Server (Node.js)

一个用于学习 MCP(Model Context Protocol)的入门级 Server,提供本地时间相关的工具。

npm version npm downloads license

📖 MCP 文档:


这个仓库是做什么的?

MCP(Model Context Protocol)是一种让 AI 助手调用外部工具的协议。本仓库从零实现了一个 Node.js 的 MCP Server,演示了完整的 "编写 → 发布到 npm → 配置到 AI 助手 → 实际使用" 流程,可作为学习和参考的范本。

它只提供 4 个时间相关工具:

工具

功能

示例调用

get_current_time

获取当前时间(支持时区)

"现在几点?""东京现在几点?"

format_time

格式化指定时间点

"把 2026-01-01 格式化一下"

time_diff

计算两个时间点的差值

"距离春节还有多久?"

list_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 日还有多少天?"

  • "列出所有亚洲时区"


发布到 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.md
A
license - permissive license
-
quality - not tested
B
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • A
    license
    A
    quality
    C
    maintenance
    An MCP server that allows checking local time on the client machine or current UTC time from an NTP server
    2
    34
    MIT
  • F
    license
    B
    quality
    D
    maintenance
    An MCP server that automatically detects and provides current time and location information based on system timezone and IP geolocation.
    2
  • F
    license
    -
    quality
    D
    maintenance
    A minimal MCP server that provides current time information with configurable timezone support set on the client side.
  • F
    license
    -
    quality
    C
    maintenance
    This MCP server provides the current server time through a basic resource and tool, following the MCP Apps quickstart.

View all related MCP servers

Related MCP Connectors

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/gouxinjie/local-time-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server