@corsair-dev/mcp 0.1.9 → 0.1.10
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 +13 -0
- package/dist/adapters/anthropic-api.d.ts.map +1 -0
- package/dist/adapters/openai-agents.d.ts +10 -0
- package/dist/adapters/openai-agents.d.ts.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +79 -11
- package/package.json +8 -2
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Tool } from '@anthropic-ai/sdk/resources';
|
|
2
|
+
import { BaseProvider } from '../core/provider.js';
|
|
3
|
+
import type { CorsairToolDef } from '../core/tools.js';
|
|
4
|
+
type CorsairAnthropicTool = Tool & {
|
|
5
|
+
run: (args: Record<string, unknown>) => Promise<string>;
|
|
6
|
+
parse: (content: unknown) => Record<string, unknown>;
|
|
7
|
+
};
|
|
8
|
+
export declare class AnthropicProvider extends BaseProvider<CorsairAnthropicTool> {
|
|
9
|
+
readonly name = "anthropic";
|
|
10
|
+
wrapTool(def: CorsairToolDef): CorsairAnthropicTool;
|
|
11
|
+
}
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=anthropic-api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anthropic-api.d.ts","sourceRoot":"","sources":["../../src/adapters/anthropic-api.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,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;CAuBnD"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { tool as AgentsTool, Tool } from '@openai/agents';
|
|
2
|
+
import type { BaseMcpOptions } from '../core/adapters.js';
|
|
3
|
+
export type OpenAIAgentsProviderOptions = BaseMcpOptions & {
|
|
4
|
+
tool: typeof AgentsTool;
|
|
5
|
+
};
|
|
6
|
+
export declare class OpenAIAgentsProvider {
|
|
7
|
+
readonly name = "openai-agents";
|
|
8
|
+
build(options: OpenAIAgentsProviderOptions): Tool<unknown>[];
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=openai-agents.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai-agents.d.ts","sourceRoot":"","sources":["../../src/adapters/openai-agents.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,IAAI,UAAU,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAG1D,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;CA0C5D"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
export { AnthropicProvider } from './adapters/anthropic-api.js';
|
|
1
2
|
export { ClaudeProvider } from './adapters/claude.js';
|
|
2
3
|
export { MastraProvider } from './adapters/mastra.js';
|
|
4
|
+
export type { OpenAIAgentsProviderOptions } from './adapters/openai-agents.js';
|
|
5
|
+
export { OpenAIAgentsProvider } from './adapters/openai-agents.js';
|
|
3
6
|
export type { OpenAIMcpConfig } from './adapters/openai.js';
|
|
4
7
|
export { getOpenAIMcpConfig } from './adapters/openai.js';
|
|
5
8
|
export type { VercelAiMcpClientOptions } from './adapters/vercel-ai.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,YAAY,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,YAAY,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AACxE,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAClE,YAAY,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,YAAY,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,YAAY,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAC;AAC/E,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,YAAY,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,YAAY,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AACxE,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAClE,YAAY,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,YAAY,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
// src/adapters/anthropic-api.ts
|
|
2
|
+
import { z as z2 } from "zod";
|
|
3
|
+
import { zodToJsonSchema } from "zod-to-json-schema";
|
|
4
|
+
|
|
1
5
|
// src/core/tools.ts
|
|
2
6
|
import { setupCorsair } from "corsair";
|
|
3
7
|
import { z } from "zod";
|
|
@@ -135,6 +139,37 @@ ${full}`
|
|
|
135
139
|
return defs;
|
|
136
140
|
}
|
|
137
141
|
|
|
142
|
+
// src/core/provider.ts
|
|
143
|
+
var BaseProvider = class {
|
|
144
|
+
build(options) {
|
|
145
|
+
return buildCorsairToolDefs(options).map((def) => this.wrapTool(def));
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
// src/adapters/anthropic-api.ts
|
|
150
|
+
var AnthropicProvider = class extends BaseProvider {
|
|
151
|
+
name = "anthropic";
|
|
152
|
+
wrapTool(def) {
|
|
153
|
+
const schema = zodToJsonSchema(z2.object(def.shape), { target: "openApi3" });
|
|
154
|
+
return {
|
|
155
|
+
type: "custom",
|
|
156
|
+
name: def.name,
|
|
157
|
+
description: def.description,
|
|
158
|
+
input_schema: schema,
|
|
159
|
+
run: async (args) => {
|
|
160
|
+
try {
|
|
161
|
+
const result = await def.handler(args);
|
|
162
|
+
return result.content.filter((c) => c.type === "text").map((c) => "text" in c ? c.text : "").join("\n");
|
|
163
|
+
} catch (err) {
|
|
164
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
165
|
+
return `Error: ${message}`;
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
parse: (content) => z2.object(def.shape).parse(content)
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
|
|
138
173
|
// src/adapters/claude.ts
|
|
139
174
|
var ClaudeProvider = class {
|
|
140
175
|
name = "claude";
|
|
@@ -147,7 +182,7 @@ var ClaudeProvider = class {
|
|
|
147
182
|
};
|
|
148
183
|
|
|
149
184
|
// src/adapters/mastra.ts
|
|
150
|
-
import { z as
|
|
185
|
+
import { z as z3 } from "zod";
|
|
151
186
|
var MastraProvider = class {
|
|
152
187
|
name = "mastra";
|
|
153
188
|
async build(options) {
|
|
@@ -156,7 +191,7 @@ var MastraProvider = class {
|
|
|
156
191
|
(def) => createTool({
|
|
157
192
|
id: def.name,
|
|
158
193
|
description: def.description,
|
|
159
|
-
inputSchema:
|
|
194
|
+
inputSchema: z3.object(def.shape),
|
|
160
195
|
execute: async (inputData) => {
|
|
161
196
|
const result = await def.handler(
|
|
162
197
|
inputData
|
|
@@ -177,6 +212,44 @@ var MastraProvider = class {
|
|
|
177
212
|
}
|
|
178
213
|
};
|
|
179
214
|
|
|
215
|
+
// src/adapters/openai-agents.ts
|
|
216
|
+
import { z as z4 } from "zod";
|
|
217
|
+
import { zodToJsonSchema as zodToJsonSchema2 } from "zod-to-json-schema";
|
|
218
|
+
var OpenAIAgentsProvider = class {
|
|
219
|
+
name = "openai-agents";
|
|
220
|
+
build(options) {
|
|
221
|
+
const { tool, ...mcpOptions } = options;
|
|
222
|
+
return buildCorsairToolDefs(mcpOptions).map((def) => {
|
|
223
|
+
const jsonSchema = zodToJsonSchema2(z4.object(def.shape));
|
|
224
|
+
const shapeKeys = new Set(Object.keys(def.shape));
|
|
225
|
+
return tool({
|
|
226
|
+
name: def.name,
|
|
227
|
+
description: def.description,
|
|
228
|
+
parameters: jsonSchema,
|
|
229
|
+
strict: false,
|
|
230
|
+
execute: async (input) => {
|
|
231
|
+
try {
|
|
232
|
+
const raw = typeof input === "string" ? JSON.parse(input) : input;
|
|
233
|
+
if (shapeKeys.has("args") && typeof raw.args !== "object") {
|
|
234
|
+
const extra = {};
|
|
235
|
+
for (const [k, v] of Object.entries(raw)) {
|
|
236
|
+
if (!shapeKeys.has(k)) extra[k] = v;
|
|
237
|
+
}
|
|
238
|
+
if (Object.keys(extra).length > 0) raw.args = extra;
|
|
239
|
+
}
|
|
240
|
+
const args = z4.object(def.shape).parse(raw);
|
|
241
|
+
const result = await def.handler(args);
|
|
242
|
+
return result.content.filter((c) => c.type === "text").map((c) => "text" in c ? c.text : "").join("\n");
|
|
243
|
+
} catch (err) {
|
|
244
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
245
|
+
return `Error: ${message}`;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
|
|
180
253
|
// src/adapters/openai.ts
|
|
181
254
|
function getOpenAIMcpConfig(baseUrl, headers) {
|
|
182
255
|
return {
|
|
@@ -202,7 +275,7 @@ async function createVercelAiMcpClient(options) {
|
|
|
202
275
|
|
|
203
276
|
// src/core/base.ts
|
|
204
277
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
205
|
-
import { z as
|
|
278
|
+
import { z as z5 } from "zod";
|
|
206
279
|
function createBaseMcpServer(options) {
|
|
207
280
|
const server = new McpServer({
|
|
208
281
|
name: "corsair",
|
|
@@ -212,7 +285,7 @@ function createBaseMcpServer(options) {
|
|
|
212
285
|
for (const def of buildCorsairToolDefs(options)) {
|
|
213
286
|
server.registerTool(
|
|
214
287
|
def.name,
|
|
215
|
-
{ description: def.description, inputSchema:
|
|
288
|
+
{ description: def.description, inputSchema: z5.object(def.shape) },
|
|
216
289
|
def.handler
|
|
217
290
|
);
|
|
218
291
|
}
|
|
@@ -278,13 +351,6 @@ function createMcpRouter(createServer) {
|
|
|
278
351
|
return router;
|
|
279
352
|
}
|
|
280
353
|
|
|
281
|
-
// src/core/provider.ts
|
|
282
|
-
var BaseProvider = class {
|
|
283
|
-
build(options) {
|
|
284
|
-
return buildCorsairToolDefs(options).map((def) => this.wrapTool(def));
|
|
285
|
-
}
|
|
286
|
-
};
|
|
287
|
-
|
|
288
354
|
// src/core/stdio.ts
|
|
289
355
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
290
356
|
async function runStdioMcpServer(options) {
|
|
@@ -293,9 +359,11 @@ async function runStdioMcpServer(options) {
|
|
|
293
359
|
await server.connect(transport);
|
|
294
360
|
}
|
|
295
361
|
export {
|
|
362
|
+
AnthropicProvider,
|
|
296
363
|
BaseProvider,
|
|
297
364
|
ClaudeProvider,
|
|
298
365
|
MastraProvider,
|
|
366
|
+
OpenAIAgentsProvider,
|
|
299
367
|
createBaseMcpServer,
|
|
300
368
|
createMcpRouter,
|
|
301
369
|
createVercelAiMcpClient,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@corsair-dev/mcp",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.10",
|
|
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",
|
|
@@ -20,11 +20,13 @@
|
|
|
20
20
|
"@modelcontextprotocol/sdk": "^1.27.1",
|
|
21
21
|
"express": "^4.21.0",
|
|
22
22
|
"zod": "^3.25.0",
|
|
23
|
-
"
|
|
23
|
+
"zod-to-json-schema": "^3.25.0",
|
|
24
|
+
"corsair": "0.1.35"
|
|
24
25
|
},
|
|
25
26
|
"peerDependencies": {
|
|
26
27
|
"@ai-sdk/mcp": ">=0.0.1",
|
|
27
28
|
"@anthropic-ai/claude-agent-sdk": ">=0.2.0",
|
|
29
|
+
"@anthropic-ai/sdk": ">=0.78.0",
|
|
28
30
|
"@mastra/core": ">=1.0.0",
|
|
29
31
|
"@openai/agents": ">=0.5.0"
|
|
30
32
|
},
|
|
@@ -35,6 +37,9 @@
|
|
|
35
37
|
"@anthropic-ai/claude-agent-sdk": {
|
|
36
38
|
"optional": true
|
|
37
39
|
},
|
|
40
|
+
"@anthropic-ai/sdk": {
|
|
41
|
+
"optional": true
|
|
42
|
+
},
|
|
38
43
|
"@mastra/core": {
|
|
39
44
|
"optional": true
|
|
40
45
|
},
|
|
@@ -43,6 +48,7 @@
|
|
|
43
48
|
}
|
|
44
49
|
},
|
|
45
50
|
"devDependencies": {
|
|
51
|
+
"@anthropic-ai/sdk": "^0.78.0",
|
|
46
52
|
"@types/express": "^4.17.21",
|
|
47
53
|
"@types/node": "^22.0.0",
|
|
48
54
|
"tsup": "^8.0.1",
|