@momeidejiyi/dsh-general-mcp 0.2.1 → 0.3.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/lib/index.js +10 -4
- package/package.json +1 -1
- package/src/catalog.ts +6 -1
- package/src/index.ts +11 -2
package/lib/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// @momeidejiyi/dsh-general-mcp@0.
|
|
1
|
+
// @momeidejiyi/dsh-general-mcp@0.3.0 (generated)
|
|
2
2
|
|
|
3
3
|
// packages/general-mcp/src/index.ts
|
|
4
4
|
import { appendFileSync } from "node:fs";
|
|
@@ -96,7 +96,7 @@ function folderFromMeta(tool) {
|
|
|
96
96
|
}
|
|
97
97
|
function folderFromName(rawName) {
|
|
98
98
|
const parts = rawName.split(/[./]/).filter(Boolean);
|
|
99
|
-
return parts.length > 1 ? parts.slice(0, -1) : [
|
|
99
|
+
return parts.length > 1 ? parts.slice(0, -1) : [];
|
|
100
100
|
}
|
|
101
101
|
function shortHash(value) {
|
|
102
102
|
let hash = 2166136261;
|
|
@@ -825,7 +825,7 @@ function apply(ctx, config) {
|
|
|
825
825
|
}
|
|
826
826
|
}
|
|
827
827
|
const enabled = item.enabled !== false;
|
|
828
|
-
const serverTimeout = typeof item.timeoutMs === "number" && Number.isFinite(item.timeoutMs) ? Math.min(Math.max(Math.round(item.timeoutMs), 1e3), 6e5) : 0;
|
|
828
|
+
const serverTimeout = typeof item.timeoutMs === "number" && Number.isFinite(item.timeoutMs) ? item.timeoutMs === 0 ? 0 : Math.min(Math.max(Math.round(item.timeoutMs), 1e3), 6e5) : 0;
|
|
829
829
|
const changed = entry.endpoint !== (item.endpoint ?? "") || JSON.stringify(entry.headers) !== JSON.stringify(headers) || entry.enabled !== enabled || entry.timeoutMs !== serverTimeout;
|
|
830
830
|
entry.endpoint = item.endpoint ?? "";
|
|
831
831
|
entry.headers = headers;
|
|
@@ -1179,12 +1179,18 @@ function installRoutes(ctx) {
|
|
|
1179
1179
|
for (const item of incoming) {
|
|
1180
1180
|
const name2 = String(item.name ?? "general");
|
|
1181
1181
|
if (removed.has(name2)) continue;
|
|
1182
|
+
if (body.createOnly === true && byName.get(name2) !== void 0) {
|
|
1183
|
+
throw new Error("\u7F51\u5173 " + name2 + " \u5DF2\u5B58\u5728");
|
|
1184
|
+
}
|
|
1182
1185
|
const previous = byName.get(name2) ?? {};
|
|
1183
1186
|
const hasEndpoint = typeof item.endpoint === "string";
|
|
1187
|
+
if (!hasEndpoint && byName.get(name2) === void 0) {
|
|
1188
|
+
throw new Error("\u7F51\u5173 " + name2 + " \u4E0D\u5B58\u5728\uFF0C\u6539\u52A8\u672A\u4FDD\u5B58");
|
|
1189
|
+
}
|
|
1184
1190
|
const endpoint2 = hasEndpoint ? item.endpoint.trim() : previous.endpoint ?? "";
|
|
1185
1191
|
const sameEndpoint = (previous.endpoint ?? "") === endpoint2;
|
|
1186
1192
|
const next2 = { ...previous, ...item, name: name2, endpoint: endpoint2 };
|
|
1187
|
-
|
|
1193
|
+
void sameEndpoint;
|
|
1188
1194
|
if (item.headersPatch !== null && typeof item.headersPatch === "object" && !Array.isArray(item.headersPatch)) {
|
|
1189
1195
|
const headers2 = { ...previous.headers ?? {} };
|
|
1190
1196
|
for (const [key, value] of Object.entries(item.headersPatch)) {
|
package/package.json
CHANGED
package/src/catalog.ts
CHANGED
|
@@ -146,9 +146,14 @@ function folderFromMeta(tool: McpTool): string[] | undefined {
|
|
|
146
146
|
return undefined
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
+
/**
|
|
150
|
+
* A name like "github.create_issue" implies a folder; a flat name implies none.
|
|
151
|
+
* Returning [] keeps those tools directly under their gateway card instead of
|
|
152
|
+
* dumping every server's tools into one "uncategorized" bucket.
|
|
153
|
+
*/
|
|
149
154
|
function folderFromName(rawName: string): string[] {
|
|
150
155
|
const parts = rawName.split(/[./]/).filter(Boolean)
|
|
151
|
-
return parts.length > 1 ? parts.slice(0, -1) : [
|
|
156
|
+
return parts.length > 1 ? parts.slice(0, -1) : []
|
|
152
157
|
}
|
|
153
158
|
|
|
154
159
|
function shortHash(value: string): string {
|
package/src/index.ts
CHANGED
|
@@ -211,7 +211,7 @@ export function apply(ctx: any, config?: Config): void {
|
|
|
211
211
|
}
|
|
212
212
|
const enabled = item.enabled !== false
|
|
213
213
|
const serverTimeout = typeof item.timeoutMs === 'number' && Number.isFinite(item.timeoutMs)
|
|
214
|
-
? Math.min(Math.max(Math.round(item.timeoutMs), 1_000), 600_000)
|
|
214
|
+
? (item.timeoutMs === 0 ? 0 : Math.min(Math.max(Math.round(item.timeoutMs), 1_000), 600_000))
|
|
215
215
|
: 0
|
|
216
216
|
const changed = entry.endpoint !== (item.endpoint ?? '') ||
|
|
217
217
|
JSON.stringify(entry.headers) !== JSON.stringify(headers) ||
|
|
@@ -577,14 +577,23 @@ function installRoutes(ctx: any): void {
|
|
|
577
577
|
for (const item of incoming as any[]) {
|
|
578
578
|
const name = String(item.name ?? 'general')
|
|
579
579
|
if (removed.has(name)) continue
|
|
580
|
+
if (body.createOnly === true && byName.get(name) !== undefined) {
|
|
581
|
+
throw new Error('网关 ' + name + ' 已存在')
|
|
582
|
+
}
|
|
580
583
|
const previous = byName.get(name) ?? {}
|
|
581
584
|
// A partial payload (only enabled/timeout/headers) must keep the
|
|
582
585
|
// stored endpoint and tool settings.
|
|
583
586
|
const hasEndpoint = typeof item.endpoint === 'string'
|
|
587
|
+
if (!hasEndpoint && byName.get(name) === undefined) {
|
|
588
|
+
throw new Error('网关 ' + name + ' 不存在,改动未保存')
|
|
589
|
+
}
|
|
584
590
|
const endpoint = hasEndpoint ? item.endpoint.trim() : (previous.endpoint ?? '')
|
|
585
591
|
const sameEndpoint = (previous.endpoint ?? '') === endpoint
|
|
592
|
+
// Keep tool settings when only the endpoint changes: silently
|
|
593
|
+
// dropping hidden/disabled/overrides was data loss. Entries for
|
|
594
|
+
// tools the new server does not expose are pruned on the next sync.
|
|
586
595
|
const next: any = { ...previous, ...item, name, endpoint }
|
|
587
|
-
|
|
596
|
+
void sameEndpoint
|
|
588
597
|
if (item.headersPatch !== null && typeof item.headersPatch === 'object' && !Array.isArray(item.headersPatch)) {
|
|
589
598
|
const headers: Record<string, string> = { ...(previous.headers ?? {}) }
|
|
590
599
|
for (const [key, value] of Object.entries(item.headersPatch as Record<string, unknown>)) {
|