MCP时间服务器(Node.js)
Node.js中非常简单的HTTP服务器,返回机器的本地时间。
终点:
- GET/time->devuelve JSON:{“time”:“本地字符串”,“iso”:“ISO8601 UTC”,“epoch_ms”:1234567890123}
- GET/->幂等a/time
要求:
- Node.js 12+(建议使用Node 18+)。没有外部依赖。
安装和使用(Windows上的git bash/wsl/bash.exe):
在项目文件夹中打开终端:
cd \"c:/Users/Flia. Mosquera/Documents/python/mcp_time_server\"运行服务器:
npm start
# o directamente
node index.js从另一个终端测试:
curl http://127.0.0.1:8000/time使用包括的客户:
node client.js
# o con URL personalizada
node client.js http://127.0.0.1:8000/time停止服务器:
- 前景:Ctrl+C
- 如果你用经理或后台启动它,它会杀死适当的PID。
注释 :
time是带有时区的本地表示,iso是UTC和epoch_ms这是自时代以来的毫秒。- 如果您想要HTTPS或身份验证,我可以添加它。
