使用说明
mcp日期时间
英语| 日本语
作为Claude桌面应用程序的MCP服务器实现的日期时间格式化服务。支持生成各种格式的日期时间字符串。
备注:此软件包仅在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/pytthon3”
基本示例
-
命令格式
# 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 -
Claude桌面应用程序提示示例
-
用户
Please tell me the current time in date_slash format -
克劳德
I'll get the current date in date_slash format. The current date is 2024/12/12
-
支持格式
| 格式名称 | 示例 | 描述 |
|---|---|---|
| 日期 | 2024-12-10 | 标准日期格式 |
| date_slash | 2024/12/10 | 带斜线的日期 |
| 日期:2024年年12月10日 | 日语日期格式 | |
| 日期时间 | 2024-12-10 00:54:01 | 标准日期时间 |
| datetime_jp | 2024年12月10日00时54分01秒 | Japanese datetime |
| datetime_t | 2024-12-10T00:54:01 | 带t分隔符的日期时间 |
| 紧凑 | 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基本格式 | 20241210T005401+0900 | |
| 日志 | 2024-12-10 00:54:01.123456 | 微秒日志格式 |
| log_compact | 20241210_005401 | 紧凑日志格式 |
| 时间 | 00:54:01 | 仅限时间 |
| 时间_ jp | 00時54分01秒 | 日本时间格式 |
调试
由于MCP服务器在stdio上运行,调试可能具有挑战性。我们建议使用 MCP检查员:
-
使用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许可证获得许可-请参阅 许可证 文件以获取详细信息。