@corsair-dev/mcp 0.1.25 → 0.1.26
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/adapters/anthropic-api.d.ts.map +1 -1
- package/dist/adapters/mastra.d.ts.map +1 -1
- package/dist/adapters/ollama.d.ts.map +1 -1
- package/dist/adapters/openai-agents.d.ts.map +1 -1
- package/dist/core/tool-result.d.ts +8 -0
- package/dist/core/tool-result.d.ts.map +1 -0
- package/dist/core/tools.d.ts +1 -0
- package/dist/core/tools.d.ts.map +1 -1
- package/dist/index.js +55 -30
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anthropic-api.d.ts","sourceRoot":"","sources":["../../src/adapters/anthropic-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AAGxD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"anthropic-api.d.ts","sourceRoot":"","sources":["../../src/adapters/anthropic-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AAGxD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAKvD,KAAK,oBAAoB,GAAG,IAAI,GAAG;IAClC,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IACxD,KAAK,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACrD,CAAC;AAEF,qBAAa,iBAAkB,SAAQ,YAAY,CAAC,oBAAoB,CAAC;IACxE,QAAQ,CAAC,IAAI,eAAe;IAE5B,QAAQ,CAAC,GAAG,EAAE,cAAc,GAAG,oBAAoB;CAoBnD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mastra.d.ts","sourceRoot":"","sources":["../../src/adapters/mastra.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"mastra.d.ts","sourceRoot":"","sources":["../../src/adapters/mastra.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAM1D,qBAAa,cAAc;IAC1B,QAAQ,CAAC,IAAI,YAAY;IAEnB,KAAK,CAAC,OAAO,EAAE,cAAc;CAuBnC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ollama.d.ts","sourceRoot":"","sources":["../../src/adapters/ollama.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"ollama.d.ts","sourceRoot":"","sources":["../../src/adapters/ollama.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,MAAM,MAAM,iBAAiB,GAAG;IAC/B,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,EAAE;QACT,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;QACpB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACpC,CAAC;IACF,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;CAC5D,CAAC;AAKF,qBAAa,cAAe,SAAQ,YAAY,CAAC,iBAAiB,CAAC;IAClE,QAAQ,CAAC,IAAI,YAAY;IAEzB,QAAQ,CAAC,GAAG,EAAE,cAAc,GAAG,iBAAiB;CAkChD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai-agents.d.ts","sourceRoot":"","sources":["../../src/adapters/openai-agents.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,IAAI,UAAU,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAE/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"openai-agents.d.ts","sourceRoot":"","sources":["../../src/adapters/openai-agents.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,IAAI,UAAU,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAE/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAK1D,MAAM,MAAM,2BAA2B,GAAG,cAAc,GAAG;IAC1D,IAAI,EAAE,OAAO,UAAU,CAAC;CACxB,CAAC;AAEF,qBAAa,oBAAoB;IAChC,QAAQ,CAAC,IAAI,mBAAmB;IAEhC,KAAK,CAAC,OAAO,EAAE,2BAA2B,GAAG,IAAI,CAAC,OAAO,CAAC,EAAE;CAuC5D"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
+
export declare function isAgentFacingActionMessage(value: unknown): value is string;
|
|
3
|
+
export declare function isActionToolError(err: unknown): boolean;
|
|
4
|
+
export declare function toolErrorResult(message: string): CallToolResult;
|
|
5
|
+
export declare function formatRunScriptResult(result: unknown): CallToolResult;
|
|
6
|
+
export declare function formatRunScriptError(err: unknown): CallToolResult;
|
|
7
|
+
export declare function callToolResultToText(result: CallToolResult): string;
|
|
8
|
+
//# sourceMappingURL=tool-result.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-result.d.ts","sourceRoot":"","sources":["../../src/core/tool-result.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAGzE,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAc1E;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAMvD;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,cAAc,CAK/D;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,OAAO,GAAG,cAAc,CAarE;AAED,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,OAAO,GAAG,cAAc,CAYjE;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,CAWnE"}
|
package/dist/core/tools.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import type { BaseMcpOptions } from './adapters.js';
|
|
4
|
+
export { callToolResultToText, formatRunScriptError, formatRunScriptResult, isActionToolError, isAgentFacingActionMessage, toolErrorResult, } from './tool-result.js';
|
|
4
5
|
export type CorsairToolDef = {
|
|
5
6
|
name: string;
|
|
6
7
|
description: string;
|
package/dist/core/tools.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/core/tools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAGzE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/core/tools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAGzE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAIpD,OAAO,EACN,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,iBAAiB,EACjB,0BAA0B,EAC1B,eAAe,GACf,MAAM,kBAAkB,CAAC;AAE1B,MAAM,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,CAAC,CAAC,WAAW,CAAC;IACrB,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC;CACpE,CAAC;AAEF,wBAAgB,oBAAoB,CACnC,OAAO,EAAE,cAAc,GACrB,cAAc,EAAE,CAkFlB"}
|
package/dist/index.js
CHANGED
|
@@ -21,6 +21,55 @@ function formatGetSchemaResponse(corsair, path) {
|
|
|
21
21
|
return getSchema(corsair, path);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
// src/core/tool-result.ts
|
|
25
|
+
import { AuthMissingError, PermissionRequiredError } from "corsair";
|
|
26
|
+
function isAgentFacingActionMessage(value) {
|
|
27
|
+
if (typeof value !== "string") {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
return value.includes("[auth-missing:") || value.startsWith("Approval required. Visit") || value.includes(" requires user approval before it can run") || value.includes(" was denied by the user") || value.includes(" is blocked by the permission policy") || value.includes(" timed out waiting for approval") || value.includes("Could not create approval link");
|
|
31
|
+
}
|
|
32
|
+
function isActionToolError(err) {
|
|
33
|
+
return err instanceof AuthMissingError || err instanceof PermissionRequiredError || err instanceof Error && isAgentFacingActionMessage(err.message);
|
|
34
|
+
}
|
|
35
|
+
function toolErrorResult(message) {
|
|
36
|
+
return {
|
|
37
|
+
isError: true,
|
|
38
|
+
content: [{ type: "text", text: message }]
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function formatRunScriptResult(result) {
|
|
42
|
+
if (isAgentFacingActionMessage(result)) {
|
|
43
|
+
return toolErrorResult(result);
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
content: [
|
|
47
|
+
{
|
|
48
|
+
type: "text",
|
|
49
|
+
text: JSON.stringify(result ?? null, null, 2)
|
|
50
|
+
}
|
|
51
|
+
]
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function formatRunScriptError(err) {
|
|
55
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
56
|
+
if (isActionToolError(err)) {
|
|
57
|
+
return toolErrorResult(message);
|
|
58
|
+
}
|
|
59
|
+
const extra = err instanceof Error && err.cause ? `
|
|
60
|
+
Cause: ${String(err.cause)}` : "";
|
|
61
|
+
const full = JSON.stringify(err, Object.getOwnPropertyNames(err));
|
|
62
|
+
return toolErrorResult(`Error running snippet: ${message}${extra}
|
|
63
|
+
${full}`);
|
|
64
|
+
}
|
|
65
|
+
function callToolResultToText(result) {
|
|
66
|
+
const text = result.content.filter((c) => c.type === "text").map((c) => "text" in c ? c.text : "").join("\n");
|
|
67
|
+
if (result.isError) {
|
|
68
|
+
throw new Error(text);
|
|
69
|
+
}
|
|
70
|
+
return text;
|
|
71
|
+
}
|
|
72
|
+
|
|
24
73
|
// src/core/tools.ts
|
|
25
74
|
function buildCorsairToolDefs(options) {
|
|
26
75
|
const { corsair, runOptions } = options;
|
|
@@ -77,29 +126,9 @@ function buildCorsairToolDefs(options) {
|
|
|
77
126
|
);
|
|
78
127
|
const invoke = () => fn(corsair);
|
|
79
128
|
const result = readonly ? await runReadonly(invoke) : await invoke();
|
|
80
|
-
return
|
|
81
|
-
content: [
|
|
82
|
-
{
|
|
83
|
-
type: "text",
|
|
84
|
-
text: JSON.stringify(result ?? null, null, 2)
|
|
85
|
-
}
|
|
86
|
-
]
|
|
87
|
-
};
|
|
129
|
+
return formatRunScriptResult(result);
|
|
88
130
|
} catch (err) {
|
|
89
|
-
|
|
90
|
-
const extra = err instanceof Error && err.cause ? `
|
|
91
|
-
Cause: ${String(err.cause)}` : "";
|
|
92
|
-
const full = JSON.stringify(err, Object.getOwnPropertyNames(err));
|
|
93
|
-
return {
|
|
94
|
-
isError: true,
|
|
95
|
-
content: [
|
|
96
|
-
{
|
|
97
|
-
type: "text",
|
|
98
|
-
text: `Error running snippet: ${message}${extra}
|
|
99
|
-
${full}`
|
|
100
|
-
}
|
|
101
|
-
]
|
|
102
|
-
};
|
|
131
|
+
return formatRunScriptError(err);
|
|
103
132
|
}
|
|
104
133
|
}
|
|
105
134
|
}
|
|
@@ -127,7 +156,7 @@ var AnthropicProvider = class extends BaseProvider {
|
|
|
127
156
|
run: async (args) => {
|
|
128
157
|
try {
|
|
129
158
|
const result = await def.handler(args);
|
|
130
|
-
return result
|
|
159
|
+
return callToolResultToText(result);
|
|
131
160
|
} catch (err) {
|
|
132
161
|
const message = err instanceof Error ? err.message : String(err);
|
|
133
162
|
return `Error: ${message}`;
|
|
@@ -172,11 +201,7 @@ var MastraProvider = class {
|
|
|
172
201
|
const result = await def.handler(
|
|
173
202
|
inputData
|
|
174
203
|
);
|
|
175
|
-
const
|
|
176
|
-
if (result.isError) {
|
|
177
|
-
throw new Error(textItems.map((c) => c.text).join("\n"));
|
|
178
|
-
}
|
|
179
|
-
const text = textItems[0]?.text ?? "";
|
|
204
|
+
const text = callToolResultToText(result);
|
|
180
205
|
try {
|
|
181
206
|
return JSON.parse(text);
|
|
182
207
|
} catch {
|
|
@@ -215,7 +240,7 @@ var OllamaProvider = class extends BaseProvider {
|
|
|
215
240
|
const raw = typeof args === "string" ? JSON.parse(args) : args;
|
|
216
241
|
const validated = z5.object(def.shape).parse(raw);
|
|
217
242
|
const result = await def.handler(validated);
|
|
218
|
-
return result
|
|
243
|
+
return callToolResultToText(result);
|
|
219
244
|
} catch (err) {
|
|
220
245
|
const message = err instanceof Error ? err.message : String(err);
|
|
221
246
|
return `Error: ${message}`;
|
|
@@ -260,7 +285,7 @@ var OpenAIAgentsProvider = class {
|
|
|
260
285
|
}
|
|
261
286
|
const args = z6.object(def.shape).parse(raw);
|
|
262
287
|
const result = await def.handler(args);
|
|
263
|
-
return result
|
|
288
|
+
return callToolResultToText(result);
|
|
264
289
|
} catch (err) {
|
|
265
290
|
const message = err instanceof Error ? err.message : String(err);
|
|
266
291
|
return `Error: ${message}`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@corsair-dev/mcp",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.26",
|
|
4
4
|
"description": "MCP server and SDK adapters for Corsair — list operations, inspect schemas, run API calls",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"@modelcontextprotocol/sdk": "^1.27.1",
|
|
22
22
|
"express": "^4.21.0",
|
|
23
23
|
"zod": "^4.1.13",
|
|
24
|
-
"corsair": "0.1.
|
|
24
|
+
"corsair": "0.1.108"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"@anthropic-ai/claude-agent-sdk": ">=0.2.0",
|