@guanxiong/mcp-server-time 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +279 -0
- package/index.js +199 -0
- package/package.json +43 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
# MCP Server Time
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@guanxiong/mcp-server-time)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
[](https://nodejs.org/)
|
|
6
|
+
|
|
7
|
+
一个简单易用的 Model Context Protocol (MCP) 时间服务器,用于在 Cursor、Claude Desktop 等支持 MCP 的应用中方便地获取当前时间信息。
|
|
8
|
+
|
|
9
|
+
## ✨ 功能特性
|
|
10
|
+
|
|
11
|
+
- ✅ **获取当前时间** - 支持多种格式(ISO、本地格式、时间戳)
|
|
12
|
+
- ✅ **时区支持** - 支持所有 IANA 时区标识符
|
|
13
|
+
- ✅ **详细信息** - 获取年、月、日、时、分、秒、星期等详细信息
|
|
14
|
+
- ✅ **轻量级** - 零配置,开箱即用
|
|
15
|
+
- ✅ **跨平台** - 支持 Windows、macOS、Linux
|
|
16
|
+
|
|
17
|
+
## 📦 安装
|
|
18
|
+
|
|
19
|
+
### 方式一:使用 npx(推荐)
|
|
20
|
+
|
|
21
|
+
无需安装,直接使用:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# 在 MCP 配置中使用
|
|
25
|
+
npx -y @guanxiong/mcp-server-time
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### 方式二:全局安装
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npm install -g @guanxiong/mcp-server-time
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### 方式三:本地安装
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
npm install @guanxiong/mcp-server-time
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## 🚀 快速开始
|
|
41
|
+
|
|
42
|
+
### 配置 Cursor
|
|
43
|
+
|
|
44
|
+
编辑 `~/.cursor/mcp.json`(Windows: `C:\Users\<用户名>\.cursor\mcp.json`),添加以下配置:
|
|
45
|
+
|
|
46
|
+
```json
|
|
47
|
+
{
|
|
48
|
+
"mcpServers": {
|
|
49
|
+
"time-server": {
|
|
50
|
+
"command": "npx",
|
|
51
|
+
"args": [
|
|
52
|
+
"-y",
|
|
53
|
+
"@guanxiong/mcp-server-time"
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### 配置 Claude Desktop
|
|
61
|
+
|
|
62
|
+
编辑 `~/Library/Application Support/Claude/claude_desktop_config.json`(macOS)或 `%APPDATA%\Claude\claude_desktop_config.json`(Windows),添加:
|
|
63
|
+
|
|
64
|
+
```json
|
|
65
|
+
{
|
|
66
|
+
"mcpServers": {
|
|
67
|
+
"time-server": {
|
|
68
|
+
"command": "npx",
|
|
69
|
+
"args": [
|
|
70
|
+
"-y",
|
|
71
|
+
"@guanxiong/mcp-server-time"
|
|
72
|
+
]
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### 重启应用
|
|
79
|
+
|
|
80
|
+
配置完成后,重启 Cursor 或 Claude Desktop 使配置生效。
|
|
81
|
+
|
|
82
|
+
## 🛠️ 可用工具
|
|
83
|
+
|
|
84
|
+
### 1. get_current_time
|
|
85
|
+
|
|
86
|
+
获取当前日期和时间。
|
|
87
|
+
|
|
88
|
+
**参数**:
|
|
89
|
+
- `timezone` (可选): 时区标识符,例如 `Asia/Shanghai`、`UTC`、`America/New_York`
|
|
90
|
+
- `format` (可选): 时间格式
|
|
91
|
+
- `iso`: ISO 8601 格式(默认)
|
|
92
|
+
- `locale`: 本地化格式
|
|
93
|
+
- `timestamp`: Unix 时间戳(毫秒)
|
|
94
|
+
|
|
95
|
+
**示例**:
|
|
96
|
+
```
|
|
97
|
+
用户:现在几点了?
|
|
98
|
+
AI:调用 get_current_time → 返回当前时间
|
|
99
|
+
|
|
100
|
+
用户:北京时间现在几点?
|
|
101
|
+
AI:调用 get_current_time,参数 timezone: "Asia/Shanghai"
|
|
102
|
+
|
|
103
|
+
用户:获取 UTC 时间戳
|
|
104
|
+
AI:调用 get_current_time,参数 format: "timestamp"
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### 2. get_time_info
|
|
108
|
+
|
|
109
|
+
获取详细的时间信息,包括年、月、日、时、分、秒、星期等。
|
|
110
|
+
|
|
111
|
+
**参数**:
|
|
112
|
+
- `timezone` (可选): 时区标识符
|
|
113
|
+
|
|
114
|
+
**返回信息**:
|
|
115
|
+
- `year`: 年份
|
|
116
|
+
- `month`: 月份(1-12)
|
|
117
|
+
- `day`: 日期(1-31)
|
|
118
|
+
- `hour`: 小时(0-23)
|
|
119
|
+
- `minute`: 分钟(0-59)
|
|
120
|
+
- `second`: 秒(0-59)
|
|
121
|
+
- `weekday`: 星期几
|
|
122
|
+
- `timezone`: 时区
|
|
123
|
+
|
|
124
|
+
**示例**:
|
|
125
|
+
```
|
|
126
|
+
用户:今天是几号?星期几?
|
|
127
|
+
AI:调用 get_time_info → 返回详细信息
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## 🌍 支持的时区
|
|
131
|
+
|
|
132
|
+
可以使用任何有效的 [IANA 时区标识符](https://www.iana.org/time-zones),例如:
|
|
133
|
+
|
|
134
|
+
| 时区 | 标识符 | UTC 偏移 |
|
|
135
|
+
|------|--------|----------|
|
|
136
|
+
| 中国标准时间 | `Asia/Shanghai` | UTC+8 |
|
|
137
|
+
| 协调世界时 | `UTC` | UTC+0 |
|
|
138
|
+
| 美国东部时间 | `America/New_York` | UTC-5/-4 |
|
|
139
|
+
| 美国西部时间 | `America/Los_Angeles` | UTC-8/-7 |
|
|
140
|
+
| 英国时间 | `Europe/London` | UTC+0/+1 |
|
|
141
|
+
| 日本时间 | `Asia/Tokyo` | UTC+9 |
|
|
142
|
+
| 法国时间 | `Europe/Paris` | UTC+1/+2 |
|
|
143
|
+
|
|
144
|
+
## 📋 使用示例
|
|
145
|
+
|
|
146
|
+
### 示例 1:获取当前时间
|
|
147
|
+
|
|
148
|
+
```
|
|
149
|
+
用户:现在几点了?
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
**返回**:
|
|
153
|
+
```json
|
|
154
|
+
{
|
|
155
|
+
"time": "2025-12-27T09:38:01.938Z",
|
|
156
|
+
"timezone": "Asia/Shanghai",
|
|
157
|
+
"format": "iso"
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### 示例 2:获取指定时区时间
|
|
162
|
+
|
|
163
|
+
```
|
|
164
|
+
用户:纽约现在几点?
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
**返回**:
|
|
168
|
+
```json
|
|
169
|
+
{
|
|
170
|
+
"time": "2025-12-27T04:38:01.938Z",
|
|
171
|
+
"timezone": "America/New_York",
|
|
172
|
+
"format": "iso"
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### 示例 3:获取时间戳
|
|
177
|
+
|
|
178
|
+
```
|
|
179
|
+
用户:当前时间戳是多少?
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
**返回**:
|
|
183
|
+
```json
|
|
184
|
+
{
|
|
185
|
+
"time": "1735292625123",
|
|
186
|
+
"timezone": "Asia/Shanghai",
|
|
187
|
+
"format": "timestamp"
|
|
188
|
+
}
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### 示例 4:获取详细时间信息
|
|
192
|
+
|
|
193
|
+
```
|
|
194
|
+
用户:今天是几号?星期几?
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
**返回**:
|
|
198
|
+
```json
|
|
199
|
+
{
|
|
200
|
+
"year": 2025,
|
|
201
|
+
"month": 12,
|
|
202
|
+
"day": 27,
|
|
203
|
+
"hour": 17,
|
|
204
|
+
"minute": 38,
|
|
205
|
+
"second": 1,
|
|
206
|
+
"weekday": "星期五",
|
|
207
|
+
"timezone": "Asia/Shanghai"
|
|
208
|
+
}
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
## 🔧 故障排除
|
|
212
|
+
|
|
213
|
+
### 工具不可用
|
|
214
|
+
|
|
215
|
+
1. **确认已重启应用** - 配置更改后必须重启 Cursor/Claude Desktop
|
|
216
|
+
2. **检查配置文件路径** - 确保配置文件路径正确
|
|
217
|
+
3. **检查 JSON 格式** - 确保 JSON 格式正确,无语法错误
|
|
218
|
+
4. **检查 Node.js 版本** - 需要 Node.js >= 18.0.0
|
|
219
|
+
|
|
220
|
+
### 服务器无法启动
|
|
221
|
+
|
|
222
|
+
1. **检查 Node.js 版本**:
|
|
223
|
+
```bash
|
|
224
|
+
node -v # 需要 >= 18.0.0
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
2. **手动测试服务器**:
|
|
228
|
+
```bash
|
|
229
|
+
npx -y @guanxiong/mcp-server-time
|
|
230
|
+
```
|
|
231
|
+
应该无输出(使用 stdio 通信)
|
|
232
|
+
|
|
233
|
+
3. **检查网络连接** - 使用 npx 需要网络连接下载包
|
|
234
|
+
|
|
235
|
+
### 时区错误
|
|
236
|
+
|
|
237
|
+
1. **确认时区标识符正确** - 使用标准 IANA 时区标识符
|
|
238
|
+
2. **检查时区名称大小写** - 时区名称区分大小写
|
|
239
|
+
3. **不指定时区** - 如果不指定,将使用系统默认时区
|
|
240
|
+
|
|
241
|
+
## 📚 相关资源
|
|
242
|
+
|
|
243
|
+
- [Model Context Protocol 文档](https://modelcontextprotocol.io/)
|
|
244
|
+
- [IANA 时区数据库](https://www.iana.org/time-zones)
|
|
245
|
+
- [Node.js Date 对象文档](https://nodejs.org/api/date.html)
|
|
246
|
+
- [Cursor IDE](https://cursor.sh/)
|
|
247
|
+
- [Claude Desktop](https://claude.ai/desktop)
|
|
248
|
+
|
|
249
|
+
## 🤝 贡献
|
|
250
|
+
|
|
251
|
+
欢迎提交 Issue 和 Pull Request!
|
|
252
|
+
|
|
253
|
+
1. Fork 本仓库
|
|
254
|
+
2. 创建特性分支 (`git checkout -b feature/AmazingFeature`)
|
|
255
|
+
3. 提交更改 (`git commit -m 'Add some AmazingFeature'`)
|
|
256
|
+
4. 推送到分支 (`git push origin feature/AmazingFeature`)
|
|
257
|
+
5. 开启 Pull Request
|
|
258
|
+
|
|
259
|
+
## 📝 更新日志
|
|
260
|
+
|
|
261
|
+
### 1.0.0 (2025-12-27)
|
|
262
|
+
|
|
263
|
+
- ✨ 初始版本发布
|
|
264
|
+
- ✅ 支持获取当前时间(多种格式)
|
|
265
|
+
- ✅ 支持时区设置
|
|
266
|
+
- ✅ 支持获取详细时间信息
|
|
267
|
+
|
|
268
|
+
## 📄 许可证
|
|
269
|
+
|
|
270
|
+
本项目采用 [MIT](LICENSE) 许可证。
|
|
271
|
+
|
|
272
|
+
## 🙏 致谢
|
|
273
|
+
|
|
274
|
+
- [Model Context Protocol](https://modelcontextprotocol.io/) - 提供 MCP 协议和 SDK
|
|
275
|
+
- 所有贡献者和用户
|
|
276
|
+
|
|
277
|
+
---
|
|
278
|
+
|
|
279
|
+
**Made with ❤️ for the MCP community**
|
package/index.js
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
4
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
5
|
+
import {
|
|
6
|
+
CallToolRequestSchema,
|
|
7
|
+
ListToolsRequestSchema,
|
|
8
|
+
} from "@modelcontextprotocol/sdk/types.js";
|
|
9
|
+
|
|
10
|
+
const server = new Server(
|
|
11
|
+
{
|
|
12
|
+
name: "mcp-server-time",
|
|
13
|
+
version: "1.0.0",
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
capabilities: {
|
|
17
|
+
tools: {},
|
|
18
|
+
},
|
|
19
|
+
}
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
// 列出可用工具
|
|
23
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
24
|
+
return {
|
|
25
|
+
tools: [
|
|
26
|
+
{
|
|
27
|
+
name: "get_current_time",
|
|
28
|
+
description: "获取当前日期和时间",
|
|
29
|
+
inputSchema: {
|
|
30
|
+
type: "object",
|
|
31
|
+
properties: {
|
|
32
|
+
timezone: {
|
|
33
|
+
type: "string",
|
|
34
|
+
description: "时区(例如:Asia/Shanghai, UTC, America/New_York)。默认为系统时区",
|
|
35
|
+
},
|
|
36
|
+
format: {
|
|
37
|
+
type: "string",
|
|
38
|
+
description: "时间格式:'iso'(ISO 8601)、'locale'(本地格式)、'timestamp'(时间戳)。默认为 'iso'",
|
|
39
|
+
enum: ["iso", "locale", "timestamp"],
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: "get_time_info",
|
|
46
|
+
description: "获取详细的时间信息,包括年、月、日、时、分、秒等",
|
|
47
|
+
inputSchema: {
|
|
48
|
+
type: "object",
|
|
49
|
+
properties: {
|
|
50
|
+
timezone: {
|
|
51
|
+
type: "string",
|
|
52
|
+
description: "时区(例如:Asia/Shanghai, UTC)。默认为系统时区",
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
};
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// 处理工具调用
|
|
62
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
63
|
+
const { name, arguments: args } = request.params;
|
|
64
|
+
|
|
65
|
+
try {
|
|
66
|
+
if (name === "get_current_time") {
|
|
67
|
+
const timezone = args?.timezone || undefined;
|
|
68
|
+
const format = args?.format || "iso";
|
|
69
|
+
|
|
70
|
+
let date;
|
|
71
|
+
if (timezone) {
|
|
72
|
+
// 使用指定时区
|
|
73
|
+
const now = new Date();
|
|
74
|
+
const formatter = new Intl.DateTimeFormat("en-US", {
|
|
75
|
+
timeZone: timezone,
|
|
76
|
+
year: "numeric",
|
|
77
|
+
month: "2-digit",
|
|
78
|
+
day: "2-digit",
|
|
79
|
+
hour: "2-digit",
|
|
80
|
+
minute: "2-digit",
|
|
81
|
+
second: "2-digit",
|
|
82
|
+
hour12: false,
|
|
83
|
+
});
|
|
84
|
+
const parts = formatter.formatToParts(now);
|
|
85
|
+
const year = parts.find((p) => p.type === "year").value;
|
|
86
|
+
const month = parts.find((p) => p.type === "month").value;
|
|
87
|
+
const day = parts.find((p) => p.type === "day").value;
|
|
88
|
+
const hour = parts.find((p) => p.type === "hour").value;
|
|
89
|
+
const minute = parts.find((p) => p.type === "minute").value;
|
|
90
|
+
const second = parts.find((p) => p.type === "second").value;
|
|
91
|
+
date = new Date(`${year}-${month}-${day}T${hour}:${minute}:${second}`);
|
|
92
|
+
} else {
|
|
93
|
+
date = new Date();
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
let result;
|
|
97
|
+
switch (format) {
|
|
98
|
+
case "timestamp":
|
|
99
|
+
result = date.getTime().toString();
|
|
100
|
+
break;
|
|
101
|
+
case "locale":
|
|
102
|
+
result = date.toLocaleString("zh-CN", timezone ? { timeZone: timezone } : {});
|
|
103
|
+
break;
|
|
104
|
+
case "iso":
|
|
105
|
+
default:
|
|
106
|
+
result = date.toISOString();
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return {
|
|
111
|
+
content: [
|
|
112
|
+
{
|
|
113
|
+
type: "text",
|
|
114
|
+
text: JSON.stringify({
|
|
115
|
+
time: result,
|
|
116
|
+
timezone: timezone || Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
117
|
+
format: format,
|
|
118
|
+
}, null, 2),
|
|
119
|
+
},
|
|
120
|
+
],
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (name === "get_time_info") {
|
|
125
|
+
const timezone = args?.timezone || undefined;
|
|
126
|
+
const now = new Date();
|
|
127
|
+
|
|
128
|
+
let dateInfo;
|
|
129
|
+
if (timezone) {
|
|
130
|
+
const formatter = new Intl.DateTimeFormat("zh-CN", {
|
|
131
|
+
timeZone: timezone,
|
|
132
|
+
year: "numeric",
|
|
133
|
+
month: "2-digit",
|
|
134
|
+
day: "2-digit",
|
|
135
|
+
hour: "2-digit",
|
|
136
|
+
minute: "2-digit",
|
|
137
|
+
second: "2-digit",
|
|
138
|
+
weekday: "long",
|
|
139
|
+
hour12: false,
|
|
140
|
+
});
|
|
141
|
+
const parts = formatter.formatToParts(now);
|
|
142
|
+
dateInfo = {
|
|
143
|
+
year: parseInt(parts.find((p) => p.type === "year").value),
|
|
144
|
+
month: parseInt(parts.find((p) => p.type === "month").value),
|
|
145
|
+
day: parseInt(parts.find((p) => p.type === "day").value),
|
|
146
|
+
hour: parseInt(parts.find((p) => p.type === "hour").value),
|
|
147
|
+
minute: parseInt(parts.find((p) => p.type === "minute").value),
|
|
148
|
+
second: parseInt(parts.find((p) => p.type === "second").value),
|
|
149
|
+
weekday: parts.find((p) => p.type === "weekday").value,
|
|
150
|
+
timezone: timezone,
|
|
151
|
+
};
|
|
152
|
+
} else {
|
|
153
|
+
dateInfo = {
|
|
154
|
+
year: now.getFullYear(),
|
|
155
|
+
month: now.getMonth() + 1,
|
|
156
|
+
day: now.getDate(),
|
|
157
|
+
hour: now.getHours(),
|
|
158
|
+
minute: now.getMinutes(),
|
|
159
|
+
second: now.getSeconds(),
|
|
160
|
+
weekday: now.toLocaleDateString("zh-CN", { weekday: "long" }),
|
|
161
|
+
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return {
|
|
166
|
+
content: [
|
|
167
|
+
{
|
|
168
|
+
type: "text",
|
|
169
|
+
text: JSON.stringify(dateInfo, null, 2),
|
|
170
|
+
},
|
|
171
|
+
],
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
throw new Error(`未知的工具: ${name}`);
|
|
176
|
+
} catch (error) {
|
|
177
|
+
return {
|
|
178
|
+
content: [
|
|
179
|
+
{
|
|
180
|
+
type: "text",
|
|
181
|
+
text: `错误: ${error.message}`,
|
|
182
|
+
},
|
|
183
|
+
],
|
|
184
|
+
isError: true,
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
// 启动服务器
|
|
190
|
+
async function main() {
|
|
191
|
+
const transport = new StdioServerTransport();
|
|
192
|
+
await server.connect(transport);
|
|
193
|
+
console.error("MCP 时间服务器已启动");
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
main().catch((error) => {
|
|
197
|
+
console.error("服务器启动失败:", error);
|
|
198
|
+
process.exit(1);
|
|
199
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@guanxiong/mcp-server-time",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A simple Model Context Protocol (MCP) server for getting current time with timezone support",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"bin": {
|
|
8
|
+
"mcp-server-time": "./index.js"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"start": "node index.js"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"mcp",
|
|
15
|
+
"time",
|
|
16
|
+
"timezone",
|
|
17
|
+
"model-context-protocol",
|
|
18
|
+
"cursor",
|
|
19
|
+
"claude",
|
|
20
|
+
"ai"
|
|
21
|
+
],
|
|
22
|
+
"author": "guanxiong.shen <guanxiong.shen@gmail.com>",
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "https://github.com/guanxiong-shen/mcp-server-time.git"
|
|
27
|
+
},
|
|
28
|
+
"bugs": {
|
|
29
|
+
"url": "https://github.com/guanxiong-shen/mcp-server-time/issues"
|
|
30
|
+
},
|
|
31
|
+
"homepage": "https://github.com/guanxiong-shen/mcp-server-time#readme",
|
|
32
|
+
"engines": {
|
|
33
|
+
"node": ">=18.0.0"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@modelcontextprotocol/sdk": "^1.25.1"
|
|
37
|
+
},
|
|
38
|
+
"files": [
|
|
39
|
+
"index.js",
|
|
40
|
+
"README.md",
|
|
41
|
+
"LICENSE"
|
|
42
|
+
]
|
|
43
|
+
}
|