@mcpcn/mcp-notification 1.0.10 → 1.0.12

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 +22 -10
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -3,6 +3,24 @@ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
3
3
  import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
4
4
  import { CallToolRequestSchema, ErrorCode, ListToolsRequestSchema, McpError } from '@modelcontextprotocol/sdk/types.js';
5
5
  const API_BASE = process.env.REMINDER_API_BASE || 'https://www.mcpcn.cc/api';
6
+ function resolveChatSessionId(request) {
7
+ const pick = (obj, keys) => {
8
+ for (const k of keys) {
9
+ const v = obj?.[k];
10
+ if (typeof v === 'string' && v)
11
+ return v;
12
+ }
13
+ return undefined;
14
+ };
15
+ return (pick(request?.params?._meta, ['chatSessionId', 'chatSessionID']) ??
16
+ pick(request?.params?.meta, ['chatSessionId', 'chatSessionID']) ??
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']));
23
+ }
6
24
  async function postJson(path, body, chatSessionId) {
7
25
  const headers = { 'Content-Type': 'application/json', Accept: 'application/json' };
8
26
  if (chatSessionId)
@@ -91,6 +109,7 @@ class ReminderServer {
91
109
  intervalSec: { type: 'number' },
92
110
  timeOfDay: { type: 'string', description: '例如 18:00 或 18:00:00' },
93
111
  tzOffsetMin: { type: 'number', description: '时区偏移分钟,例如北京为 480' },
112
+ chatSessionId: { type: 'string' },
94
113
  },
95
114
  required: ['content', 'repeat'],
96
115
  additionalProperties: false,
@@ -101,7 +120,7 @@ class ReminderServer {
101
120
  description: '获取设备的提醒列表(仅未触发的 scheduled)。',
102
121
  inputSchema: {
103
122
  type: 'object',
104
- properties: {},
123
+ properties: { chatSessionId: { type: 'string' } },
105
124
  required: [],
106
125
  additionalProperties: false,
107
126
  },
@@ -111,7 +130,7 @@ class ReminderServer {
111
130
  description: '取消指定提醒。',
112
131
  inputSchema: {
113
132
  type: 'object',
114
- properties: { id: { type: 'string' } },
133
+ properties: { id: { type: 'string' }, chatSessionId: { type: 'string' } },
115
134
  required: ['id'],
116
135
  additionalProperties: false,
117
136
  },
@@ -125,14 +144,7 @@ class ReminderServer {
125
144
  }
126
145
  const name = request.params.name;
127
146
  const args = request.params.arguments;
128
- const chatSessionId = request?.meta?.chatSessionId ??
129
- request?._meta?.chatSessionId ??
130
- request?.params?.meta?.chatSessionId ??
131
- request?.params?._meta?.chatSessionId ??
132
- request?.params?.arguments?.meta?.chatSessionId ??
133
- request?.params?.arguments?._meta?.chatSessionId ??
134
- request?.params?.arguments?.chatSessionId ??
135
- request?.params?.chatSessionId;
147
+ const chatSessionId = resolveChatSessionId(request);
136
148
  if (!chatSessionId) {
137
149
  console.error('未在请求中检测到 chatSessionId(meta.chatSessionId)');
138
150
  const baseMsg = '解析设备失败: chatSessionId不能为空,工具暂无法使用';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mcpcn/mcp-notification",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
4
4
  "description": "系统通知MCP服务器",
5
5
  "packageManager": "yarn@1.22.22",
6
6
  "main": "dist/index.js",