返回市场
麦普日期时间

麦普日期时间

作者:ZeparHyfar25 星标更新:2024-12-13

项目介绍

mcp-datetime

Python 版本 MCP 版本 许可证

English | 日本語

一个作为MCP服务器实现的日期时间格式化服务,用于Claude桌面应用程序。支持生成多种格式的日期时间字符串。

注意:此包仅在macOS上进行了测试。尚未验证Windows兼容性。

使用前提

在使用mcp-datetime之前,请确保已安装以下工具:

  • Python 3.12或更高版本
  • uv(Python包安装器)
  • uvx(Python包运行器)

功能

  • ✨ 支持多种日期时间格式
  • 🇯🇵 日语支持
  • 📁 优化的文件名生成格式
  • 🌏 准确的时区处理
  • 🔧 与Claude桌面应用无缝集成

MCP服务器组件

工具

服务器实现了一个工具:

  • get_datetime:获取当前日期和时间的各种格式
    • 接受“format”作为必需的字符串参数
    • 根据指定的格式返回格式化的日期时间字符串
    • 支持多种格式类型,包括标准、日语和ISO格式

与Claude桌面应用一起使用

在您的配置文件中添加以下内容:

配置文件位置(macOS): ~/Library/Application Support/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "mcp-datetime": {
      "command": "uvx",
      "args": ["mcp-datetime"]
    }
  }
}

关于安装

如果您需要直接安装该包(例如,用于开发或源代码检查),可以使用以下方法之一:

  • 从PyPI安装

    pip install mcp-datetime
    
  • 从GitHub源码安装

    git clone https://github.com/ZeparHyfar/mcp-datetime.git
    cd mcp-datetime
    pip install -e .
    
  • 手动安装示例claude_desktop_config.json

    {
      "mcpServers": {
        "mcp-datetime": {
          "command": "python",
          "args": ["-m", "mcp_datetime"],
          "env": {
            "PYTHON": "/path/to/your/python"
          }
        }
      }
    }
    

    将"/path/to/your/python"替换为您实际的Python解释器路径

    例如,“/usr/local/bin/python3”或“/Users/username/.pyenv/versions/3.12.0/bin/python3”

基本示例

  • 命令格式

    # 标准日期时间格式
    call datetime-service.get_datetime {"format": "datetime"}
    # 结果:2024-12-10 00:54:01
    
    # 日语格式
    call datetime-service.get_datetime {"format": "datetime_jp"}
    # 结果:2024年12月10日 00时54分01秒
    
    # 文件名格式
    call datetime-service.get_datetime {"format": "filename_md"}
    # 结果:20241210005401.md
    
  • Claude桌面应用提示示例

    • 用户

      请告诉我当前时间的date_slash格式
      
    • Claude

      我会获取当前日期的date_slash格式。
      
      当前日期是2024/12/12
      

支持的格式

格式名称示例描述
date2024-12-10标准日期格式
date_slash2024/12/10带斜杠的日期格式
date_jp2024年12月10日日语日期格式
datetime2024-12-10 00:54:01标准日期时间
datetime_jp2024年12月10日 00时54分01秒日语日期时间
datetime_t2024-12-10T00:54:01带T分隔符的日期时间
compact20241210005401紧凑格式用于ID
compact_date20241210仅紧凑日期
compact_time005401仅紧凑时间
filename_md20241210005401.mdMarkdown文件名
filename_txt20241210005401.txt文本文件名
filename_log20241210005401.log日志文件名
iso2024-12-10T00:54:01+0900ISO 8601格式
iso_basic20241210T005401+0900基础ISO格式
log2024-12-10 00:54:01.123456带微秒的日志格式
log_compact20241210_005401紧凑日志格式
time00:54:01仅时间
time_jp00时54分01秒日语时间格式

调试

由于MCP服务器通过stdio运行,调试可能会很困难。我们推荐使用MCP Inspector

  • 使用PyPI包

    npx @modelcontextprotocol/inspector uvx mcp-datetime
    
  • 使用从GitHub下载的源代码

    git clone https://github.com/ZeparHyfar/mcp-datetime.git
    npx @modelcontextprotocol/inspector uvx --directory ./mcp-datetime run mcp-datetime
    

许可证

本项目根据MIT许可证授权 - 查看LICENSE文件以获取详细信息。