Back to MCP directory
publicPublicdnsLocal runtime

TimeMCP

一个基于MCP协议的时间服务工具,提供当前时间查询和时区转换功能。

article

README

🚀 时间MCP

时间MCP是一个简单的模型控制协议(MCP)服务器,它提供了时间和时区转换工具,能帮助用户轻松获取特定时区的时间,以及在不同时区之间进行时间转换。

🚀 快速开始

构建

go build -o ./bin/mcp-time .

添加到 claude_desktop_config.json

{
    "mcpServers": {
        "time": {
            "command": "/Path/To/Your/Bin/mcp-time"
        }
    }
}

使用与 MCP 兼容的客户端

该服务器实现了模型控制协议,这意味着它可以与任何MCP兼容的客户端一起使用。客户端将能够:

  1. 发现可用工具
  2. 调用具有适当参数的工具
  3. 收到格式化的响应

✨ 主要特性

该服务器提供的工具有:

1. get_current_time

获取特定时区或系统时区的当前时间。 参数:

  • timezone (字符串,可选):要获取当前时间的时区。如果未提供,默认使用系统时区。 示例响应:
当前时间为 Europe/Warsaw: 2025-04-09 15:30:45

2. convert_time

在不同时区之间转换时间。 参数:

  • source_timezone (字符串,可选):源时区。如果未提供,默认使用系统时区。
  • time (字符串,可选):24小时格式的时间(HH:MM)。如果未提供,默认使用当前时间。
  • target_timezone (字符串,必需):要转换到的目标时区。 示例响应:
时间转换:15:30 在 Europe/Warsaw → 09:30 在 America/New_York

💻 使用示例

基础用法

获取东京当前时间

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "get_current_time",
    "arguments": {
      "timezone": "Asia/Tokyo"
    }
  }
}

转换时间

{
  "jsonrpc": "2.0",
  "id": 2,
  "method": "tools/call",
  "params": {
    "name": "convert_time",
    "arguments": {
      "source_timezone": "Europe/Warsaw",
      "time": "15:30",
      "target_timezone": "America/New_York"
    }
  }
}

🔧 技术细节

依赖项

  • github.com/mark3labs/mcp-go:模型控制协议的实现
  • github.com/araddon/dateparse:灵活的日期解析库

支持的时区

该服务器支持所有 IANA 时区数据库条目,例如:

  • Europe/Warsaw
  • America/New_York
  • Asia/Tokyo
  • Australia/Sydney
  • Africa/Cairo
  • 等等。
help

Runtime guide

cloud

Hosted runtime

Hosted servers run from a provider-managed environment. You usually connect the MCP client to the hosted endpoint or follow the provider's authorization flow, without keeping a local process alive

  1. Open provider connection page
  2. Authorize or copy endpoint
  3. Connect from your MCP client
terminal

Local runtime / other methods

Local servers run on your own machine or infrastructure. You normally copy the server_config into your MCP client, install the required package, and provide env variables from env_schema when needed

  1. Copy server_config
  2. Install required package
  3. Fill env variables and restart client