@mcpcn/mcp-notification 1.0.15 → 1.0.17
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/dist/index.js +37 -5
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -12,10 +12,42 @@ function resolveChatSessionId(request) {
|
|
|
12
12
|
}
|
|
13
13
|
return undefined;
|
|
14
14
|
};
|
|
15
|
-
|
|
16
|
-
pick(request?.params?.meta, ['chatSessionId', 'chatSessionID'])
|
|
17
|
-
pick(request?.meta, ['chatSessionId', 'chatSessionID'])
|
|
18
|
-
pick(request?._meta, ['chatSessionId', 'chatSessionID'])
|
|
15
|
+
const direct = 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
|
+
if (direct)
|
|
20
|
+
return direct;
|
|
21
|
+
const inArgs = pick(request?.params?.arguments?._meta, ['chatSessionId', 'chatSessionID']) ||
|
|
22
|
+
pick(request?.params?.arguments?.meta, ['chatSessionId', 'chatSessionID']) ||
|
|
23
|
+
pick(request?.params?.arguments, ['chatSessionId', 'chatSessionID']);
|
|
24
|
+
if (inArgs)
|
|
25
|
+
return inArgs;
|
|
26
|
+
const scan = (obj, keys, maxDepth = 3) => {
|
|
27
|
+
const queue = [obj];
|
|
28
|
+
const seen = new Set();
|
|
29
|
+
let depth = 0;
|
|
30
|
+
while (queue.length && depth <= maxDepth) {
|
|
31
|
+
const cur = queue.shift();
|
|
32
|
+
if (!cur || typeof cur !== 'object' || seen.has(cur)) {
|
|
33
|
+
depth++;
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
seen.add(cur);
|
|
37
|
+
for (const k of keys) {
|
|
38
|
+
const v = cur[k];
|
|
39
|
+
if (typeof v === 'string' && v)
|
|
40
|
+
return v;
|
|
41
|
+
}
|
|
42
|
+
for (const v of Object.values(cur)) {
|
|
43
|
+
if (v && typeof v === 'object')
|
|
44
|
+
queue.push(v);
|
|
45
|
+
}
|
|
46
|
+
depth++;
|
|
47
|
+
}
|
|
48
|
+
return undefined;
|
|
49
|
+
};
|
|
50
|
+
return scan(request, ['chatSessionId', 'chatSessionID']);
|
|
19
51
|
}
|
|
20
52
|
async function postJson(path, body, chatSessionId) {
|
|
21
53
|
const headers = { 'Content-Type': 'application/json', Accept: 'application/json' };
|
|
@@ -132,7 +164,7 @@ class ReminderServer {
|
|
|
132
164
|
},
|
|
133
165
|
],
|
|
134
166
|
}));
|
|
135
|
-
this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
167
|
+
this.server.setRequestHandler((CallToolRequestSchema.passthrough ? CallToolRequestSchema.passthrough() : CallToolRequestSchema), async (request) => {
|
|
136
168
|
try {
|
|
137
169
|
if (!request.params.arguments || typeof request.params.arguments !== 'object') {
|
|
138
170
|
throw new McpError(ErrorCode.InvalidParams, '无效的参数');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcpcn/mcp-notification",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.17",
|
|
4
4
|
"description": "系统通知MCP服务器",
|
|
5
5
|
"packageManager": "yarn@1.22.22",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -36,6 +36,6 @@
|
|
|
36
36
|
"typescript": "^5.7.2"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@modelcontextprotocol/sdk": "^1.0
|
|
39
|
+
"@modelcontextprotocol/sdk": "^1.10.0"
|
|
40
40
|
}
|
|
41
41
|
}
|