@burtson-labs/agent-core 1.6.20 → 1.6.21
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/mcp/authFailure.d.ts +58 -0
- package/dist/mcp/authFailure.d.ts.map +1 -0
- package/dist/mcp/authFailure.js +105 -0
- package/dist/mcp/authFailure.js.map +1 -0
- package/dist/mcp/index.d.ts +1 -0
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +5 -1
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/toolAdapter.d.ts.map +1 -1
- package/dist/mcp/toolAdapter.js +12 -2
- package/dist/mcp/toolAdapter.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turning an expired MCP credential into something the agent can act on.
|
|
3
|
+
*
|
|
4
|
+
* The failure this exists for: a connected MCP server's session expires
|
|
5
|
+
* mid-task and the tool comes back with a server-generated string like
|
|
6
|
+
*
|
|
7
|
+
* Tool 'listMessages' execution failed: The AuthApi rejected the session JWT
|
|
8
|
+
* and the API-key re-validation also failed. The API key may be…
|
|
9
|
+
*
|
|
10
|
+
* To a model that is only pattern-matching, that reads as "this capability is
|
|
11
|
+
* broken", not "this capability needs sixty seconds of user action". Observed
|
|
12
|
+
* consequence: the agent silently abandoned the connected service, fell back to
|
|
13
|
+
* driving Mail.app through `osascript`, and never told the user their Gmail
|
|
14
|
+
* connection had expired. The task limped to an answer by a much worse route,
|
|
15
|
+
* and the actual problem went unreported.
|
|
16
|
+
*
|
|
17
|
+
* An expired credential is one of the most recoverable failures in the whole
|
|
18
|
+
* system — the user just has to re-authorize. But nothing in the error said so,
|
|
19
|
+
* and nothing named the command that does it.
|
|
20
|
+
*
|
|
21
|
+
* So: detect auth-shaped failures, and rewrite them into an instruction that
|
|
22
|
+
* names the server, states plainly that this is recoverable, and tells the
|
|
23
|
+
* agent to surface the reconnect command rather than routing around it.
|
|
24
|
+
*/
|
|
25
|
+
export interface McpAuthFailure {
|
|
26
|
+
/** The server whose credential needs refreshing. */
|
|
27
|
+
server: string;
|
|
28
|
+
/** Original error text, preserved so the user can see what actually failed. */
|
|
29
|
+
original: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Does this MCP failure look like an expired or rejected credential?
|
|
33
|
+
*
|
|
34
|
+
* Checked against the error text only. Tool output that merely *mentions*
|
|
35
|
+
* tokens (reading an auth module's source, say) never reaches here — this runs
|
|
36
|
+
* on the throw path, not on successful results.
|
|
37
|
+
*/
|
|
38
|
+
export declare function looksLikeAuthFailure(message: string): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Rewrite an auth failure into a recovery instruction.
|
|
41
|
+
*
|
|
42
|
+
* Three things the replacement must do, each learned from the trace above:
|
|
43
|
+
*
|
|
44
|
+
* 1. Say it is recoverable and temporary. Otherwise the model reasons about
|
|
45
|
+
* the capability as permanently absent and stops considering it.
|
|
46
|
+
* 2. Name the reconnect command, so the agent can hand the user something to
|
|
47
|
+
* run instead of paraphrasing "you may need to check your settings".
|
|
48
|
+
* 3. Explicitly forbid the silent workaround. The agent routing around a
|
|
49
|
+
* broken connection without mentioning it is the part that actually cost
|
|
50
|
+
* the user — they finished the task believing Gmail had been searched.
|
|
51
|
+
*/
|
|
52
|
+
export declare function describeMcpAuthFailure(failure: McpAuthFailure): string;
|
|
53
|
+
/**
|
|
54
|
+
* Wrap an MCP invocation error, upgrading auth-shaped failures into recovery
|
|
55
|
+
* instructions and passing everything else through unchanged.
|
|
56
|
+
*/
|
|
57
|
+
export declare function formatMcpToolError(namespacedName: string, server: string, message: string): string;
|
|
58
|
+
//# sourceMappingURL=authFailure.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authFailure.d.ts","sourceRoot":"","sources":["../../src/mcp/authFailure.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAqBH,MAAM,WAAW,cAAc;IAC7B,oDAAoD;IACpD,MAAM,EAAE,MAAM,CAAC;IACf,+EAA+E;IAC/E,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAG7D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,cAAc,GAAG,MAAM,CAoBtE;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAKlG"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Turning an expired MCP credential into something the agent can act on.
|
|
4
|
+
*
|
|
5
|
+
* The failure this exists for: a connected MCP server's session expires
|
|
6
|
+
* mid-task and the tool comes back with a server-generated string like
|
|
7
|
+
*
|
|
8
|
+
* Tool 'listMessages' execution failed: The AuthApi rejected the session JWT
|
|
9
|
+
* and the API-key re-validation also failed. The API key may be…
|
|
10
|
+
*
|
|
11
|
+
* To a model that is only pattern-matching, that reads as "this capability is
|
|
12
|
+
* broken", not "this capability needs sixty seconds of user action". Observed
|
|
13
|
+
* consequence: the agent silently abandoned the connected service, fell back to
|
|
14
|
+
* driving Mail.app through `osascript`, and never told the user their Gmail
|
|
15
|
+
* connection had expired. The task limped to an answer by a much worse route,
|
|
16
|
+
* and the actual problem went unreported.
|
|
17
|
+
*
|
|
18
|
+
* An expired credential is one of the most recoverable failures in the whole
|
|
19
|
+
* system — the user just has to re-authorize. But nothing in the error said so,
|
|
20
|
+
* and nothing named the command that does it.
|
|
21
|
+
*
|
|
22
|
+
* So: detect auth-shaped failures, and rewrite them into an instruction that
|
|
23
|
+
* names the server, states plainly that this is recoverable, and tells the
|
|
24
|
+
* agent to surface the reconnect command rather than routing around it.
|
|
25
|
+
*/
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.looksLikeAuthFailure = looksLikeAuthFailure;
|
|
28
|
+
exports.describeMcpAuthFailure = describeMcpAuthFailure;
|
|
29
|
+
exports.formatMcpToolError = formatMcpToolError;
|
|
30
|
+
/**
|
|
31
|
+
* Auth-shaped failure signatures.
|
|
32
|
+
*
|
|
33
|
+
* Deliberately broad on the symptom and narrow on the action: a false positive
|
|
34
|
+
* costs one unnecessary "you may need to reconnect" line, while a false
|
|
35
|
+
* negative costs a silent capability loss like the one above. Ordered from
|
|
36
|
+
* most to least specific so the matched phrase can be quoted back.
|
|
37
|
+
*/
|
|
38
|
+
const AUTH_FAILURE_PATTERNS = [
|
|
39
|
+
/rejected the session (?:jwt|token)/i,
|
|
40
|
+
/re-?validation (?:also )?failed/i,
|
|
41
|
+
/\b(?:token|session|credential|api[- ]?key)s?\b[^.]{0,40}\b(?:expired|invalid|revoked|rejected)\b/i,
|
|
42
|
+
/\bexpired\b[^.]{0,30}\b(?:token|session|credential|grant)\b/i,
|
|
43
|
+
/\b(?:401|403)\b|\bunauthori[sz]ed\b|\bforbidden\b/i,
|
|
44
|
+
/\bauthentication (?:failed|required|error)\b/i,
|
|
45
|
+
/\bnot authenticated\b|\bre-?authenticat/i,
|
|
46
|
+
/\binvalid_grant\b|\binvalid_token\b|\btoken_expired\b/i
|
|
47
|
+
];
|
|
48
|
+
/**
|
|
49
|
+
* Does this MCP failure look like an expired or rejected credential?
|
|
50
|
+
*
|
|
51
|
+
* Checked against the error text only. Tool output that merely *mentions*
|
|
52
|
+
* tokens (reading an auth module's source, say) never reaches here — this runs
|
|
53
|
+
* on the throw path, not on successful results.
|
|
54
|
+
*/
|
|
55
|
+
function looksLikeAuthFailure(message) {
|
|
56
|
+
if (!message) {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
return AUTH_FAILURE_PATTERNS.some((re) => re.test(message));
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Rewrite an auth failure into a recovery instruction.
|
|
63
|
+
*
|
|
64
|
+
* Three things the replacement must do, each learned from the trace above:
|
|
65
|
+
*
|
|
66
|
+
* 1. Say it is recoverable and temporary. Otherwise the model reasons about
|
|
67
|
+
* the capability as permanently absent and stops considering it.
|
|
68
|
+
* 2. Name the reconnect command, so the agent can hand the user something to
|
|
69
|
+
* run instead of paraphrasing "you may need to check your settings".
|
|
70
|
+
* 3. Explicitly forbid the silent workaround. The agent routing around a
|
|
71
|
+
* broken connection without mentioning it is the part that actually cost
|
|
72
|
+
* the user — they finished the task believing Gmail had been searched.
|
|
73
|
+
*/
|
|
74
|
+
function describeMcpAuthFailure(failure) {
|
|
75
|
+
const { server, original } = failure;
|
|
76
|
+
return [
|
|
77
|
+
`Authentication for the "${server}" MCP server has expired or been rejected.`,
|
|
78
|
+
'',
|
|
79
|
+
`Underlying error: ${original}`,
|
|
80
|
+
'',
|
|
81
|
+
'This is RECOVERABLE and usually takes under a minute — the connection is',
|
|
82
|
+
'configured correctly, its credential just needs refreshing. Do not treat',
|
|
83
|
+
`"${server}" as permanently unavailable.`,
|
|
84
|
+
'',
|
|
85
|
+
'Do this now, in order:',
|
|
86
|
+
`1. Tell the user plainly that the "${server}" connection needs re-authorizing,`,
|
|
87
|
+
` and that they can fix it by running: /mcp connect ${server}`,
|
|
88
|
+
'2. Do NOT silently switch to another route to get the same data. If you can',
|
|
89
|
+
' reach it another way, say what you are about to do and why FIRST — a user',
|
|
90
|
+
' who is not told their connection expired will assume it worked.',
|
|
91
|
+
'3. If the rest of the task does not depend on this server, continue with it',
|
|
92
|
+
' and report the expired connection alongside your result.'
|
|
93
|
+
].join('\n');
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Wrap an MCP invocation error, upgrading auth-shaped failures into recovery
|
|
97
|
+
* instructions and passing everything else through unchanged.
|
|
98
|
+
*/
|
|
99
|
+
function formatMcpToolError(namespacedName, server, message) {
|
|
100
|
+
if (looksLikeAuthFailure(message)) {
|
|
101
|
+
return describeMcpAuthFailure({ server, original: message });
|
|
102
|
+
}
|
|
103
|
+
return `Error invoking ${namespacedName}: ${message}`;
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=authFailure.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authFailure.js","sourceRoot":"","sources":["../../src/mcp/authFailure.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;AAmCH,oDAGC;AAeD,wDAoBC;AAMD,gDAKC;AAlFD;;;;;;;GAOG;AACH,MAAM,qBAAqB,GAAa;IACtC,qCAAqC;IACrC,kCAAkC;IAClC,mGAAmG;IACnG,8DAA8D;IAC9D,oDAAoD;IACpD,+CAA+C;IAC/C,0CAA0C;IAC1C,wDAAwD;CACzD,CAAC;AASF;;;;;;GAMG;AACH,SAAgB,oBAAoB,CAAC,OAAe;IAClD,IAAI,CAAC,OAAO,EAAE,CAAC;QAAA,OAAO,KAAK,CAAC;IAAA,CAAC;IAC7B,OAAO,qBAAqB,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;AAC9D,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,SAAgB,sBAAsB,CAAC,OAAuB;IAC5D,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IACrC,OAAO;QACL,2BAA2B,MAAM,4CAA4C;QAC7E,EAAE;QACF,qBAAqB,QAAQ,EAAE;QAC/B,EAAE;QACF,0EAA0E;QAC1E,0EAA0E;QAC1E,IAAI,MAAM,+BAA+B;QACzC,EAAE;QACF,wBAAwB;QACxB,sCAAsC,MAAM,oCAAoC;QAChF,wDAAwD,MAAM,EAAE;QAChE,6EAA6E;QAC7E,8EAA8E;QAC9E,oEAAoE;QACpE,6EAA6E;QAC7E,6DAA6D;KAC9D,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC;AAED;;;GAGG;AACH,SAAgB,kBAAkB,CAAC,cAAsB,EAAE,MAAc,EAAE,OAAe;IACxF,IAAI,oBAAoB,CAAC,OAAO,CAAC,EAAE,CAAC;QAClC,OAAO,sBAAsB,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;IAC/D,CAAC;IACD,OAAO,kBAAkB,cAAc,KAAK,OAAO,EAAE,CAAC;AACxD,CAAC"}
|
package/dist/mcp/index.d.ts
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
*/
|
|
13
13
|
export { McpClientPool, fingerprintServerConfig, type McpClientPoolOptions, type McpTrustGate, type McpToolsDiscoveredCallback, type RemoteToolDef as McpRemoteToolDef } from './clientPool';
|
|
14
14
|
export { mcpToolToAgentTool, getAllMcpAgentTools } from './toolAdapter';
|
|
15
|
+
export { looksLikeAuthFailure, describeMcpAuthFailure, formatMcpToolError, type McpAuthFailure } from './authFailure';
|
|
15
16
|
export { serveBanditMcp } from './server';
|
|
16
17
|
export { shouldActivateServer, effectiveTriggers, inferProviderHint } from './activation';
|
|
17
18
|
export type { McpServerConfig, McpServersFile, McpServerStatus, McpServerSnapshot } from './types';
|
package/dist/mcp/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACL,aAAa,EACb,uBAAuB,EACvB,KAAK,oBAAoB,EACzB,KAAK,YAAY,EACjB,KAAK,0BAA0B,EAC/B,KAAK,aAAa,IAAI,gBAAgB,EACvC,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,cAAc,CAAC;AACtB,YAAY,EACV,eAAe,EACf,cAAc,EACd,eAAe,EACf,iBAAiB,EAClB,MAAM,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACL,aAAa,EACb,uBAAuB,EACvB,KAAK,oBAAoB,EACzB,KAAK,YAAY,EACjB,KAAK,0BAA0B,EAC/B,KAAK,aAAa,IAAI,gBAAgB,EACvC,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AACtH,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,cAAc,CAAC;AACtB,YAAY,EACV,eAAe,EACf,cAAc,EACd,eAAe,EACf,iBAAiB,EAClB,MAAM,SAAS,CAAC"}
|
package/dist/mcp/index.js
CHANGED
|
@@ -12,13 +12,17 @@
|
|
|
12
12
|
* pool gets zero behavior change. No backward-compat risk.
|
|
13
13
|
*/
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.inferProviderHint = exports.effectiveTriggers = exports.shouldActivateServer = exports.serveBanditMcp = exports.getAllMcpAgentTools = exports.mcpToolToAgentTool = exports.fingerprintServerConfig = exports.McpClientPool = void 0;
|
|
15
|
+
exports.inferProviderHint = exports.effectiveTriggers = exports.shouldActivateServer = exports.serveBanditMcp = exports.formatMcpToolError = exports.describeMcpAuthFailure = exports.looksLikeAuthFailure = exports.getAllMcpAgentTools = exports.mcpToolToAgentTool = exports.fingerprintServerConfig = exports.McpClientPool = void 0;
|
|
16
16
|
var clientPool_1 = require("./clientPool");
|
|
17
17
|
Object.defineProperty(exports, "McpClientPool", { enumerable: true, get: function () { return clientPool_1.McpClientPool; } });
|
|
18
18
|
Object.defineProperty(exports, "fingerprintServerConfig", { enumerable: true, get: function () { return clientPool_1.fingerprintServerConfig; } });
|
|
19
19
|
var toolAdapter_1 = require("./toolAdapter");
|
|
20
20
|
Object.defineProperty(exports, "mcpToolToAgentTool", { enumerable: true, get: function () { return toolAdapter_1.mcpToolToAgentTool; } });
|
|
21
21
|
Object.defineProperty(exports, "getAllMcpAgentTools", { enumerable: true, get: function () { return toolAdapter_1.getAllMcpAgentTools; } });
|
|
22
|
+
var authFailure_1 = require("./authFailure");
|
|
23
|
+
Object.defineProperty(exports, "looksLikeAuthFailure", { enumerable: true, get: function () { return authFailure_1.looksLikeAuthFailure; } });
|
|
24
|
+
Object.defineProperty(exports, "describeMcpAuthFailure", { enumerable: true, get: function () { return authFailure_1.describeMcpAuthFailure; } });
|
|
25
|
+
Object.defineProperty(exports, "formatMcpToolError", { enumerable: true, get: function () { return authFailure_1.formatMcpToolError; } });
|
|
22
26
|
var server_1 = require("./server");
|
|
23
27
|
Object.defineProperty(exports, "serveBanditMcp", { enumerable: true, get: function () { return server_1.serveBanditMcp; } });
|
|
24
28
|
var activation_1 = require("./activation");
|
package/dist/mcp/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;AAEH,2CAOsB;AANpB,2GAAA,aAAa,OAAA;AACb,qHAAA,uBAAuB,OAAA;AAMzB,6CAAwE;AAA/D,iHAAA,kBAAkB,OAAA;AAAE,kHAAA,mBAAmB,OAAA;AAChD,mCAA0C;AAAjC,wGAAA,cAAc,OAAA;AACvB,2CAIsB;AAHpB,kHAAA,oBAAoB,OAAA;AACpB,+GAAA,iBAAiB,OAAA;AACjB,+GAAA,iBAAiB,OAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;AAEH,2CAOsB;AANpB,2GAAA,aAAa,OAAA;AACb,qHAAA,uBAAuB,OAAA;AAMzB,6CAAwE;AAA/D,iHAAA,kBAAkB,OAAA;AAAE,kHAAA,mBAAmB,OAAA;AAChD,6CAAsH;AAA7G,mHAAA,oBAAoB,OAAA;AAAE,qHAAA,sBAAsB,OAAA;AAAE,iHAAA,kBAAkB,OAAA;AACzE,mCAA0C;AAAjC,wGAAA,cAAc,OAAA;AACvB,2CAIsB;AAHpB,kHAAA,oBAAoB,OAAA;AACpB,+GAAA,iBAAiB,OAAA;AACjB,+GAAA,iBAAiB,OAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toolAdapter.d.ts","sourceRoot":"","sources":["../../src/mcp/toolAdapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAkF,MAAM,qBAAqB,CAAC;AACrI,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"toolAdapter.d.ts","sourceRoot":"","sources":["../../src/mcp/toolAdapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAkF,MAAM,qBAAqB,CAAC;AACrI,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAUlD,UAAU,cAAc;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAC5C,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB,IAAI,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC;CACzC;AAED,UAAU,aAAa;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,cAAc,CAAC;CAC9B;AAiFD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,aAAa,EACrB,IAAI,EAAE,aAAa,GAClB,SAAS,CAuEX;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,aAAa,EACnB,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,SAAS,EAAE,CAAC,CAqBtB"}
|
package/dist/mcp/toolAdapter.js
CHANGED
|
@@ -16,6 +16,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
16
16
|
exports.mcpToolToAgentTool = mcpToolToAgentTool;
|
|
17
17
|
exports.getAllMcpAgentTools = getAllMcpAgentTools;
|
|
18
18
|
const activation_1 = require("./activation");
|
|
19
|
+
const authFailure_1 = require("./authFailure");
|
|
19
20
|
/**
|
|
20
21
|
* Translate one MCP JSON-Schema node into the slimmer
|
|
21
22
|
* AgentToolParameterSchema shape. Recursive for object properties and
|
|
@@ -174,12 +175,21 @@ function mcpToolToAgentTool(serverName, remote, pool) {
|
|
|
174
175
|
}
|
|
175
176
|
}
|
|
176
177
|
const result = await pool.callTool(serverName, remote.name, args);
|
|
177
|
-
|
|
178
|
+
const rendered = renderMcpResult(result);
|
|
179
|
+
// A server can also report auth failure as a normal isError result
|
|
180
|
+
// rather than throwing — same recovery either way.
|
|
181
|
+
if (rendered.isError && (0, authFailure_1.looksLikeAuthFailure)(rendered.output)) {
|
|
182
|
+
return {
|
|
183
|
+
output: (0, authFailure_1.describeMcpAuthFailure)({ server: serverName, original: rendered.output }),
|
|
184
|
+
isError: true
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
return rendered;
|
|
178
188
|
}
|
|
179
189
|
catch (err) {
|
|
180
190
|
const msg = err instanceof Error ? err.message : String(err);
|
|
181
191
|
return {
|
|
182
|
-
output:
|
|
192
|
+
output: (0, authFailure_1.formatMcpToolError)(namespacedName, serverName, msg),
|
|
183
193
|
isError: true
|
|
184
194
|
};
|
|
185
195
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toolAdapter.js","sourceRoot":"","sources":["../../src/mcp/toolAdapter.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;
|
|
1
|
+
{"version":3,"file":"toolAdapter.js","sourceRoot":"","sources":["../../src/mcp/toolAdapter.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;AAkHH,gDA2EC;AAoBD,kDAwBC;AArOD,6CAAuE;AACvE,+CAAiG;AAuBjG;;;;;;;GAOG;AACH,SAAS,aAAa,CAAC,IAAgC;IACrD,IAAI,CAAC,IAAI,EAAE,CAAC;QAAA,OAAO,SAAS,CAAC;IAAA,CAAC;IAC9B,MAAM,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC;IACpB,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC;IAC/F,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QAAA,OAAO,SAAS,CAAC;IAAA,CAAC;IAC7C,MAAM,GAAG,GAA6B,EAAE,CAAC;IACzC,IAAI,CAAC,EAAE,CAAC;QAAA,GAAG,CAAC,IAAI,GAAG,CAAqC,CAAC;IAAA,CAAC;IAC1D,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;QAAA,GAAG,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;IAAA,CAAC;IAC3D,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;QAAA,GAAG,CAAC,IAAI,GAAG,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