时间转换工具

MCP时间服务器是一个简单的时间及时区转换工具,支持获取当前时间和时区转换功能。

  • by r0mdau
  • Go
  • 本地部署
  • 更新于
在 GitHub 查看 r0mdau/mcp-time

使用说明

MCP时间服务器

用于时间和时区转换的简单MCP工具。

基于Anthropic的Python MCP时间服务器 模型上下文协议/服务器.

项目结构

此项目遵循标准Go项目布局:

mcp-time/
├── cmd/mcp-time/        # Application entry point
├── internal/
│   ├── types/           # Shared type definitions
│   ├── handlers/        # MCP tool handlers
│   ├── timezone/        # Timezone operations
│   └── timeutil/        # Time utility functions
├── build/               # Compiled binaries
└── docs/                # Documentation

包含的工具

  • get_current_time:返回给定IANA时区的当前时间(默认UTC)
  • convert_time:以HH:MM格式转换时区之间的时间

Github Copilot中的提示使用示例:

  • Get the current time in New York using the MCP Time Server tool.
  • Convert 14:30 from London time to Tokyo time using the MCP Time Server tool.

发展

构建并运行

  1. 构建二进制文件:

    make build
    
  2. 运行服务器:

    make run
    
  3. 默认情况下,MCP服务器侦听端口8080。

命令行选项

  • --local-timezone:覆盖本地时区(例如,“美国/纽约”)
  • --port:要监听的端口(默认值:8080)

测试

运行测试套件:

make test

目标是在所有内部包中实现>80%的测试覆盖率。

开发工作流程

看 代理商.md 详细的开发指南和测试说明。