ZeparHyfar/mcp-datetime
简介
核心亮点
- 消除 AI 时间幻觉,提供精准的实时日期查询
- 支持多种时间格式转换,适配不同开发场景
- 简化日期计算逻辑,无需手动输入当前时间
- 即插即用,快速增强 AI 的时间感知能力
完整文档
mcp-datetime



English | 日本語
一个为 Claude Desktop Application 实现的 MCP server 日期时间格式化服务。支持生成多种格式的 datetime 字符串。
> 注意:本软件包仅在 macOS 上经过测试。Windows 兼容性尚未验证。
Prerequisites
在使用 mcp-datetime 之前,请确保已安装以下工具:
- Python 3.12 或更高版本
- uv (Python 包安装程序)
- uvx (Python 包运行器)
Features
- ✨ 支持多种 datetime 格式
- 🇯🇵 支持日语
- 📁 针对文件名生成的优化格式
- 🌏 精确的时区处理
- 🔧 与 Claude Desktop App 无缝集成
MCP Server Components
Tools
该 server 实现了以下工具:
get_datetime: 以多种格式获取当前日期和时间
format 作为必需的 string 参数
- 根据指定的格式返回格式化后的 datetime 字符串
- 支持多种格式类型,包括标准格式、日语格式和 ISO 格式
Usage with Claude Desktop App
将以下内容添加到你的配置文件中:
配置文件位置 (macOS):~/Library/Application Support/Claude/claude_desktop_config.json
{
"mcpServers": {
"mcp-datetime": {
"command": "uvx",
"args": ["mcp-datetime"]
}
}
}如果您需要直接安装该 package(例如为了进行开发或查看源代码),可以使用以下方法之一:
- 从 PyPI 安装- 从 GitHub 源码安装bash
pip install mcp-datetime- 用于手动安装的bashgit clone https://github.com/ZeparHyfar/mcp-datetime.git cd mcp-datetime pip install -e .claude_desktop_config.json示例将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"基础示例
- 命令格式- Claude Desktop App 提示词示例code
# Standard datetime format call datetime-service.get_datetime {"format": "datetime"} # Result: 2024-12-10 00:54:01# Japanese format
call datetime-service.get_datetime {"format": "datetime_jp"}
# Result: 2024年12月10日 00時54分01秒# Filename format
call datetime-service.get_datetime {"format": "filename_md"}
# Result: 20241210005401.md- 用户
- ClaudecodePlease tell me the current time in date_slash format## 支持的格式| Format Name | Example | Description |codeI'll get the current date in date_slash format.The current date is 2024/12/12
| ------------ | --------------------------- | ---------------------------- |
| date | 2024-12-10 | 标准日期格式 |
| date_slash | 2024/12/10 | 斜杠分隔日期 |
| date_jp | 2024年12月10日 | 日式日期格式 |
| datetime | 2024-12-10 00:54:01 | 标准日期时间 |
| datetime_jp | 2024年12月10日 00時54分01秒 | 日式日期时间 |
| datetime_t | 2024-12-10T00:54:01 | 带 T 分隔符的日期时间 |
| compact | 20241210005401 | 用于 ID 的紧凑格式 |
| compact_date | 20241210 | 仅紧凑日期 |
| compact_time | 005401 | 仅紧凑时间 |
| filename_md | 20241210005401.md | Markdown 文件名 |
| filename_txt | 20241210005401.txt | 文本文件名 |
| filename_log | 20241210005401.log | 日志文件名 |
| iso | 2024-12-10T00:54:01+0900 | ISO 8601 格式 |
| iso_basic | 20241210T005401+0900 | 基础 ISO 格式 |
| log | 2024-12-10 00:54:01.123456 | 带微秒的日志格式 |
| log_compact | 20241210_005401 | 紧凑日志格式 |
| time | 00:54:01 | 仅时间 |
| time_jp | 00時54分01秒 | 日式时间格式 |## 调试由于 MCP server 通过 stdio 运行,调试可能会比较困难。我们建议使用 MCP Inspector:
- 使用 PyPI package- 使用从 GitHub 下载的源代码code
npx @modelcontextprotocol/inspector uvx mcp-datetime## Licensecodegit clone https://github.com/ZeparHyfar/mcp-datetime.git npx @modelcontextprotocol/inspector uvx --directory ./mcp-datetime run mcp-datetime本项目采用 MIT License 许可 - 详见 LICENSE 文件。
- 使用 PyPI package
- 命令格式