mcp-datetime
用于日期时间格式化和文件名生成的MCP Server。
简介
mcp-datetime
是一个为 Claude 桌面应用提供的日期时间格式化服务,以 MCP 服务器形式实现,支持多种日期时间格式。
安装前提
- Python 3.12+
- uv (Python 包安装器)
- uvx (Python 包运行器)
快速安装
pip install mcp-datetime
配置 Claude 桌面应用
编辑配置文件 ~/Library/Application Support/Claude/claude_desktop_config.json
:
{
"mcpServers": {
"mcp-datetime": {
"command": "uvx",
"args": ["mcp-datetime"]
}
}
}
使用示例
在 Claude 桌面应用中:
# 标准日期时间格式
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
常用格式示例
格式名称 | 示例 | 描述 |
---|---|---|
date | 2024-12-10 | 标准日期格式 |
datetime | 2024-12-10 00:54:01 | 标准日期时间 |
date_jp | 2024年12月10日 | 日语日期格式 |
compact | 20241210005401 | 用于 ID 的紧凑格式 |
iso | 2024-12-10T00:54:01+0900 | ISO 8601 格式 |
filename_md | 20241210005401.md | Markdown 文件名 |
调试
使用 MCP Inspector 进行调试:
npx @modelcontextprotocol/inspector uvx mcp-datetime
许可证
MIT