@mcpcn/mcp-notification 1.0.13 → 1.0.15

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.
Files changed (2) hide show
  1. package/dist/index.js +28 -9
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -15,11 +15,7 @@ function resolveChatSessionId(request) {
15
15
  return (pick(request?.params?._meta, ['chatSessionId', 'chatSessionID']) ??
16
16
  pick(request?.params?.meta, ['chatSessionId', 'chatSessionID']) ??
17
17
  pick(request?.meta, ['chatSessionId', 'chatSessionID']) ??
18
- pick(request?._meta, ['chatSessionId', 'chatSessionID']) ??
19
- pick(request?.params, ['chatSessionId', 'chatSessionID']) ??
20
- pick(request?.params?.arguments?.meta, ['chatSessionId', 'chatSessionID']) ??
21
- pick(request?.params?.arguments?._meta, ['chatSessionId', 'chatSessionID']) ??
22
- pick(request?.params?.arguments, ['chatSessionId', 'chatSessionID']));
18
+ pick(request?._meta, ['chatSessionId', 'chatSessionID']));
23
19
  }
24
20
  async function postJson(path, body, chatSessionId) {
25
21
  const headers = { 'Content-Type': 'application/json', Accept: 'application/json' };
@@ -109,7 +105,6 @@ class ReminderServer {
109
105
  intervalSec: { type: 'number' },
110
106
  timeOfDay: { type: 'string', description: '例如 18:00 或 18:00:00' },
111
107
  tzOffsetMin: { type: 'number', description: '时区偏移分钟,例如北京为 480' },
112
- chatSessionId: { type: 'string' },
113
108
  },
114
109
  required: ['content', 'repeat'],
115
110
  additionalProperties: false,
@@ -120,7 +115,7 @@ class ReminderServer {
120
115
  description: '获取设备的提醒列表(仅未触发的 scheduled)。',
121
116
  inputSchema: {
122
117
  type: 'object',
123
- properties: { chatSessionId: { type: 'string' } },
118
+ properties: {},
124
119
  required: [],
125
120
  additionalProperties: false,
126
121
  },
@@ -130,7 +125,7 @@ class ReminderServer {
130
125
  description: '取消指定提醒。',
131
126
  inputSchema: {
132
127
  type: 'object',
133
- properties: { id: { type: 'string' }, chatSessionId: { type: 'string' } },
128
+ properties: { id: { type: 'string' } },
134
129
  required: ['id'],
135
130
  additionalProperties: false,
136
131
  },
@@ -174,11 +169,35 @@ class ReminderServer {
174
169
  if (resp.code !== 0) {
175
170
  return { content: [{ type: 'text', text: `设置失败:${resp.msg}` }], isError: true };
176
171
  }
172
+ const triggerAt = resp.data?.triggerAt;
173
+ const offsetMin = typeof params.tzOffsetMin === 'number' ? params.tzOffsetMin : -new Date().getTimezoneOffset();
174
+ const formatOffset = (min) => {
175
+ const sign = min >= 0 ? '+' : '-';
176
+ const abs = Math.abs(min);
177
+ const hh = String(Math.floor(abs / 60)).padStart(2, '0');
178
+ const mm = String(abs % 60).padStart(2, '0');
179
+ return `${sign}${hh}:${mm}`;
180
+ };
181
+ const toLocalRfc3339 = (iso, offMin) => {
182
+ if (!iso)
183
+ return undefined;
184
+ const d = new Date(iso);
185
+ if (isNaN(d.getTime()))
186
+ return iso;
187
+ const y = d.getFullYear();
188
+ const m = String(d.getMonth() + 1).padStart(2, '0');
189
+ const day = String(d.getDate()).padStart(2, '0');
190
+ const hh = String(d.getHours()).padStart(2, '0');
191
+ const mi = String(d.getMinutes()).padStart(2, '0');
192
+ const ss = String(d.getSeconds()).padStart(2, '0');
193
+ return `${y}-${m}-${day}T${hh}:${mi}:${ss}${formatOffset(offMin)}`;
194
+ };
195
+ const triggerAtLocal = toLocalRfc3339(triggerAt, offsetMin);
177
196
  return {
178
197
  content: [
179
198
  {
180
199
  type: 'text',
181
- text: JSON.stringify({ id: resp.data?.id, triggerAt: resp.data?.triggerAt, msg: resp.msg || '设置成功' }, null, 2),
200
+ text: JSON.stringify({ id: resp.data?.id, triggerAt: resp.data?.triggerAt, triggerAtLocal, msg: resp.msg || '设置成功' }, null, 2),
182
201
  },
183
202
  ],
184
203
  isError: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mcpcn/mcp-notification",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
4
4
  "description": "系统通知MCP服务器",
5
5
  "packageManager": "yarn@1.22.22",
6
6
  "main": "dist/index.js",