这是一个用于获取当前时间ISO格式(YYYY-MM-DD HH:mm:ss)的MCP服务器,借助JavaScript Date实现。该服务器适用于Claude桌面应用程序,可在Windows和macOS系统上运行。
本项目提供了便捷的时间获取和时间差计算功能,以下是简单的使用说明:
npm install @dandelion/mcp-time
config.json中添加配置:{
"modules": {
"time": {
"url": "http://localhost:3000",
"type": "mcp"
}
}
}
使用以下命令安装本项目:
npm install @dandelion/mcp-time
getCurrentTime该工具用于返回当前时间的ISO格式,无需输入参数。 示例JSON-RPC请求:
{
"jsonrpc": "2.0",
"id": 1,
"method": "getCurrentTime"
}
示例JSON-RPC响应:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"time": "2024-02-08 11:04:33",
"success": true
}
}
getTimeDifference该工具用于计算给定时间戳与当前时间之间的差异。 示例JSON-RPC请求:
{
"jsonrpc": "2.0",
"id": 1,
"method": "getTimeDifference",
"params": {
"timestamp": "2024-02-08 12:30:00",
"interval": "minutes"
}
}
示例JSON-RPC响应:
// 对于过去时间戳(30分钟前)
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"difference": -30,
"interval": "minutes",
"inputTimestamp": "2024-02-08 12:30:00",
"currentTime": "2024-02-08 13:00:00"
}
}
// 对于未来时间戳(在45分钟后)
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"difference": 45,
"interval": "minutes",
"inputTimestamp": "2024-02-08 12:30:00",
"currentTime": "2024-02-08 13:15:00"
}
}
getCurrentTime
{
"time": "2024-02-08 11:04:33",
"success": true
}
getTimeDifference
timestamp:ISO格式时间戳(YYYY-MM-DD HH:mm:ss)。interval:'分钟'(默认)或 '秒'。在config.json中添加以下内容:
{
"modules": {
"time": {
"url": "http://localhost:3000",
"type": "mcp"
}
}
}
git clone https://github.com/your-username/dandelion.git
cd dandelion/packages/mcp-time
npm install
npm test
npm start
此项目受MIT许可证保护。