@code-yeongyu/senpi 2026.7.17-3 → 2026.7.17-5
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/CHANGELOG.md +26 -0
- package/dist/core/extensions/builtin/compaction/repair-tool-pairs.d.ts +1 -0
- package/dist/core/extensions/builtin/compaction/repair-tool-pairs.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/repair-tool-pairs.js +20 -2
- package/dist/core/extensions/builtin/compaction/repair-tool-pairs.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/config-schema.d.ts +8 -1
- package/dist/core/extensions/builtin/mcp/config-schema.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/config-schema.js +23 -0
- package/dist/core/extensions/builtin/mcp/config-schema.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/config.d.ts +13 -0
- package/dist/core/extensions/builtin/mcp/config.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/config.js +36 -0
- package/dist/core/extensions/builtin/mcp/config.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/service-snapshot.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/service-snapshot.js +1 -0
- package/dist/core/extensions/builtin/mcp/service-snapshot.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/service-types.d.ts +12 -0
- package/dist/core/extensions/builtin/mcp/service-types.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/service-types.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/service.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/service.js +2 -1
- package/dist/core/extensions/builtin/mcp/service.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/status.js +1 -0
- package/dist/core/extensions/builtin/mcp/status.js.map +1 -1
- package/dist/core/extensions/builtin/websearch/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/websearch/index.js +20 -3
- package/dist/core/extensions/builtin/websearch/index.js.map +1 -1
- package/dist/core/extensions/index.d.ts +1 -0
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +20 -4
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +3 -1
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +20 -0
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +13 -0
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/provider-composer.d.ts.map +1 -1
- package/dist/core/provider-composer.js +8 -1
- package/dist/core/provider-composer.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/docs/extensions.md +46 -0
- package/docs/mcp.md +16 -0
- package/node_modules/@code-yeongyu/senpi-codemode/CHANGELOG.md +25 -0
- package/node_modules/@code-yeongyu/senpi-codemode/package.json +3 -3
- package/node_modules/@code-yeongyu/senpi-codemode/src/prompt/eval-prompt.ts +8 -7
- package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js +19 -4
- package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/proxy.d.ts +3 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/proxy.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/proxy.js +4 -2
- package/node_modules/@earendil-works/pi-agent-core/dist/proxy.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/package.json +2 -2
- package/node_modules/@earendil-works/pi-ai/dist/compat.d.ts +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/compat.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/compat.js +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/compat.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/models.generated.d.ts +31 -0
- package/node_modules/@earendil-works/pi-ai/dist/models.generated.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.models.js +9 -9
- package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.models.js +5 -5
- package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/together.models.d.ts +31 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/together.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/together.models.js +19 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/together.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/context-transformer.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/context-transformer.js +3 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/context-transformer.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/index.d.ts +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/index.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/index.js +2 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/index.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/invoke-tag-scanner.d.ts +11 -0
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/invoke-tag-scanner.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/invoke-tag-scanner.js +40 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/invoke-tag-scanner.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/stream.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/stream.js +92 -7
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/stream.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/gemma4.d.ts +8 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/gemma4.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/gemma4.js +129 -27
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/gemma4.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/json-mix.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/json-mix.js +140 -6
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/json-mix.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/morph-xml.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/morph-xml.js +28 -6
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/morph-xml.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/yaml-xml.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/yaml-xml.js +51 -18
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/yaml-xml.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/stream-wrapper.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/stream-wrapper.js +70 -9
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/stream-wrapper.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/types.d.ts +5 -2
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/types.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/types.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/types.d.ts +8 -2
- package/node_modules/@earendil-works/pi-ai/dist/types.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/types.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/tool-pair-repair.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/tool-pair-repair.js +19 -2
- package/node_modules/@earendil-works/pi-ai/dist/utils/tool-pair-repair.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/tool-schema-compat.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/tool-schema-compat.js +45 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/tool-schema-compat.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/package.json +1 -1
- package/node_modules/@earendil-works/pi-pty/package.json +1 -1
- package/node_modules/@earendil-works/pi-tui/package.json +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2026.7.17-5] - 2026-07-17
|
|
4
|
+
|
|
5
|
+
### Breaking Changes
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
### Changed
|
|
10
|
+
|
|
11
|
+
### Fixed
|
|
12
|
+
|
|
13
|
+
### Removed
|
|
14
|
+
|
|
15
|
+
## [2026.7.17-4] - 2026-07-17
|
|
16
|
+
|
|
17
|
+
### Breaking Changes
|
|
18
|
+
|
|
19
|
+
### Added
|
|
20
|
+
|
|
21
|
+
### Changed
|
|
22
|
+
|
|
23
|
+
### Fixed
|
|
24
|
+
|
|
25
|
+
- Fixed Kimi/Moonshot function parameters with root object unions by flattening them into a compatible object schema.
|
|
26
|
+
|
|
27
|
+
### Removed
|
|
28
|
+
|
|
3
29
|
## [2026.7.17-3] - 2026-07-17
|
|
4
30
|
|
|
5
31
|
### Breaking Changes
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Message } from "@earendil-works/pi-ai";
|
|
2
2
|
export declare const TOOL_RESULT_PLACEHOLDER = "Tool output unavailable (context compacted)";
|
|
3
|
+
/** Repairs orphaned tool results and dangling tool calls. */
|
|
3
4
|
export declare function repairOrphanedToolResults(messages: Message[]): Message[];
|
|
4
5
|
//# sourceMappingURL=repair-tool-pairs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repair-tool-pairs.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/compaction/repair-tool-pairs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAe,MAAM,uBAAuB,CAAC;AAElE,eAAO,MAAM,uBAAuB,gDAAgD,CAAC;
|
|
1
|
+
{"version":3,"file":"repair-tool-pairs.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/compaction/repair-tool-pairs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAe,MAAM,uBAAuB,CAAC;AAElE,eAAO,MAAM,uBAAuB,gDAAgD,CAAC;AAgBrF,6DAA6D;AAC7D,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,OAAO,EAAE,CAkDxE"}
|
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
export const TOOL_RESULT_PLACEHOLDER = "Tool output unavailable (context compacted)";
|
|
2
|
+
/**
|
|
3
|
+
* Retry diagnostic for a dangling tool call flagged `incomplete` by the text
|
|
4
|
+
* tool-call middleware (truncated and unrecoverable at stream end). Tells the
|
|
5
|
+
* model the call never ran and should be re-issued with complete arguments.
|
|
6
|
+
* Duplicated verbatim in the sibling pair-repair copy — the two packages
|
|
7
|
+
* intentionally do not share this constant (no new cross-package dependency).
|
|
8
|
+
*/
|
|
9
|
+
function incompleteToolCallRetryText(name, errorMessage) {
|
|
10
|
+
if (errorMessage !== undefined) {
|
|
11
|
+
return `${errorMessage}${errorMessage.endsWith(".") ? "" : "."} Re-issue the tool call with complete arguments.`;
|
|
12
|
+
}
|
|
13
|
+
return `Tool call "${name}" was not executed: the response ended before the tool call was complete. Re-issue the tool call with complete arguments.`;
|
|
14
|
+
}
|
|
15
|
+
/** Repairs orphaned tool results and dangling tool calls. */
|
|
2
16
|
export function repairOrphanedToolResults(messages) {
|
|
3
17
|
const toolCallIds = new Set();
|
|
4
18
|
const toolResultIds = new Set();
|
|
@@ -31,12 +45,16 @@ export function repairOrphanedToolResults(messages) {
|
|
|
31
45
|
for (const block of message.content) {
|
|
32
46
|
if (block.type !== "toolCall" || !dangling.has(block.id))
|
|
33
47
|
continue;
|
|
48
|
+
const incomplete = block.incomplete === true;
|
|
49
|
+
const text = incomplete
|
|
50
|
+
? incompleteToolCallRetryText(block.name, block.errorMessage)
|
|
51
|
+
: TOOL_RESULT_PLACEHOLDER;
|
|
34
52
|
output.push({
|
|
35
53
|
role: "toolResult",
|
|
36
54
|
toolCallId: block.id,
|
|
37
55
|
toolName: block.name,
|
|
38
|
-
content: [{ type: "text", text
|
|
39
|
-
isError:
|
|
56
|
+
content: [{ type: "text", text }],
|
|
57
|
+
isError: incomplete,
|
|
40
58
|
timestamp: message.timestamp ? message.timestamp + 1 : Date.now(),
|
|
41
59
|
});
|
|
42
60
|
dangling.delete(block.id);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repair-tool-pairs.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/compaction/repair-tool-pairs.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,uBAAuB,GAAG,6CAA6C,CAAC;AAErF,MAAM,UAAU,yBAAyB,CAAC,QAAmB;IAC5D,MAAM,WAAW,GAAG,IAAI,GAAG,EAAU,CAAC;IACtC,MAAM,aAAa,GAAG,IAAI,GAAG,EAAU,C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AK,CAAC,IAAI,KAAK,UAAU,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;oBAAE,SAAS;gBACnE,MAAM,CAAC,IAAI,CAAC;oBACX,IAAI,EAAE,YAAY;oBAClB,UAAU,EAAE,KAAK,CAAC,EAAE;oBACpB,QAAQ,EAAE,KAAK,CAAC,IAAI;oBACpB,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"repair-tool-pairs.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/compaction/repair-tool-pairs.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,uBAAuB,GAAG,6CAA6C,CAAC;AAErF;;;;;;GAMG;AACH,SAAS,2BAA2B,CAAC,IAAY,EAAE,YAAqB;IACvE,IAAI,YAAY,KAAK,SAAS,EAAE,CAAC;QAChC,OAAO,GAAG,YAAY,GAAG,YAAY,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,kDAAkD,CAAC;IAClH,CAAC;IACD,OAAO,cAAc,IAAI,2HAA2H,CAAC;AACtJ,CAAC;AAED,6DAA6D;AAC7D,MAAM,UAAU,yBAAyB,CAAC,QAAmB;IAC5D,MAAM,WAAW,GAAG,IAAI,GAAG,EAAU,CAAC;IACtC,MAAM,aAAa,GAAG,IAAI,GAAG,EAAU,CAAC;IACxC,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAChC,IAAI,OAAO,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;YAClC,KAAK,MAAM,KAAK,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;gBACrC,IAAI,KAAK,CAAC,IAAI,KAAK,UAAU;oBAAE,WAAW,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YAC1D,CAAC;QACF,CAAC;QACD,IAAI,OAAO,CAAC,IAA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AM,CAAC,IAAI,CAAC;oBACX,IAAI,EAAE,YAAY;oBAClB,UAAU,EAAE,KAAK,CAAC,EAAE;oBACpB,QAAQ,EAAE,KAAK,CAAC,IAAI;oBACpB,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;oBACjC,OAAO,EAAE,UAAU;oBACnB,SAAS,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE;iBACjE,CAAC,CAAC;gBACH,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YAC3B,CAAC;QACF,CAAC;IACF,CAAC;IAED,OAAO,MAAM,CAAC;AACf,CAAC","sourcesContent":["import type { Message, TextContent } from \"@earendil-works/pi-ai\";\n\nexport const TOOL_RESULT_PLACEHOLDER = \"Tool output unavailable (context compacted)\";\n\n/**\n * Retry diagnostic for a dangling tool call flagged `incomplete` by the text\n * tool-call middleware (truncated and unrecoverable at stream end). Tells the\n * model the call never ran and should be re-issued with complete arguments.\n * Duplicated verbatim in the sibling pair-repair copy — the two packages\n * intentionally do not share this constant (no new cross-package dependency).\n */\nfunction incompleteToolCallRetryText(name: string, errorMessage?: string): string {\n\tif (errorMessage !== undefined) {\n\t\treturn `${errorMessage}${errorMessage.endsWith(\".\") ? \"\" : \".\"} Re-issue the tool call with complete arguments.`;\n\t}\n\treturn `Tool call \"${name}\" was not executed: the response ended before the tool call was complete. Re-issue the tool call with complete arguments.`;\n}\n\n/** Repairs orphaned tool results and dangling tool calls. */\nexport function repairOrphanedToolResults(messages: Message[]): Message[] {\n\tconst toolCallIds = new Set<string>();\n\tconst toolResultIds = new Set<string>();\n\tfor (const message of messages) {\n\t\tif (message.role === \"assistant\") {\n\t\t\tfor (const block of message.content) {\n\t\t\t\tif (block.type === \"toolCall\") toolCallIds.add(block.id);\n\t\t\t}\n\t\t}\n\t\tif (message.role === \"toolResult\") toolResultIds.add(message.toolCallId);\n\t}\n\n\tconst output: Message[] = [];\n\tconst dangling = new Set([...toolCallIds].filter((id) => !toolResultIds.has(id)));\n\n\tfor (const message of messages) {\n\t\tif (message.role === \"toolResult\") {\n\t\t\tif (!toolCallIds.has(message.toolCallId)) {\n\t\t\t\toutput.push({\n\t\t\t\t\t...message,\n\t\t\t\t\tcontent: [{ type: \"text\", text: TOOL_RESULT_PLACEHOLDER }] satisfies TextContent[],\n\t\t\t\t});\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\toutput.push(message);\n\t\t\tcontinue;\n\t\t}\n\n\t\toutput.push(message);\n\t\tif (message.role === \"assistant\") {\n\t\t\tfor (const block of message.content) {\n\t\t\t\tif (block.type !== \"toolCall\" || !dangling.has(block.id)) continue;\n\t\t\t\tconst incomplete = block.incomplete === true;\n\t\t\t\tconst text = incomplete\n\t\t\t\t\t? incompleteToolCallRetryText(block.name, block.errorMessage)\n\t\t\t\t\t: TOOL_RESULT_PLACEHOLDER;\n\t\t\t\toutput.push({\n\t\t\t\t\trole: \"toolResult\",\n\t\t\t\t\ttoolCallId: block.id,\n\t\t\t\t\ttoolName: block.name,\n\t\t\t\t\tcontent: [{ type: \"text\", text }],\n\t\t\t\t\tisError: incomplete,\n\t\t\t\t\ttimestamp: message.timestamp ? message.timestamp + 1 : Date.now(),\n\t\t\t\t});\n\t\t\t\tdangling.delete(block.id);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn output;\n}\n"]}
|
|
@@ -96,8 +96,10 @@ export type McpServerConfig = Static<typeof ServerSchema> & {
|
|
|
96
96
|
exposure: "auto" | "direct" | "search" | "proxy";
|
|
97
97
|
logLevel: Static<typeof LogLevelSchema>;
|
|
98
98
|
};
|
|
99
|
+
/** Public raw type for extension-declared MCP servers. */
|
|
100
|
+
export type McpServerDeclaration = Static<typeof ServerSchema>;
|
|
99
101
|
export type McpSettings = Required<Pick<Static<typeof SettingsSchema>, "toolPrefix">> & Omit<Static<typeof SettingsSchema>, "toolPrefix">;
|
|
100
|
-
export type McpServerSource = "global" | "claude" | "project" | "skill";
|
|
102
|
+
export type McpServerSource = "global" | "claude" | "project" | "skill" | "extension";
|
|
101
103
|
export type McpServerState = "enabled" | "disabled" | "untrusted";
|
|
102
104
|
export interface ResolvedMcpServer {
|
|
103
105
|
name: string;
|
|
@@ -247,6 +249,11 @@ export declare const validateConfig: import("typebox/compile").Validator<{}, Typ
|
|
|
247
249
|
logLevel?: "alert" | "critical" | "debug" | "emergency" | "error" | "info" | "notice" | "warning" | undefined;
|
|
248
250
|
}> | undefined;
|
|
249
251
|
}>;
|
|
252
|
+
/**
|
|
253
|
+
* Validate a single extension-declared MCP server.
|
|
254
|
+
* Returns a descriptive error string, or null when valid.
|
|
255
|
+
*/
|
|
256
|
+
export declare function validateMcpServerDeclaration(name: string, raw: unknown): string | null;
|
|
250
257
|
export declare const defaultSettings: McpSettings;
|
|
251
258
|
export {};
|
|
252
259
|
//# sourceMappingURL=config-schema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-schema.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/mcp/config-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAG5C,eAAO,MAAM,cAAc,wNASzB,CAAC;AAaH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0BxB,CAAC;AAEF,QAAA,MAAM,cAAc;;;;;;;;;;;;EAoBnB,CAAC;AAEF,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAMxB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,YAAY,CAAC,CAAC;AACpD,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,OAAO,YAAY,CAAC,GAAG;IAC3D,IAAI,EAAE,OAAO,GAAG,MA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EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IACzC,cAAc,EAAE,OAAO,CAAC;CACxB;AAED,wBAAgB,gCAAgC,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,GAAG,SAAS,CAYtF;AAED,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAwB,CAAC;AAGpD;;;GAGG;AACH,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAkBtF;AAED,eAAO,MAAM,eAAe,EAAE,WAI7B,CAAC"}
|
|
@@ -71,6 +71,29 @@ export function getServerEndpointValidationError(config) {
|
|
|
71
71
|
return undefined;
|
|
72
72
|
}
|
|
73
73
|
export const validateConfig = Compile(ConfigSchema);
|
|
74
|
+
const validateServer = Compile(ServerSchema);
|
|
75
|
+
/**
|
|
76
|
+
* Validate a single extension-declared MCP server.
|
|
77
|
+
* Returns a descriptive error string, or null when valid.
|
|
78
|
+
*/
|
|
79
|
+
export function validateMcpServerDeclaration(name, raw) {
|
|
80
|
+
if (!validateServer.Check(raw)) {
|
|
81
|
+
const error = Array.from(validateServer.Errors(raw))[0];
|
|
82
|
+
const path = error.instancePath
|
|
83
|
+
.replace(/^\//, "")
|
|
84
|
+
.split("/")
|
|
85
|
+
.map((p) => p.replace(/~1/g, "/").replace(/~0/g, "~"))
|
|
86
|
+
.join(".") || "$";
|
|
87
|
+
const message = error.message === "must be array" ? "Expected array" : error.message;
|
|
88
|
+
return `Invalid MCP server declaration "${name}": ${path}: ${message}`;
|
|
89
|
+
}
|
|
90
|
+
const server = raw;
|
|
91
|
+
const endpointError = getServerEndpointValidationError({ mcpServers: { [name]: server } });
|
|
92
|
+
if (endpointError) {
|
|
93
|
+
return `Invalid MCP server declaration "${name}": ${endpointError}`;
|
|
94
|
+
}
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
74
97
|
export const defaultSettings = {
|
|
75
98
|
outputGuard: { maxBytes: 50 * 1024, maxLines: 2000 },
|
|
76
99
|
searchThreshold: 10,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-schema.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/mcp/config-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1C,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC;IACxC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;IACrB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;IACpB,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;IACtB,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC;IACvB,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;IACrB,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC;IACxB,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;IACrB,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC;CACzB,CAAC,CAAC;AAEH,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,CAC9B;IACC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;IACtC,YAAY,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;IAC1E,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,IA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AG,OAAO,CAAC,YAAY,CAAC,CAAC;AACpD,MAAM,CAAC,MAAM,eAAe,GAAgB;IAC3C,WAAW,EAAE,EAAE,QAAQ,EAAE,EAAE,GAAG,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE;IACpD,eAAe,EAAE,EAAE;IACnB,UAAU,EAAE,KAAK;CACjB,CAAC","sourcesContent":["import { type Static, Type } from \"typebox\";\nimport { Compile } from \"typebox/compile\";\n\nexport const LogLevelSchema = Type.Union([\n\tType.Literal(\"debug\"),\n\tType.Literal(\"info\"),\n\tType.Literal(\"notice\"),\n\tType.Literal(\"warning\"),\n\tType.Literal(\"error\"),\n\tType.Literal(\"critical\"),\n\tType.Literal(\"alert\"),\n\tType.Literal(\"emergency\"),\n]);\n\nconst OAuthSchema = Type.Object(\n\t{\n\t\tclientId: Type.Optional(Type.String()),\n\t\tcallbackPort: Type.Optional(Type.Integer({ minimum: 0, maximum: 65_535 })),\n\t\tscopes: Type.Optional(Type.Array(Type.String())),\n\t\tclientMetadataUrl: Type.Optional(Type.String()),\n\t\tflow: Type.Optional(Type.Union([Type.Literal(\"code\"), Type.Literal(\"client_credentials\")])),\n\t},\n\t{ additionalProperties: false },\n);\n\nexport const ServerSchema = Type.Object(\n\t{\n\t\ttype: Type.Optional(Type.Union([Type.Literal(\"stdio\"), Type.Literal(\"http\")])),\n\t\turl: Type.Optional(Type.String()),\n\t\tcommand: Type.Optional(Type.String()),\n\t\targs: Type.Optional(Type.Array(Type.String())),\n\t\tenv: Type.Optional(Type.Record(Type.String(), Type.String())),\n\t\tcwd: Type.Optional(Type.String()),\n\t\theaders: Type.Optional(Type.Record(Type.String(), Type.String())),\n\t\tauth: Type.Optional(Type.Union([Type.Literal(\"bearer\"), Type.Literal(\"oauth\"), Type.Literal(false)])),\n\t\tbearerTokenEnv: Type.Optional(Type.String()),\n\t\toauth: Type.Optional(OAuthSchema),\n\t\tenabled: Type.Optional(Type.Boolean()),\n\t\tlifecycle: Type.Optional(Type.Union([Type.Literal(\"lazy\"), Type.Literal(\"eager\"), Type.Literal(\"keep-alive\")])),\n\t\tidleTimeoutMin: Type.Optional(Type.Number()),\n\t\trequestTimeoutMs: Type.Optional(Type.Number()),\n\t\tconnectTimeoutMs: Type.Optional(Type.Number()),\n\t\tincludeTools: Type.Optional(Type.Array(Type.String())),\n\t\texcludeTools: Type.Optional(Type.Array(Type.String())),\n\t\tdirectTools: Type.Optional(Type.Union([Type.Boolean(), Type.Array(Type.String())])),\n\t\texposure: Type.Optional(\n\t\t\tType.Union([Type.Literal(\"auto\"), Type.Literal(\"direct\"), Type.Literal(\"search\"), Type.Literal(\"proxy\")]),\n\t\t),\n\t\tlogLevel: Type.Optional(LogLevelSchema),\n\t},\n\t{ additionalProperties: false },\n);\n\nconst SettingsSchema = Type.Object(\n\t{\n\t\ttoolPrefix: Type.Optional(Type.String()),\n\t\tsearchThreshold: Type.Optional(Type.Number()),\n\t\toutputGuard: Type.Optional(\n\t\t\tType.Object(\n\t\t\t\t{\n\t\t\t\t\tmaxBytes: Type.Optional(Type.Number()),\n\t\t\t\t\tmaxLines: Type.Optional(Type.Number()),\n\t\t\t\t\tmaxTokens: Type.Optional(Type.Number()),\n\t\t\t\t},\n\t\t\t\t{ additionalProperties: false },\n\t\t\t),\n\t\t),\n\t\timportConfigs: Type.Optional(Type.Array(Type.Literal(\"claude\"))),\n\t\toauthCallbackUrl: Type.Optional(Type.String()),\n\t\tstubSwap: Type.Optional(Type.Boolean()),\n\t\tnativeToolSearch: Type.Optional(Type.Union([Type.Literal(\"auto\"), Type.Boolean()])),\n\t},\n\t{ additionalProperties: false },\n);\n\nexport const ConfigSchema = Type.Object(\n\t{\n\t\tsettings: Type.Optional(SettingsSchema),\n\t\tmcpServers: Type.Optional(Type.Record(Type.String(), ServerSchema)),\n\t},\n\t{ additionalProperties: false },\n);\n\nexport type RawConfig = Static<typeof ConfigSchema>;\nexport type McpServerConfig = Static<typeof ServerSchema> & {\n\ttype: \"stdio\" | \"http\";\n\targs: string[];\n\tenabled: boolean;\n\tlifecycle: \"lazy\" | \"eager\" | \"keep-alive\";\n\tconnectTimeoutMs: number;\n\trequestTimeoutMs: number;\n\tidleTimeoutMin: number;\n\texposure: \"auto\" | \"direct\" | \"search\" | \"proxy\";\n\tlogLevel: Static<typeof LogLevelSchema>;\n};\nexport type McpSettings = Required<Pick<Static<typeof SettingsSchema>, \"toolPrefix\">> &\n\tOmit<Static<typeof SettingsSchema>, \"toolPrefix\">;\nexport type McpServerSource = \"global\" | \"claude\" | \"project\" | \"skill\";\nexport type McpServerState = \"enabled\" | \"disabled\" | \"untrusted\";\n\nexport interface ResolvedMcpServer {\n\tname: string;\n\tsource: McpServerSource;\n\tsourcePath: string;\n\tstate: McpServerState;\n\ttransport?: \"stdio\" | \"http\";\n\tconfigHash?: string;\n\tconfig?: McpServerConfig;\n}\n\nexport interface ResolvedMcpConfig {\n\tsettings: McpSettings;\n\tservers: Record<string, ResolvedMcpServer>;\n\tdiagnostics: string[];\n}\n\nexport interface LoadMcpConfigOptions {\n\tcwd: string;\n\tagentDir?: string;\n\tenv?: Record<string, string | undefined>;\n\tprojectTrusted: boolean;\n}\n\nexport function getServerEndpointValidationError(config: RawConfig): string | undefined {\n\tfor (const [name, server] of Object.entries(config.mcpServers ?? {})) {\n\t\tif (server.enabled === false) continue;\n\t\tconst type = server.type ?? (server.url ? \"http\" : \"stdio\");\n\t\tif (type === \"stdio\" && (server.command === undefined || server.command.trim().length === 0)) {\n\t\t\treturn `mcpServers.${name}.command: Required for enabled stdio server`;\n\t\t}\n\t\tif (type === \"http\" && (server.url === undefined || server.url.trim().length === 0)) {\n\t\t\treturn `mcpServers.${name}.url: Required for enabled http server`;\n\t\t}\n\t}\n\treturn undefined;\n}\n\nexport const validateConfig = Compile(ConfigSchema);\nexport const defaultSettings: McpSettings = {\n\toutputGuard: { maxBytes: 50 * 1024, maxLines: 2000 },\n\tsearchThreshold: 10,\n\ttoolPrefix: \"mcp\",\n};\n"]}
|
|
1
|
+
{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CAAC,CAAC,CAAC,CAAC,CAAC;QACxD,MAAM,IAAI,GACT,KAAK,CAAC,YAAY;aAChB,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;aAClB,KAAK,CAAC,GAAG,CAAC;aACV,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;aACrD,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC;QACpB,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,KAAK,eAAe,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC;QACrF,OAAO,mCAAmC,IAAI,MAAM,IAAI,KAAK,OAAO,EAAE,CAAC;IACxE,CAAC;IACD,MAAM,MAAM,GAAG,GAA2B,CAAC;IAC3C,MAAM,aAAa,GAAG,gCAAgC,CAAC,EAAE,UAAU,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;IAC3F,IAAI,aAAa,EAAE,CAAC;QACnB,OAAO,mCAAmC,IAAI,MAAM,aAAa,EAAE,CAAC;IACrE,CAAC;IACD,OAAO,IAAI,CAAC;AACb,CAAC;AAED,MAAM,CAAC,MAAM,eAAe,GAAgB;IAC3C,WAAW,EAAE,EAAE,QAAQ,EAAE,EAAE,GAAG,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE;IACpD,eAAe,EAAE,EAAE;IACnB,UAAU,EAAE,KAAK;CACjB,CAAC","sourcesContent":["import { type Static, Type } from \"typebox\";\nimport { Compile } from \"typebox/compile\";\n\nexport const LogLevelSchema = Type.Union([\n\tType.Literal(\"debug\"),\n\tType.Literal(\"info\"),\n\tType.Literal(\"notice\"),\n\tType.Literal(\"warning\"),\n\tType.Literal(\"error\"),\n\tType.Literal(\"critical\"),\n\tType.Literal(\"alert\"),\n\tType.Literal(\"emergency\"),\n]);\n\nconst OAuthSchema = Type.Object(\n\t{\n\t\tclientId: Type.Optional(Type.String()),\n\t\tcallbackPort: Type.Optional(Type.Integer({ minimum: 0, maximum: 65_535 })),\n\t\tscopes: Type.Optional(Type.Array(Type.String())),\n\t\tclientMetadataUrl: Type.Optional(Type.String()),\n\t\tflow: Type.Optional(Type.Union([Type.Literal(\"code\"), Type.Literal(\"client_credentials\")])),\n\t},\n\t{ additionalProperties: false },\n);\n\nexport const ServerSchema = Type.Object(\n\t{\n\t\ttype: Type.Optional(Type.Union([Type.Literal(\"stdio\"), Type.Literal(\"http\")])),\n\t\turl: Type.Optional(Type.String()),\n\t\tcommand: Type.Optional(Type.String()),\n\t\targs: Type.Optional(Type.Array(Type.String())),\n\t\tenv: Type.Optional(Type.Record(Type.String(), Type.String())),\n\t\tcwd: Type.Optional(Type.String()),\n\t\theaders: Type.Optional(Type.Record(Type.String(), Type.String())),\n\t\tauth: Type.Optional(Type.Union([Type.Literal(\"bearer\"), Type.Literal(\"oauth\"), Type.Literal(false)])),\n\t\tbearerTokenEnv: Type.Optional(Type.String()),\n\t\toauth: Type.Optional(OAuthSchema),\n\t\tenabled: Type.Optional(Type.Boolean()),\n\t\tlifecycle: Type.Optional(Type.Union([Type.Literal(\"lazy\"), Type.Literal(\"eager\"), Type.Literal(\"keep-alive\")])),\n\t\tidleTimeoutMin: Type.Optional(Type.Number()),\n\t\trequestTimeoutMs: Type.Optional(Type.Number()),\n\t\tconnectTimeoutMs: Type.Optional(Type.Number()),\n\t\tincludeTools: Type.Optional(Type.Array(Type.String())),\n\t\texcludeTools: Type.Optional(Type.Array(Type.String())),\n\t\tdirectTools: Type.Optional(Type.Union([Type.Boolean(), Type.Array(Type.String())])),\n\t\texposure: Type.Optional(\n\t\t\tType.Union([Type.Literal(\"auto\"), Type.Literal(\"direct\"), Type.Literal(\"search\"), Type.Literal(\"proxy\")]),\n\t\t),\n\t\tlogLevel: Type.Optional(LogLevelSchema),\n\t},\n\t{ additionalProperties: false },\n);\n\nconst SettingsSchema = Type.Object(\n\t{\n\t\ttoolPrefix: Type.Optional(Type.String()),\n\t\tsearchThreshold: Type.Optional(Type.Number()),\n\t\toutputGuard: Type.Optional(\n\t\t\tType.Object(\n\t\t\t\t{\n\t\t\t\t\tmaxBytes: Type.Optional(Type.Number()),\n\t\t\t\t\tmaxLines: Type.Optional(Type.Number()),\n\t\t\t\t\tmaxTokens: Type.Optional(Type.Number()),\n\t\t\t\t},\n\t\t\t\t{ additionalProperties: false },\n\t\t\t),\n\t\t),\n\t\timportConfigs: Type.Optional(Type.Array(Type.Literal(\"claude\"))),\n\t\toauthCallbackUrl: Type.Optional(Type.String()),\n\t\tstubSwap: Type.Optional(Type.Boolean()),\n\t\tnativeToolSearch: Type.Optional(Type.Union([Type.Literal(\"auto\"), Type.Boolean()])),\n\t},\n\t{ additionalProperties: false },\n);\n\nexport const ConfigSchema = Type.Object(\n\t{\n\t\tsettings: Type.Optional(SettingsSchema),\n\t\tmcpServers: Type.Optional(Type.Record(Type.String(), ServerSchema)),\n\t},\n\t{ additionalProperties: false },\n);\n\nexport type RawConfig = Static<typeof ConfigSchema>;\nexport type McpServerConfig = Static<typeof ServerSchema> & {\n\ttype: \"stdio\" | \"http\";\n\targs: string[];\n\tenabled: boolean;\n\tlifecycle: \"lazy\" | \"eager\" | \"keep-alive\";\n\tconnectTimeoutMs: number;\n\trequestTimeoutMs: number;\n\tidleTimeoutMin: number;\n\texposure: \"auto\" | \"direct\" | \"search\" | \"proxy\";\n\tlogLevel: Static<typeof LogLevelSchema>;\n};\n/** Public raw type for extension-declared MCP servers. */\nexport type McpServerDeclaration = Static<typeof ServerSchema>;\nexport type McpSettings = Required<Pick<Static<typeof SettingsSchema>, \"toolPrefix\">> &\n\tOmit<Static<typeof SettingsSchema>, \"toolPrefix\">;\nexport type McpServerSource = \"global\" | \"claude\" | \"project\" | \"skill\" | \"extension\";\nexport type McpServerState = \"enabled\" | \"disabled\" | \"untrusted\";\n\nexport interface ResolvedMcpServer {\n\tname: string;\n\tsource: McpServerSource;\n\tsourcePath: string;\n\tstate: McpServerState;\n\ttransport?: \"stdio\" | \"http\";\n\tconfigHash?: string;\n\tconfig?: McpServerConfig;\n}\n\nexport interface ResolvedMcpConfig {\n\tsettings: McpSettings;\n\tservers: Record<string, ResolvedMcpServer>;\n\tdiagnostics: string[];\n}\n\nexport interface LoadMcpConfigOptions {\n\tcwd: string;\n\tagentDir?: string;\n\tenv?: Record<string, string | undefined>;\n\tprojectTrusted: boolean;\n}\n\nexport function getServerEndpointValidationError(config: RawConfig): string | undefined {\n\tfor (const [name, server] of Object.entries(config.mcpServers ?? {})) {\n\t\tif (server.enabled === false) continue;\n\t\tconst type = server.type ?? (server.url ? \"http\" : \"stdio\");\n\t\tif (type === \"stdio\" && (server.command === undefined || server.command.trim().length === 0)) {\n\t\t\treturn `mcpServers.${name}.command: Required for enabled stdio server`;\n\t\t}\n\t\tif (type === \"http\" && (server.url === undefined || server.url.trim().length === 0)) {\n\t\t\treturn `mcpServers.${name}.url: Required for enabled http server`;\n\t\t}\n\t}\n\treturn undefined;\n}\n\nexport const validateConfig = Compile(ConfigSchema);\nconst validateServer = Compile(ServerSchema);\n\n/**\n * Validate a single extension-declared MCP server.\n * Returns a descriptive error string, or null when valid.\n */\nexport function validateMcpServerDeclaration(name: string, raw: unknown): string | null {\n\tif (!validateServer.Check(raw)) {\n\t\tconst error = Array.from(validateServer.Errors(raw))[0];\n\t\tconst path =\n\t\t\terror.instancePath\n\t\t\t\t.replace(/^\\//, \"\")\n\t\t\t\t.split(\"/\")\n\t\t\t\t.map((p) => p.replace(/~1/g, \"/\").replace(/~0/g, \"~\"))\n\t\t\t\t.join(\".\") || \"$\";\n\t\tconst message = error.message === \"must be array\" ? \"Expected array\" : error.message;\n\t\treturn `Invalid MCP server declaration \"${name}\": ${path}: ${message}`;\n\t}\n\tconst server = raw as McpServerDeclaration;\n\tconst endpointError = getServerEndpointValidationError({ mcpServers: { [name]: server } });\n\tif (endpointError) {\n\t\treturn `Invalid MCP server declaration \"${name}\": ${endpointError}`;\n\t}\n\treturn null;\n}\n\nexport const defaultSettings: McpSettings = {\n\toutputGuard: { maxBytes: 50 * 1024, maxLines: 2000 },\n\tsearchThreshold: 10,\n\ttoolPrefix: \"mcp\",\n};\n"]}
|
|
@@ -1,9 +1,22 @@
|
|
|
1
|
+
import type { RegisteredMcpServerDeclaration } from "../../types.ts";
|
|
1
2
|
import { type LoadMcpConfigOptions, type RawConfig, type ResolvedMcpConfig, type ResolvedMcpServer } from "./config-schema.ts";
|
|
2
3
|
export declare class McpConfigValidationError extends Error {
|
|
3
4
|
constructor(message: string);
|
|
4
5
|
}
|
|
5
6
|
export declare function loadMcpConfig(options: LoadMcpConfigOptions): ResolvedMcpConfig;
|
|
6
7
|
export declare function visitSpawnableMcpServers(config: ResolvedMcpConfig, visit: (name: string, server: ResolvedMcpServer) => void): void;
|
|
8
|
+
/**
|
|
9
|
+
* Resolve an extension-declared MCP server. Preserves the declared exposure,
|
|
10
|
+
* directTools, filters, lifecycle, and enabled state. A stdio declaration
|
|
11
|
+
* without an explicit `cwd` defaults to the extension's registration cwd.
|
|
12
|
+
*/
|
|
13
|
+
export declare function resolveExtensionMcpServer(name: string, raw: NonNullable<RawConfig["mcpServers"]>[string], sourcePath: string, registrationCwd: string): ResolvedMcpServer;
|
|
14
|
+
/**
|
|
15
|
+
* Merge extension-declared MCP servers into a resolved config. Trusted file
|
|
16
|
+
* sources (global/claude/project) win, including disabled entries. An
|
|
17
|
+
* extension entry replaces an untrusted placeholder and records a diagnostic.
|
|
18
|
+
*/
|
|
19
|
+
export declare function mergeExtensionMcpServers(result: ResolvedMcpConfig, declarations: readonly RegisteredMcpServerDeclaration[]): void;
|
|
7
20
|
/**
|
|
8
21
|
* Resolve a skill-declared MCP server (mcp.json sidecar or SKILL.md
|
|
9
22
|
* frontmatter). Exposure is forced to search with no directTools so the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/mcp/config.ts"],"names":[],"mappings":"AAKA,OAAO,EAGN,KAAK,oBAAoB,EAIzB,KAAK,SAAS,EACd,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EAEtB,MAAM,oBAAoB,CAAC;AAE5B,qBAAa,wBAAyB,SAAQ,KAAK;IAClD,YAAY,OAAO,EAAE,MAAM,EAG1B;CACD;AASD,wBAAgB,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,iBAAiB,CAqD9E;AAED,wBAAgB,wBAAwB,CACvC,MAAM,EAAE,iBAAiB,EACzB,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,KAAK,IAAI,GACtD,IAAI,CAMN;AA6GD;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACpC,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,WAAW,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,EACjD,UAAU,EAAE,MAAM,GAChB,iBAAiB,CAWnB"}
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/mcp/config.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,EAGN,KAAK,oBAAoB,EAIzB,KAAK,SAAS,EACd,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EAEtB,MAAM,oBAAoB,CAAC;AAE5B,qBAAa,wBAAyB,SAAQ,KAAK;IAClD,YAAY,OAAO,EAAE,MAAM,EAG1B;CACD;AASD,wBAAgB,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,iBAAiB,CAqD9E;AAED,wBAAgB,wBAAwB,CACvC,MAAM,EAAE,iBAAiB,EACzB,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,KAAK,IAAI,GACtD,IAAI,CAMN;AA6GD;;;;GAIG;AACH,wBAAgB,yBAAyB,CACxC,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,WAAW,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,EACjD,UAAU,EAAE,MAAM,EAClB,eAAe,EAAE,MAAM,GACrB,iBAAiB,CAYnB;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CACvC,MAAM,EAAE,iBAAiB,EACzB,YAAY,EAAE,SAAS,8BAA8B,EAAE,GACrD,IAAI,CAqBN;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACpC,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,WAAW,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,EACjD,UAAU,EAAE,MAAM,GAChB,iBAAiB,CAWnB"}
|
|
@@ -151,6 +151,42 @@ function readServerNames(raw) {
|
|
|
151
151
|
return [];
|
|
152
152
|
return Object.keys(servers);
|
|
153
153
|
}
|
|
154
|
+
/**
|
|
155
|
+
* Resolve an extension-declared MCP server. Preserves the declared exposure,
|
|
156
|
+
* directTools, filters, lifecycle, and enabled state. A stdio declaration
|
|
157
|
+
* without an explicit `cwd` defaults to the extension's registration cwd.
|
|
158
|
+
*/
|
|
159
|
+
export function resolveExtensionMcpServer(name, raw, sourcePath, registrationCwd) {
|
|
160
|
+
const withCwd = { ...raw, cwd: raw.cwd ?? registrationCwd };
|
|
161
|
+
const config = normalizeServer(withCwd);
|
|
162
|
+
return {
|
|
163
|
+
config,
|
|
164
|
+
configHash: hashConfig(config),
|
|
165
|
+
name,
|
|
166
|
+
source: "extension",
|
|
167
|
+
sourcePath,
|
|
168
|
+
state: config.enabled ? "enabled" : "disabled",
|
|
169
|
+
transport: config.type,
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Merge extension-declared MCP servers into a resolved config. Trusted file
|
|
174
|
+
* sources (global/claude/project) win, including disabled entries. An
|
|
175
|
+
* extension entry replaces an untrusted placeholder and records a diagnostic.
|
|
176
|
+
*/
|
|
177
|
+
export function mergeExtensionMcpServers(result, declarations) {
|
|
178
|
+
for (const decl of declarations) {
|
|
179
|
+
const existing = result.servers[decl.name];
|
|
180
|
+
if (existing !== undefined && existing.state !== "untrusted") {
|
|
181
|
+
result.diagnostics.push(`Extension MCP server '${decl.name}' from ${decl.extensionPath} skipped; ${existing.source} config at ${existing.sourcePath} wins.`);
|
|
182
|
+
continue;
|
|
183
|
+
}
|
|
184
|
+
if (existing !== undefined) {
|
|
185
|
+
result.diagnostics.push(`Extension MCP server '${decl.name}' from ${decl.extensionPath} replaces untrusted ${existing.source} placeholder from ${existing.sourcePath}.`);
|
|
186
|
+
}
|
|
187
|
+
result.servers[decl.name] = resolveExtensionMcpServer(decl.name, decl.config, decl.extensionPath, decl.registrationCwd);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
154
190
|
/**
|
|
155
191
|
* Resolve a skill-declared MCP server (mcp.json sidecar or SKILL.md
|
|
156
192
|
* frontmatter). Exposure is forced to search with no directTools so the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/mcp/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EACN,eAAe,EACf,gCAAgC,EAQhC,cAAc,GACd,MAAM,oBAAoB,CAAC;AAE5B,MAAM,OAAO,wBAAyB,SAAQ,KAAK;IAClD,YAAY,OAAe;QAC1B,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;IACxC,CAAC;CACD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CAAC,MAAM,EAAE,IAAY,EAAE,SAAiB,EAAE,aAAiC,EAAE,EAAE;QAC9E,OAAO,GAAG,CAAC,IAAI,CAAC,IAAI,aAAa,IAAI,EAAE,CAAC;IACzC,CAAC,CACD,CAAC;AACH,CAAC;AAED,SAAS,UAAU,CAAC,MAAuB;IAC1C,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC3E,CAAC;AAED,SAAS,eAAe,CAAC,KAAc;IACtC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,KAAK,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;IAC7E,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QACjD,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;aAC3B,IAAI,EAAE;aACN,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,eAAe,CAAE,KAAiC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;aAClG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;IAChB,CAAC;IACD,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AAC9B,CAAC","sourcesContent":["import { createHash } from \"node:crypto\";\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport type { TLocalizedValidationError } from \"typebox/error\";\nimport { CONFIG_DIR_NAME, getAgentDir } from \"../../../../config.ts\";\nimport {\n\tdefaultSettings,\n\tgetServerEndpointValidationError,\n\ttype LoadMcpConfigOptions,\n\ttype McpServerConfig,\n\ttype McpServerSource,\n\ttype McpSettings,\n\ttype RawConfig,\n\ttype ResolvedMcpConfig,\n\ttype ResolvedMcpServer,\n\tvalidateConfig,\n} from \"./config-schema.ts\";\n\nexport class McpConfigValidationError extends Error {\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"McpConfigValidationError\";\n\t}\n}\n\ninterface JsonReadResult {\n\traw: unknown;\n\tdiagnostic?: string;\n}\n\nconst trustedEnv = process.env as Record<string, string | undefined>;\n\nexport function loadMcpConfig(options: LoadMcpConfigOptions): ResolvedMcpConfig {\n\tconst agentDir = options.agentDir ?? getAgentDir();\n\tconst env = options.env ?? trustedEnv;\n\tconst globalPath = join(agentDir, \"mcp.json\");\n\tconst projectPath = join(options.cwd, CONFIG_DIR_NAME, \"mcp.json\");\n\tconst claudePath = join(options.cwd, \".mcp.json\");\n\tconst globalConfig = readTrustedConfig(globalPath, env);\n\tconst projectRead = readConfigJson(projectPath, options.projectTrusted);\n\tconst projectRaw = projectRead.raw;\n\tconst preliminary = mergeConfigs(\n\t\tglobalConfig,\n\t\toptions.projectTrusted ? validateRaw(projectRaw, projectPath) : undefined,\n\t);\n\tconst shouldImportClaude = preliminary.settings?.importConfigs?.includes(\"claude\") === true;\n\tconst claudeRead = shouldImportClaude ? readConfigJson(claudePath, options.projectTrusted) : { raw: undefined };\n\tconst claudeRaw = claudeRead.raw;\n\tconst sources = [\n\t\t{ config: globalConfig, path: globalPath, source: \"global\" as const, trusted: true },\n\t\t{\n\t\t\tconfig:\n\t\t\t\toptions.projectTrusted && shouldImportClaude ? readTrustedConfig(claudePath, env, claudeRaw) : undefined,\n\t\t\tpath: claudePath,\n\t\t\tsource: \"claude\" as const,\n\t\t\ttrusted: options.projectTrusted,\n\t\t},\n\t\t{\n\t\t\tconfig: options.projectTrusted ? readTrustedConfig(projectPath, env, projectRaw) : undefined,\n\t\t\tpath: projectPath,\n\t\t\tsource: \"project\" as const,\n\t\t\ttrusted: options.projectTrusted,\n\t\t},\n\t];\n\tconst merged = mergeConfigs(...sources.map((item) => item.config));\n\tconst result: ResolvedMcpConfig = { diagnostics: [], servers: {}, settings: normalizeSettings(merged.settings) };\n\tfor (const diagnostic of [projectRead.diagnostic, claudeRead.diagnostic]) {\n\t\tif (diagnostic) result.diagnostics.push(diagnostic);\n\t}\n\n\tfor (const item of sources) {\n\t\tif (item.trusted && item.config?.mcpServers) {\n\t\t\taddTrustedServers(result, item.config.mcpServers, item.source, item.path);\n\t\t\tcontinue;\n\t\t}\n\t\tif (!item.trusted) {\n\t\t\taddUntrustedServers(\n\t\t\t\tresult,\n\t\t\t\treadServerNames(item.source === \"claude\" ? claudeRaw : projectRaw),\n\t\t\t\titem.source,\n\t\t\t\titem.path,\n\t\t\t);\n\t\t}\n\t}\n\treturn result;\n}\n\nexport function visitSpawnableMcpServers(\n\tconfig: ResolvedMcpConfig,\n\tvisit: (name: string, server: ResolvedMcpServer) => void,\n): void {\n\tfor (const [name, server] of Object.entries(config.servers)) {\n\t\tif (server.state === \"enabled\") {\n\t\t\tvisit(name, server);\n\t\t}\n\t}\n}\n\nfunction readTrustedConfig(\n\tpath: string,\n\tenv: Record<string, string | undefined>,\n\traw = readConfigJson(path, true).raw,\n): RawConfig | undefined {\n\tconst config = interpolateConfig(validateRaw(raw, path), env);\n\tconst endpointError = config ? getServerEndpointValidationError(config) : undefined;\n\tif (endpointError) throw new McpConfigValidationError(`Invalid MCP config at ${endpointError}`);\n\treturn config;\n}\n\nfunction readConfigJson(path: string, trusted: boolean): JsonReadResult {\n\tif (!existsSync(path)) return { raw: undefined };\n\ttry {\n\t\tconst raw: unknown = JSON.parse(readFileSync(path, \"utf-8\"));\n\t\treturn { raw };\n\t} catch (error) {\n\t\tconst reason = error instanceof Error ? error.message : String(error);\n\t\tif (trusted) throw new McpConfigValidationError(`Invalid MCP config at ${path}: ${reason}`);\n\t\treturn { raw: undefined, diagnostic: `Blocked untrusted MCP config at ${path}: invalid JSON (${reason})` };\n\t}\n}\n\nfunction validateRaw(raw: unknown, _path: string): RawConfig | undefined {\n\tif (raw === undefined) return undefined;\n\tif (validateConfig.Check(raw)) {\n\t\tconst config = raw as RawConfig;\n\t\tconst endpointError = getServerEndpointValidationError(config);\n\t\tif (endpointError) throw new McpConfigValidationError(`Invalid MCP config at ${endpointError}`);\n\t\treturn config;\n\t}\n\tconst error = Array.from(validateConfig.Errors(raw))[0];\n\tthrow new McpConfigValidationError(`Invalid MCP config at ${formatErrorPath(error)}: ${formatErrorMessage(error)}`);\n}\n\nfunction formatErrorPath(error: TLocalizedValidationError): string {\n\tconst trimmed = error.instancePath.replace(/^\\//, \"\");\n\treturn trimmed.length === 0 ? \"$\" : trimmed.split(\"/\").map(decodePathPart).join(\".\");\n}\n\nfunction decodePathPart(part: string): string {\n\treturn part.replace(/~1/g, \"/\").replace(/~0/g, \"~\");\n}\n\nfunction formatErrorMessage(error: TLocalizedValidationError): string {\n\treturn error.message === \"must be array\" ? \"Expected array\" : error.message;\n}\n\nfunction mergeConfigs(...configs: (RawConfig | undefined)[]): RawConfig {\n\tconst merged: RawConfig = {};\n\tfor (const config of configs) {\n\t\tif (!config) continue;\n\t\tmerged.settings = { ...(merged.settings ?? {}), ...(config.settings ?? {}) };\n\t\tmerged.mcpServers = { ...(merged.mcpServers ?? {}), ...(config.mcpServers ?? {}) };\n\t}\n\treturn merged;\n}\n\nfunction normalizeSettings(settings: RawConfig[\"settings\"]): McpSettings {\n\treturn { ...defaultSettings, ...settings };\n}\n\nfunction addTrustedServers(\n\tresult: ResolvedMcpConfig,\n\tservers: NonNullable<RawConfig[\"mcpServers\"]>,\n\tsource: McpServerSource,\n\tsourcePath: string,\n): void {\n\tfor (const [name, server] of Object.entries(servers)) {\n\t\tconst config = normalizeServer(server);\n\t\tresult.servers[name] = {\n\t\t\tconfig,\n\t\t\tconfigHash: hashConfig(config),\n\t\t\tname,\n\t\t\tsource,\n\t\t\tsourcePath,\n\t\t\tstate: config.enabled ? \"enabled\" : \"disabled\",\n\t\t\ttransport: config.type,\n\t\t};\n\t}\n}\n\nfunction addUntrustedServers(\n\tresult: ResolvedMcpConfig,\n\tnames: readonly string[],\n\tsource: McpServerSource,\n\tsourcePath: string,\n): void {\n\tfor (const name of names) {\n\t\tconst existing = result.servers[name];\n\t\tif (existing && existing.state !== \"untrusted\") {\n\t\t\tresult.diagnostics.push(\n\t\t\t\t`Blocked untrusted ${source} MCP server '${name}' from shadowing trusted ${existing.source} server.`,\n\t\t\t);\n\t\t\tcontinue;\n\t\t}\n\t\tresult.servers[name] = { name, source, sourcePath, state: \"untrusted\" };\n\t}\n}\n\nfunction readServerNames(raw: unknown): string[] {\n\tif (typeof raw !== \"object\" || raw === null || Array.isArray(raw)) return [];\n\tconst servers = (raw as { mcpServers?: unknown }).mcpServers;\n\tif (typeof servers !== \"object\" || servers === null || Array.isArray(servers)) return [];\n\treturn Object.keys(servers);\n}\n\n/**\n * Resolve a skill-declared MCP server (mcp.json sidecar or SKILL.md\n * frontmatter). Exposure is forced to search with no directTools so the\n * catalog registers with ZERO active tools until the owning skill loads\n * (0 pre-load payload tokens); lifecycle stays lazy.\n */\nexport function resolveSkillMcpServer(\n\tname: string,\n\traw: NonNullable<RawConfig[\"mcpServers\"]>[string],\n\tsourcePath: string,\n): ResolvedMcpServer {\n\tconst config = { ...normalizeServer(raw), directTools: [], exposure: \"search\" as const };\n\treturn {\n\t\tconfig,\n\t\tconfigHash: hashConfig(config),\n\t\tname,\n\t\tsource: \"skill\",\n\t\tsourcePath,\n\t\tstate: config.enabled ? \"enabled\" : \"disabled\",\n\t\ttransport: config.type,\n\t};\n}\n\nfunction normalizeServer(server: NonNullable<RawConfig[\"mcpServers\"]>[string]): McpServerConfig {\n\tconst type = server.type ?? (server.url ? \"http\" : \"stdio\");\n\treturn {\n\t\targs: server.args ?? [],\n\t\tconnectTimeoutMs: server.connectTimeoutMs ?? 15_000,\n\t\tenabled: server.enabled ?? true,\n\t\texposure: server.exposure ?? \"auto\",\n\t\tidleTimeoutMin: server.idleTimeoutMin ?? 10,\n\t\tlifecycle: server.lifecycle ?? \"lazy\",\n\t\tlogLevel: server.logLevel ?? \"info\",\n\t\trequestTimeoutMs: server.requestTimeoutMs ?? 30_000,\n\t\ttype,\n\t\t...server,\n\t};\n}\n\nfunction interpolateConfig(\n\tconfig: RawConfig | undefined,\n\tenv: Record<string, string | undefined>,\n): RawConfig | undefined {\n\treturn interpolateValue(config, \"mcp\", env) as RawConfig | undefined;\n}\n\nfunction interpolateValue(value: unknown, path: string, env: Record<string, string | undefined>): unknown {\n\tif (typeof value === \"string\") return interpolateString(value, path, env);\n\tif (Array.isArray(value)) return value.map((item, index) => interpolateValue(item, `${path}.${index}`, env));\n\tif (typeof value === \"object\" && value !== null) {\n\t\tconst out: Record<string, unknown> = {};\n\t\tfor (const [key, item] of Object.entries(value)) out[key] = interpolateValue(item, `${path}.${key}`, env);\n\t\treturn out;\n\t}\n\treturn value;\n}\n\nfunction interpolateString(value: string, path: string, env: Record<string, string | undefined>): string {\n\tif (value.trimStart().startsWith(\"!\") || value.includes(\"$(\")) {\n\t\tconst displayPath = path.replace(/^mcp\\./, \"\");\n\t\tthrow new McpConfigValidationError(\n\t\t\t`MCP config interpolation rejected command substitution at ${displayPath}: config values may reference only environment variables for security; shell commands are never executed.`,\n\t\t);\n\t}\n\treturn value.replace(\n\t\t/\\$\\{([A-Za-z_][A-Za-z0-9_]*)(:-([^}]*))?\\}/g,\n\t\t(_match, name: string, _fallback: string, fallbackValue: string | undefined) => {\n\t\t\treturn env[name] ?? fallbackValue ?? \"\";\n\t\t},\n\t);\n}\n\nfunction hashConfig(config: McpServerConfig): string {\n\treturn createHash(\"sha256\").update(stableStringify(config)).digest(\"hex\");\n}\n\nfunction stableStringify(value: unknown): string {\n\tif (Array.isArray(value)) return `[${value.map(stableStringify).join(\",\")}]`;\n\tif (typeof value === \"object\" && value !== null) {\n\t\treturn `{${Object.keys(value)\n\t\t\t.sort()\n\t\t\t.map((key) => `${JSON.stringify(key)}:${stableStringify((value as Record<string, unknown>)[key])}`)\n\t\t\t.join(\",\")}}`;\n\t}\n\treturn JSON.stringify(value);\n}\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,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QACjD,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;aAC3B,IAAI,EAAE;aACN,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,eAAe,CAAE,KAAiC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;aAClG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;IAChB,CAAC;IACD,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AAC9B,CAAC","sourcesContent":["import { createHash } from \"node:crypto\";\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport type { TLocalizedValidationError } from \"typebox/error\";\nimport { CONFIG_DIR_NAME, getAgentDir } from \"../../../../config.ts\";\nimport type { RegisteredMcpServerDeclaration } from \"../../types.ts\";\nimport {\n\tdefaultSettings,\n\tgetServerEndpointValidationError,\n\ttype LoadMcpConfigOptions,\n\ttype McpServerConfig,\n\ttype McpServerSource,\n\ttype McpSettings,\n\ttype RawConfig,\n\ttype ResolvedMcpConfig,\n\ttype ResolvedMcpServer,\n\tvalidateConfig,\n} from \"./config-schema.ts\";\n\nexport class McpConfigValidationError extends Error {\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"McpConfigValidationError\";\n\t}\n}\n\ninterface JsonReadResult {\n\traw: unknown;\n\tdiagnostic?: string;\n}\n\nconst trustedEnv = process.env as Record<string, string | undefined>;\n\nexport function loadMcpConfig(options: LoadMcpConfigOptions): ResolvedMcpConfig {\n\tconst agentDir = options.agentDir ?? getAgentDir();\n\tconst env = options.env ?? trustedEnv;\n\tconst globalPath = join(agentDir, \"mcp.json\");\n\tconst projectPath = join(options.cwd, CONFIG_DIR_NAME, \"mcp.json\");\n\tconst claudePath = join(options.cwd, \".mcp.json\");\n\tconst globalConfig = readTrustedConfig(globalPath, env);\n\tconst projectRead = readConfigJson(projectPath, options.projectTrusted);\n\tconst projectRaw = projectRead.raw;\n\tconst preliminary = mergeConfigs(\n\t\tglobalConfig,\n\t\toptions.projectTrusted ? validateRaw(projectRaw, projectPath) : undefined,\n\t);\n\tconst shouldImportClaude = preliminary.settings?.importConfigs?.includes(\"claude\") === true;\n\tconst claudeRead = shouldImportClaude ? readConfigJson(claudePath, options.projectTrusted) : { raw: undefined };\n\tconst claudeRaw = claudeRead.raw;\n\tconst sources = [\n\t\t{ config: globalConfig, path: globalPath, source: \"global\" as const, trusted: true },\n\t\t{\n\t\t\tconfig:\n\t\t\t\toptions.projectTrusted && shouldImportClaude ? readTrustedConfig(claudePath, env, claudeRaw) : undefined,\n\t\t\tpath: claudePath,\n\t\t\tsource: \"claude\" as const,\n\t\t\ttrusted: options.projectTrusted,\n\t\t},\n\t\t{\n\t\t\tconfig: options.projectTrusted ? readTrustedConfig(projectPath, env, projectRaw) : undefined,\n\t\t\tpath: projectPath,\n\t\t\tsource: \"project\" as const,\n\t\t\ttrusted: options.projectTrusted,\n\t\t},\n\t];\n\tconst merged = mergeConfigs(...sources.map((item) => item.config));\n\tconst result: ResolvedMcpConfig = { diagnostics: [], servers: {}, settings: normalizeSettings(merged.settings) };\n\tfor (const diagnostic of [projectRead.diagnostic, claudeRead.diagnostic]) {\n\t\tif (diagnostic) result.diagnostics.push(diagnostic);\n\t}\n\n\tfor (const item of sources) {\n\t\tif (item.trusted && item.config?.mcpServers) {\n\t\t\taddTrustedServers(result, item.config.mcpServers, item.source, item.path);\n\t\t\tcontinue;\n\t\t}\n\t\tif (!item.trusted) {\n\t\t\taddUntrustedServers(\n\t\t\t\tresult,\n\t\t\t\treadServerNames(item.source === \"claude\" ? claudeRaw : projectRaw),\n\t\t\t\titem.source,\n\t\t\t\titem.path,\n\t\t\t);\n\t\t}\n\t}\n\treturn result;\n}\n\nexport function visitSpawnableMcpServers(\n\tconfig: ResolvedMcpConfig,\n\tvisit: (name: string, server: ResolvedMcpServer) => void,\n): void {\n\tfor (const [name, server] of Object.entries(config.servers)) {\n\t\tif (server.state === \"enabled\") {\n\t\t\tvisit(name, server);\n\t\t}\n\t}\n}\n\nfunction readTrustedConfig(\n\tpath: string,\n\tenv: Record<string, string | undefined>,\n\traw = readConfigJson(path, true).raw,\n): RawConfig | undefined {\n\tconst config = interpolateConfig(validateRaw(raw, path), env);\n\tconst endpointError = config ? getServerEndpointValidationError(config) : undefined;\n\tif (endpointError) throw new McpConfigValidationError(`Invalid MCP config at ${endpointError}`);\n\treturn config;\n}\n\nfunction readConfigJson(path: string, trusted: boolean): JsonReadResult {\n\tif (!existsSync(path)) return { raw: undefined };\n\ttry {\n\t\tconst raw: unknown = JSON.parse(readFileSync(path, \"utf-8\"));\n\t\treturn { raw };\n\t} catch (error) {\n\t\tconst reason = error instanceof Error ? error.message : String(error);\n\t\tif (trusted) throw new McpConfigValidationError(`Invalid MCP config at ${path}: ${reason}`);\n\t\treturn { raw: undefined, diagnostic: `Blocked untrusted MCP config at ${path}: invalid JSON (${reason})` };\n\t}\n}\n\nfunction validateRaw(raw: unknown, _path: string): RawConfig | undefined {\n\tif (raw === undefined) return undefined;\n\tif (validateConfig.Check(raw)) {\n\t\tconst config = raw as RawConfig;\n\t\tconst endpointError = getServerEndpointValidationError(config);\n\t\tif (endpointError) throw new McpConfigValidationError(`Invalid MCP config at ${endpointError}`);\n\t\treturn config;\n\t}\n\tconst error = Array.from(validateConfig.Errors(raw))[0];\n\tthrow new McpConfigValidationError(`Invalid MCP config at ${formatErrorPath(error)}: ${formatErrorMessage(error)}`);\n}\n\nfunction formatErrorPath(error: TLocalizedValidationError): string {\n\tconst trimmed = error.instancePath.replace(/^\\//, \"\");\n\treturn trimmed.length === 0 ? \"$\" : trimmed.split(\"/\").map(decodePathPart).join(\".\");\n}\n\nfunction decodePathPart(part: string): string {\n\treturn part.replace(/~1/g, \"/\").replace(/~0/g, \"~\");\n}\n\nfunction formatErrorMessage(error: TLocalizedValidationError): string {\n\treturn error.message === \"must be array\" ? \"Expected array\" : error.message;\n}\n\nfunction mergeConfigs(...configs: (RawConfig | undefined)[]): RawConfig {\n\tconst merged: RawConfig = {};\n\tfor (const config of configs) {\n\t\tif (!config) continue;\n\t\tmerged.settings = { ...(merged.settings ?? {}), ...(config.settings ?? {}) };\n\t\tmerged.mcpServers = { ...(merged.mcpServers ?? {}), ...(config.mcpServers ?? {}) };\n\t}\n\treturn merged;\n}\n\nfunction normalizeSettings(settings: RawConfig[\"settings\"]): McpSettings {\n\treturn { ...defaultSettings, ...settings };\n}\n\nfunction addTrustedServers(\n\tresult: ResolvedMcpConfig,\n\tservers: NonNullable<RawConfig[\"mcpServers\"]>,\n\tsource: McpServerSource,\n\tsourcePath: string,\n): void {\n\tfor (const [name, server] of Object.entries(servers)) {\n\t\tconst config = normalizeServer(server);\n\t\tresult.servers[name] = {\n\t\t\tconfig,\n\t\t\tconfigHash: hashConfig(config),\n\t\t\tname,\n\t\t\tsource,\n\t\t\tsourcePath,\n\t\t\tstate: config.enabled ? \"enabled\" : \"disabled\",\n\t\t\ttransport: config.type,\n\t\t};\n\t}\n}\n\nfunction addUntrustedServers(\n\tresult: ResolvedMcpConfig,\n\tnames: readonly string[],\n\tsource: McpServerSource,\n\tsourcePath: string,\n): void {\n\tfor (const name of names) {\n\t\tconst existing = result.servers[name];\n\t\tif (existing && existing.state !== \"untrusted\") {\n\t\t\tresult.diagnostics.push(\n\t\t\t\t`Blocked untrusted ${source} MCP server '${name}' from shadowing trusted ${existing.source} server.`,\n\t\t\t);\n\t\t\tcontinue;\n\t\t}\n\t\tresult.servers[name] = { name, source, sourcePath, state: \"untrusted\" };\n\t}\n}\n\nfunction readServerNames(raw: unknown): string[] {\n\tif (typeof raw !== \"object\" || raw === null || Array.isArray(raw)) return [];\n\tconst servers = (raw as { mcpServers?: unknown }).mcpServers;\n\tif (typeof servers !== \"object\" || servers === null || Array.isArray(servers)) return [];\n\treturn Object.keys(servers);\n}\n\n/**\n * Resolve an extension-declared MCP server. Preserves the declared exposure,\n * directTools, filters, lifecycle, and enabled state. A stdio declaration\n * without an explicit `cwd` defaults to the extension's registration cwd.\n */\nexport function resolveExtensionMcpServer(\n\tname: string,\n\traw: NonNullable<RawConfig[\"mcpServers\"]>[string],\n\tsourcePath: string,\n\tregistrationCwd: string,\n): ResolvedMcpServer {\n\tconst withCwd = { ...raw, cwd: raw.cwd ?? registrationCwd };\n\tconst config = normalizeServer(withCwd);\n\treturn {\n\t\tconfig,\n\t\tconfigHash: hashConfig(config),\n\t\tname,\n\t\tsource: \"extension\",\n\t\tsourcePath,\n\t\tstate: config.enabled ? \"enabled\" : \"disabled\",\n\t\ttransport: config.type,\n\t};\n}\n\n/**\n * Merge extension-declared MCP servers into a resolved config. Trusted file\n * sources (global/claude/project) win, including disabled entries. An\n * extension entry replaces an untrusted placeholder and records a diagnostic.\n */\nexport function mergeExtensionMcpServers(\n\tresult: ResolvedMcpConfig,\n\tdeclarations: readonly RegisteredMcpServerDeclaration[],\n): void {\n\tfor (const decl of declarations) {\n\t\tconst existing = result.servers[decl.name];\n\t\tif (existing !== undefined && existing.state !== \"untrusted\") {\n\t\t\tresult.diagnostics.push(\n\t\t\t\t`Extension MCP server '${decl.name}' from ${decl.extensionPath} skipped; ${existing.source} config at ${existing.sourcePath} wins.`,\n\t\t\t);\n\t\t\tcontinue;\n\t\t}\n\t\tif (existing !== undefined) {\n\t\t\tresult.diagnostics.push(\n\t\t\t\t`Extension MCP server '${decl.name}' from ${decl.extensionPath} replaces untrusted ${existing.source} placeholder from ${existing.sourcePath}.`,\n\t\t\t);\n\t\t}\n\t\tresult.servers[decl.name] = resolveExtensionMcpServer(\n\t\t\tdecl.name,\n\t\t\tdecl.config,\n\t\t\tdecl.extensionPath,\n\t\t\tdecl.registrationCwd,\n\t\t);\n\t}\n}\n\n/**\n * Resolve a skill-declared MCP server (mcp.json sidecar or SKILL.md\n * frontmatter). Exposure is forced to search with no directTools so the\n * catalog registers with ZERO active tools until the owning skill loads\n * (0 pre-load payload tokens); lifecycle stays lazy.\n */\nexport function resolveSkillMcpServer(\n\tname: string,\n\traw: NonNullable<RawConfig[\"mcpServers\"]>[string],\n\tsourcePath: string,\n): ResolvedMcpServer {\n\tconst config = { ...normalizeServer(raw), directTools: [], exposure: \"search\" as const };\n\treturn {\n\t\tconfig,\n\t\tconfigHash: hashConfig(config),\n\t\tname,\n\t\tsource: \"skill\",\n\t\tsourcePath,\n\t\tstate: config.enabled ? \"enabled\" : \"disabled\",\n\t\ttransport: config.type,\n\t};\n}\n\nfunction normalizeServer(server: NonNullable<RawConfig[\"mcpServers\"]>[string]): McpServerConfig {\n\tconst type = server.type ?? (server.url ? \"http\" : \"stdio\");\n\treturn {\n\t\targs: server.args ?? [],\n\t\tconnectTimeoutMs: server.connectTimeoutMs ?? 15_000,\n\t\tenabled: server.enabled ?? true,\n\t\texposure: server.exposure ?? \"auto\",\n\t\tidleTimeoutMin: server.idleTimeoutMin ?? 10,\n\t\tlifecycle: server.lifecycle ?? \"lazy\",\n\t\tlogLevel: server.logLevel ?? \"info\",\n\t\trequestTimeoutMs: server.requestTimeoutMs ?? 30_000,\n\t\ttype,\n\t\t...server,\n\t};\n}\n\nfunction interpolateConfig(\n\tconfig: RawConfig | undefined,\n\tenv: Record<string, string | undefined>,\n): RawConfig | undefined {\n\treturn interpolateValue(config, \"mcp\", env) as RawConfig | undefined;\n}\n\nfunction interpolateValue(value: unknown, path: string, env: Record<string, string | undefined>): unknown {\n\tif (typeof value === \"string\") return interpolateString(value, path, env);\n\tif (Array.isArray(value)) return value.map((item, index) => interpolateValue(item, `${path}.${index}`, env));\n\tif (typeof value === \"object\" && value !== null) {\n\t\tconst out: Record<string, unknown> = {};\n\t\tfor (const [key, item] of Object.entries(value)) out[key] = interpolateValue(item, `${path}.${key}`, env);\n\t\treturn out;\n\t}\n\treturn value;\n}\n\nfunction interpolateString(value: string, path: string, env: Record<string, string | undefined>): string {\n\tif (value.trimStart().startsWith(\"!\") || value.includes(\"$(\")) {\n\t\tconst displayPath = path.replace(/^mcp\\./, \"\");\n\t\tthrow new McpConfigValidationError(\n\t\t\t`MCP config interpolation rejected command substitution at ${displayPath}: config values may reference only environment variables for security; shell commands are never executed.`,\n\t\t);\n\t}\n\treturn value.replace(\n\t\t/\\$\\{([A-Za-z_][A-Za-z0-9_]*)(:-([^}]*))?\\}/g,\n\t\t(_match, name: string, _fallback: string, fallbackValue: string | undefined) => {\n\t\t\treturn env[name] ?? fallbackValue ?? \"\";\n\t\t},\n\t);\n}\n\nfunction hashConfig(config: McpServerConfig): string {\n\treturn createHash(\"sha256\").update(stableStringify(config)).digest(\"hex\");\n}\n\nfunction stableStringify(value: unknown): string {\n\tif (Array.isArray(value)) return `[${value.map(stableStringify).join(\",\")}]`;\n\tif (typeof value === \"object\" && value !== null) {\n\t\treturn `{${Object.keys(value)\n\t\t\t.sort()\n\t\t\t.map((key) => `${JSON.stringify(key)}:${stableStringify((value as Record<string, unknown>)[key])}`)\n\t\t\t.join(\",\")}}`;\n\t}\n\treturn JSON.stringify(value);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-snapshot.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/mcp/service-snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEhF,wBAAgB,sBAAsB,CACrC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,iBAAiB,GAAG,SAAS,EACrC,UAAU,EAAE,gBAAgB,GAAG,SAAS,EACxC,KAAK,EAAE,kBAAkB,GAAG,SAAS,EACrC,GAAG,SAAa,GACd,iBAAiB,
|
|
1
|
+
{"version":3,"file":"service-snapshot.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/mcp/service-snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEhF,wBAAgB,sBAAsB,CACrC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,iBAAiB,GAAG,SAAS,EACrC,UAAU,EAAE,gBAAgB,GAAG,SAAS,EACxC,KAAK,EAAE,kBAAkB,GAAG,SAAS,EACrC,GAAG,SAAa,GACd,iBAAiB,CAiBnB"}
|
|
@@ -3,6 +3,7 @@ export function buildMcpServerSnapshot(name, server, connection, entry, now = Da
|
|
|
3
3
|
name,
|
|
4
4
|
configState: server?.state ?? "removed",
|
|
5
5
|
configHash: server?.configHash ?? null,
|
|
6
|
+
source: server?.source ?? null,
|
|
6
7
|
sourcePath: server?.sourcePath ?? null,
|
|
7
8
|
lifecycleState: connection?.state === "idle" && connection.generation === 0 && entry?.cachedCatalog !== undefined
|
|
8
9
|
? "cached"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-snapshot.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/mcp/service-snapshot.ts"],"names":[],"mappings":"AAIA,MAAM,UAAU,sBAAsB,CACrC,IAAY,EACZ,MAAqC,EACrC,UAAwC,EACxC,KAAqC,EACrC,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE;IAEhB,OAAO;QACN,IAAI;QACJ,WAAW,EAAE,MAAM,EAAE,KAAK,IAAI,SAAS;QACvC,UAAU,EAAE,MAAM,EAAE,UAAU,IAAI,IAAI;QACtC,UAAU,EAAE,MAAM,EAAE,UAAU,IAAI,IAAI;QACtC,cAAc,EACb,UAAU,EAAE,KAAK,KAAK,MAAM,IAAI,UAAU,CAAC,UAAU,KAAK,CAAC,IAAI,KAAK,EAAE,aAAa,KAAK,SAAS;YAChG,CAAC,CAAC,QAAQ;YACV,CAAC,CAAC,CAAC,UAAU,EAAE,KAAK,IAAI,aAAa,CAAC;QACxC,UAAU,EAAE,UAAU,EAAE,UAAU,IAAI,IAAI;QAC1C,GAAG,EAAE,UAAU,EAAE,UAAU,EAAE,IAAI,IAAI;QACrC,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,IAAI,IAAI;QACjD,QAAQ,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,KAAK,CAAC,WAAW;QAC9D,QAAQ,EAAE,KAAK,EAAE,QAAQ,IAAI,EAAE,SAAS,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,cAAc,EAAE,CAAC,EAAE,cAAc,EAAE,CAAC,EAAE;KAClG,CAAC;AACH,CAAC","sourcesContent":["import type { ResolvedMcpServer } from \"./config-schema.ts\";\nimport type { ServerConnection } from \"./connection.ts\";\nimport type { McpConnectionEntry, McpServerSnapshot } from \"./service-types.ts\";\n\nexport function buildMcpServerSnapshot(\n\tname: string,\n\tserver: ResolvedMcpServer | undefined,\n\tconnection: ServerConnection | undefined,\n\tentry: McpConnectionEntry | undefined,\n\tnow = Date.now(),\n): McpServerSnapshot {\n\treturn {\n\t\tname,\n\t\tconfigState: server?.state ?? \"removed\",\n\t\tconfigHash: server?.configHash ?? null,\n\t\tsourcePath: server?.sourcePath ?? null,\n\t\tlifecycleState:\n\t\t\tconnection?.state === \"idle\" && connection.generation === 0 && entry?.cachedCatalog !== undefined\n\t\t\t\t? \"cached\"\n\t\t\t\t: (connection?.state ?? \"not_spawned\"),\n\t\tgeneration: connection?.generation ?? null,\n\t\tpid: connection?.getRootPid() ?? null,\n\t\tlastError: connection?.lastError?.message ?? null,\n\t\tuptimeMs: entry === undefined ? null : now - entry.createdAtMs,\n\t\tcounters: entry?.counters ?? { callCount: 0, errorCount: 0, totalLatencyMs: 0, reconnectCount: 0 },\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"service-snapshot.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/mcp/service-snapshot.ts"],"names":[],"mappings":"AAIA,MAAM,UAAU,sBAAsB,CACrC,IAAY,EACZ,MAAqC,EACrC,UAAwC,EACxC,KAAqC,EACrC,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE;IAEhB,OAAO;QACN,IAAI;QACJ,WAAW,EAAE,MAAM,EAAE,KAAK,IAAI,SAAS;QACvC,UAAU,EAAE,MAAM,EAAE,UAAU,IAAI,IAAI;QACtC,MAAM,EAAE,MAAM,EAAE,MAAM,IAAI,IAAI;QAC9B,UAAU,EAAE,MAAM,EAAE,UAAU,IAAI,IAAI;QACtC,cAAc,EACb,UAAU,EAAE,KAAK,KAAK,MAAM,IAAI,UAAU,CAAC,UAAU,KAAK,CAAC,IAAI,KAAK,EAAE,aAAa,KAAK,SAAS;YAChG,CAAC,CAAC,QAAQ;YACV,CAAC,CAAC,CAAC,UAAU,EAAE,KAAK,IAAI,aAAa,CAAC;QACxC,UAAU,EAAE,UAAU,EAAE,UAAU,IAAI,IAAI;QAC1C,GAAG,EAAE,UAAU,EAAE,UAAU,EAAE,IAAI,IAAI;QACrC,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,IAAI,IAAI;QACjD,QAAQ,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,KAAK,CAAC,WAAW;QAC9D,QAAQ,EAAE,KAAK,EAAE,QAAQ,IAAI,EAAE,SAAS,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,cAAc,EAAE,CAAC,EAAE,cAAc,EAAE,CAAC,EAAE;KAClG,CAAC;AACH,CAAC","sourcesContent":["import type { ResolvedMcpServer } from \"./config-schema.ts\";\nimport type { ServerConnection } from \"./connection.ts\";\nimport type { McpConnectionEntry, McpServerSnapshot } from \"./service-types.ts\";\n\nexport function buildMcpServerSnapshot(\n\tname: string,\n\tserver: ResolvedMcpServer | undefined,\n\tconnection: ServerConnection | undefined,\n\tentry: McpConnectionEntry | undefined,\n\tnow = Date.now(),\n): McpServerSnapshot {\n\treturn {\n\t\tname,\n\t\tconfigState: server?.state ?? \"removed\",\n\t\tconfigHash: server?.configHash ?? null,\n\t\tsource: server?.source ?? null,\n\t\tsourcePath: server?.sourcePath ?? null,\n\t\tlifecycleState:\n\t\t\tconnection?.state === \"idle\" && connection.generation === 0 && entry?.cachedCatalog !== undefined\n\t\t\t\t? \"cached\"\n\t\t\t\t: (connection?.state ?? \"not_spawned\"),\n\t\tgeneration: connection?.generation ?? null,\n\t\tpid: connection?.getRootPid() ?? null,\n\t\tlastError: connection?.lastError?.message ?? null,\n\t\tuptimeMs: entry === undefined ? null : now - entry.createdAtMs,\n\t\tcounters: entry?.counters ?? { callCount: 0, errorCount: 0, totalLatencyMs: 0, reconnectCount: 0 },\n\t};\n}\n"]}
|
|
@@ -12,6 +12,17 @@ export type McpSessionContext = Pick<ExtensionContext, "cwd" | "isProjectTrusted
|
|
|
12
12
|
* requirement narrow lets tests pass a two-line fake.
|
|
13
13
|
*/
|
|
14
14
|
sessionManager?: Pick<ExtensionContext["sessionManager"], "getEntries">;
|
|
15
|
+
/**
|
|
16
|
+
* Extension-declared MCP servers. Read on every attach so reattach/reload
|
|
17
|
+
* paths pick up the current declarations without caching them in the MCP
|
|
18
|
+
* builtin.
|
|
19
|
+
*/
|
|
20
|
+
getRegisteredMcpServers?: () => readonly {
|
|
21
|
+
name: string;
|
|
22
|
+
config: Record<string, unknown>;
|
|
23
|
+
extensionPath: string;
|
|
24
|
+
registrationCwd: string;
|
|
25
|
+
}[];
|
|
15
26
|
};
|
|
16
27
|
export interface McpSessionOptions {
|
|
17
28
|
readonly agentDir?: string;
|
|
@@ -32,6 +43,7 @@ export interface McpServerSnapshot {
|
|
|
32
43
|
name: string;
|
|
33
44
|
configState: ResolvedMcpServer["state"] | "removed";
|
|
34
45
|
configHash: string | null;
|
|
46
|
+
source: ResolvedMcpServer["source"] | null;
|
|
35
47
|
sourcePath: string | null;
|
|
36
48
|
lifecycleState: ServerConnectionState | "cached" | "not_spawned";
|
|
37
49
|
generation: number | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-types.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/mcp/service-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAChG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAC/E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C,MAAM,MAAM,gBAAgB,GAAG,OAAO,CAAC,oBAAoB,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC,CAAC;AAC1F,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,gBAAgB,EAAE,KAAK,GAAG,kBAAkB,CAAC,GAAG;IACpF;;;;OAIG;IACH,cAAc,CAAC,EAAE,IAAI,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,EAAE,YAAY,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"service-types.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/mcp/service-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAChG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,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,CAAC,EAAE,cAAc,CAAC;IACnC,aAAa,CAAC,EAAE,sBAAsB,CAAC;IACvC,0BAA0B,EAAE,OAAO,CAAC;IACpC,kFAAkF;IAClF,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,0FAA0F;IAC1F,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,8DAA8D;IAC9D,kBAAkB,CAAC,EAAE,MAAM,IAAI,CAAC;CAChC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-types.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/mcp/service-types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ExtensionContext, SessionShutdownEvent, SessionStartEvent } from \"../../types.ts\";\nimport type { ServerAuthPlan } from \"./auth/context.ts\";\nimport type { McpCachedServerCatalog } from \"./catalog-cache.ts\";\nimport type { ResolvedMcpServer } from \"./config-schema.ts\";\nimport type { ServerConnection, ServerConnectionState } from \"./connection.ts\";\nimport type { McpLogger } from \"./log.ts\";\n\nexport type McpDisposeReason = Extract<SessionShutdownEvent[\"reason\"], \"quit\" | \"reload\">;\nexport type McpSessionContext = Pick<ExtensionContext, \"cwd\" | \"isProjectTrusted\"> & {\n\t/**\n\t * Session history access, present on the real ExtensionContext. Only\n\t * getEntries is needed (attach-time promotion rehydration); keeping the\n\t * requirement narrow lets tests pass a two-line fake.\n\t */\n\tsessionManager?: Pick<ExtensionContext[\"sessionManager\"], \"getEntries\">;\n};\n\nexport interface McpSessionOptions {\n\treadonly agentDir?: string;\n\treadonly env?: Record<string, string | undefined>;\n\treadonly logDir?: string;\n\treadonly projectTrusted?: boolean;\n}\n\nexport interface McpServiceSnapshot {\n\tdisposed: boolean;\n\tdisposeCount: number;\n\tlastDisposeReason: McpDisposeReason | null;\n\tsessionStartCount: number;\n\tlastSessionStartReason: SessionStartEvent[\"reason\"] | null;\n\thasSessionContext: boolean;\n\tconnectionCount: number;\n}\n\nexport interface McpServerSnapshot {\n\tname: string;\n\tconfigState: ResolvedMcpServer[\"state\"] | \"removed\";\n\tconfigHash: string | null;\n\tsourcePath: string | null;\n\tlifecycleState: ServerConnectionState | \"cached\" | \"not_spawned\";\n\tgeneration: number | null;\n\tpid: number | null;\n\tlastError: string | null;\n\tuptimeMs: number | null;\n\tcounters: McpServerCounters;\n}\n\nexport interface McpServerCounters {\n\tcallCount: number;\n\terrorCount: number;\n\ttotalLatencyMs: number;\n\treconnectCount: number;\n}\n\nexport interface McpConnectionEntry {\n\treadonly key: string;\n\treadonly name: string;\n\treadonly configHash: string;\n\treadonly connection: ServerConnection;\n\treadonly logger: McpLogger;\n\treadonly createdAtMs: number;\n\treadonly counters: McpServerCounters;\n\treadonly agentDir?: string;\n\treadonly authPlan?: ServerAuthPlan;\n\tcachedCatalog?: McpCachedServerCatalog;\n\tcacheRefreshedAfterConnect: boolean;\n\t/** Full mcp tool names last registered for this server (list_changed diffing). */\n\tknownToolNames?: string[];\n\t/** Latest `/mcp status` list_changed delta line, e.g. \"2 added (inactive), 1 removed\". */\n\tlastListChangedDelta?: string;\n\t/** Teardown for the list_changed coalescer + subscription. */\n\tdisposeListChanged?: () => void;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"service-types.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/mcp/service-types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ExtensionContext, SessionShutdownEvent, SessionStartEvent } from \"../../types.ts\";\nimport type { ServerAuthPlan } from \"./auth/context.ts\";\nimport type { McpCachedServerCatalog } from \"./catalog-cache.ts\";\nimport type { ResolvedMcpServer } from \"./config-schema.ts\";\nimport type { ServerConnection, ServerConnectionState } from \"./connection.ts\";\nimport type { McpLogger } from \"./log.ts\";\n\nexport type McpDisposeReason = Extract<SessionShutdownEvent[\"reason\"], \"quit\" | \"reload\">;\nexport type McpSessionContext = Pick<ExtensionContext, \"cwd\" | \"isProjectTrusted\"> & {\n\t/**\n\t * Session history access, present on the real ExtensionContext. Only\n\t * getEntries is needed (attach-time promotion rehydration); keeping the\n\t * requirement narrow lets tests pass a two-line fake.\n\t */\n\tsessionManager?: Pick<ExtensionContext[\"sessionManager\"], \"getEntries\">;\n\t/**\n\t * Extension-declared MCP servers. Read on every attach so reattach/reload\n\t * paths pick up the current declarations without caching them in the MCP\n\t * builtin.\n\t */\n\tgetRegisteredMcpServers?: () => readonly {\n\t\tname: string;\n\t\tconfig: Record<string, unknown>;\n\t\textensionPath: string;\n\t\tregistrationCwd: string;\n\t}[];\n};\n\nexport interface McpSessionOptions {\n\treadonly agentDir?: string;\n\treadonly env?: Record<string, string | undefined>;\n\treadonly logDir?: string;\n\treadonly projectTrusted?: boolean;\n}\n\nexport interface McpServiceSnapshot {\n\tdisposed: boolean;\n\tdisposeCount: number;\n\tlastDisposeReason: McpDisposeReason | null;\n\tsessionStartCount: number;\n\tlastSessionStartReason: SessionStartEvent[\"reason\"] | null;\n\thasSessionContext: boolean;\n\tconnectionCount: number;\n}\n\nexport interface McpServerSnapshot {\n\tname: string;\n\tconfigState: ResolvedMcpServer[\"state\"] | \"removed\";\n\tconfigHash: string | null;\n\tsource: ResolvedMcpServer[\"source\"] | null;\n\tsourcePath: string | null;\n\tlifecycleState: ServerConnectionState | \"cached\" | \"not_spawned\";\n\tgeneration: number | null;\n\tpid: number | null;\n\tlastError: string | null;\n\tuptimeMs: number | null;\n\tcounters: McpServerCounters;\n}\n\nexport interface McpServerCounters {\n\tcallCount: number;\n\terrorCount: number;\n\ttotalLatencyMs: number;\n\treconnectCount: number;\n}\n\nexport interface McpConnectionEntry {\n\treadonly key: string;\n\treadonly name: string;\n\treadonly configHash: string;\n\treadonly connection: ServerConnection;\n\treadonly logger: McpLogger;\n\treadonly createdAtMs: number;\n\treadonly counters: McpServerCounters;\n\treadonly agentDir?: string;\n\treadonly authPlan?: ServerAuthPlan;\n\tcachedCatalog?: McpCachedServerCatalog;\n\tcacheRefreshedAfterConnect: boolean;\n\t/** Full mcp tool names last registered for this server (list_changed diffing). */\n\tknownToolNames?: string[];\n\t/** Latest `/mcp status` list_changed delta line, e.g. \"2 added (inactive), 1 removed\". */\n\tlastListChangedDelta?: string;\n\t/** Teardown for the list_changed coalescer + subscription. */\n\tdisposeListChanged?: () => void;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/mcp/service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAI5F,OAAO,
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/mcp/service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAI5F,OAAO,EAA2C,qBAAqB,EAA4B,MAAM,aAAa,CAAC;AACvH,OAAO,KAAK,EAAE,eAAe,EAAwC,MAAM,oBAAoB,CAAC;AAChG,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAGnD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAYlE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAIxD,OAAO,KAAK,EAEX,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,MAAM,oBAAoB,CAAC;AAQ5B,OAAO,EAAE,gCAAgC,EAAE,MAAM,iBAAiB,CAAC;AAEnE,qBAAa,UAAU;;IAoBhB,aAAa,CAClB,KAAK,EAAE,iBAAiB,EACxB,GAAG,EAAE,iBAAiB,EACtB,GAAG,CAAC,EAAE,IAAI,CAAC,YAAY,EAAE,gBAAgB,GAAG,gBAAgB,GAAG,cAAc,CAAC,EAC9E,OAAO,GAAE,iBAAsB,GAC7B,OAAO,CAAC,IAAI,CA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EAAE,OAAO,GAAG,IAAI,CAOjE;IAED,WAAW,IAAI,kBAAkB,CAUhC;IA0JD;;;;OAIG;IACH,+BAA+B,CAAC,QAAQ,EAAE,SAAS,OAAO,EAAE,GAAG,MAAM,EAAE,CAGtE;IAED;;;;;OAKG;IACH,yBAAyB,CAAC,QAAQ,EAAE,SAAS,OAAO,EAAE,GAAG,MAAM,EAAE,CAGhE;IAaD,cAAc,IAAI,GAAG,CAAC,MAAM,EAAE,OAAO,0BAA0B,EAAE,gBAAgB,CAAC,CAEjF;IAED,aAAa,CACZ,IAAI,EAAE,MAAM,GAEV;QAAE,MAAM,EAAE,eAAe,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,GAC9G,SAAS,CASX;IAED,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAEtD;IAED;8DAC0D;IAC1D,0BAA0B,IAAI,MAAM,GAAG,OAAO,GAAG,SAAS,CAEzD;CACD;AAID,wBAAgB,aAAa,IAAI,UAAU,CAK1C;AAED,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,oBAAoB,CAAC,QAAQ,CAAC,GAAG,MAAM,IAAI,gBAAgB,CAE1G;AASD,wBAAgB,uBAAuB,IAAI,IAAI,CAE9C"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { detectLiteralBearerWarnings, resolveServerAuth } from "./auth/context.js";
|
|
2
2
|
import { collectToolCatalog } from "./catalog.js";
|
|
3
3
|
import { getValidCachedServer, readMcpCatalogCache } from "./catalog-cache.js";
|
|
4
|
-
import { loadMcpConfig, resolveSkillMcpServer, visitSpawnableMcpServers } from "./config.js";
|
|
4
|
+
import { loadMcpConfig, mergeExtensionMcpServers, resolveSkillMcpServer, visitSpawnableMcpServers } from "./config.js";
|
|
5
5
|
import { ServerConnection } from "./connection.js";
|
|
6
6
|
import { mapMcpCatalogNames } from "./expose/register.js";
|
|
7
7
|
import { cleanupMcpOutputArtifacts } from "./guard/output-guard.js";
|
|
@@ -44,6 +44,7 @@ export class McpService {
|
|
|
44
44
|
env: options.env,
|
|
45
45
|
projectTrusted: options.projectTrusted ?? ctx.isProjectTrusted(),
|
|
46
46
|
});
|
|
47
|
+
mergeExtensionMcpServers(config, ctx.getRegisteredMcpServers?.() ?? []);
|
|
47
48
|
this.#config = config;
|
|
48
49
|
this.#pi = _pi;
|
|
49
50
|
this.#authAgentDir = options.agentDir;
|