@corsair-dev/mcp 0.1.9 → 0.1.11

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.
@@ -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":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AAGxD,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":"AAAA,OAAO,KAAK,EAAE,IAAI,IAAI,UAAU,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAG/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;CA4C5D"}
@@ -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;AAEzE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD,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,CAkKlB"}
1
+ {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/core/tools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAEzE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD,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,CAwKlB"}
package/dist/index.d.ts CHANGED
@@ -1,7 +1,10 @@
1
+ export { AnthropicProvider } from './adapters/anthropic-api.js';
1
2
  export { ClaudeProvider } from './adapters/claude.js';
2
3
  export { MastraProvider } from './adapters/mastra.js';
3
4
  export type { OpenAIMcpConfig } from './adapters/openai.js';
4
5
  export { getOpenAIMcpConfig } from './adapters/openai.js';
6
+ export type { OpenAIAgentsProviderOptions } from './adapters/openai-agents.js';
7
+ export { OpenAIAgentsProvider } from './adapters/openai-agents.js';
5
8
  export type { VercelAiMcpClientOptions } from './adapters/vercel-ai.js';
6
9
  export { createVercelAiMcpClient } from './adapters/vercel-ai.js';
7
10
  export type { BaseMcpOptions, PermissionAdapter } from './core/adapters.js';
@@ -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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O,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";
@@ -81,11 +85,17 @@ ${full}`
81
85
  handler: async () => {
82
86
  try {
83
87
  if (Object.keys(corsair).includes("withTenant")) {
84
- throw new Error("Cannot setup Corsair if it multiTenancy is enabled.");
88
+ throw new Error(
89
+ "Cannot setup Corsair if it multiTenancy is enabled."
90
+ );
85
91
  }
86
- const text = await setupCorsair(corsair);
92
+ const text = await setupCorsair(
93
+ corsair
94
+ );
87
95
  return {
88
- content: [{ type: "text", text: text || "Corsair setup complete." }]
96
+ content: [
97
+ { type: "text", text: text || "Corsair setup complete." }
98
+ ]
89
99
  };
90
100
  } catch (err) {
91
101
  const message = err instanceof Error ? err.message : String(err);
@@ -135,6 +145,37 @@ ${full}`
135
145
  return defs;
136
146
  }
137
147
 
148
+ // src/core/provider.ts
149
+ var BaseProvider = class {
150
+ build(options) {
151
+ return buildCorsairToolDefs(options).map((def) => this.wrapTool(def));
152
+ }
153
+ };
154
+
155
+ // src/adapters/anthropic-api.ts
156
+ var AnthropicProvider = class extends BaseProvider {
157
+ name = "anthropic";
158
+ wrapTool(def) {
159
+ const schema = zodToJsonSchema(z2.object(def.shape), { target: "openApi3" });
160
+ return {
161
+ type: "custom",
162
+ name: def.name,
163
+ description: def.description,
164
+ input_schema: schema,
165
+ run: async (args) => {
166
+ try {
167
+ const result = await def.handler(args);
168
+ return result.content.filter((c) => c.type === "text").map((c) => "text" in c ? c.text : "").join("\n");
169
+ } catch (err) {
170
+ const message = err instanceof Error ? err.message : String(err);
171
+ return `Error: ${message}`;
172
+ }
173
+ },
174
+ parse: (content) => z2.object(def.shape).parse(content)
175
+ };
176
+ }
177
+ };
178
+
138
179
  // src/adapters/claude.ts
139
180
  var ClaudeProvider = class {
140
181
  name = "claude";
@@ -147,7 +188,7 @@ var ClaudeProvider = class {
147
188
  };
148
189
 
149
190
  // src/adapters/mastra.ts
150
- import { z as z2 } from "zod";
191
+ import { z as z3 } from "zod";
151
192
  var MastraProvider = class {
152
193
  name = "mastra";
153
194
  async build(options) {
@@ -156,7 +197,7 @@ var MastraProvider = class {
156
197
  (def) => createTool({
157
198
  id: def.name,
158
199
  description: def.description,
159
- inputSchema: z2.object(def.shape),
200
+ inputSchema: z3.object(def.shape),
160
201
  execute: async (inputData) => {
161
202
  const result = await def.handler(
162
203
  inputData
@@ -186,6 +227,44 @@ function getOpenAIMcpConfig(baseUrl, headers) {
186
227
  };
187
228
  }
188
229
 
230
+ // src/adapters/openai-agents.ts
231
+ import { z as z4 } from "zod";
232
+ import { zodToJsonSchema as zodToJsonSchema2 } from "zod-to-json-schema";
233
+ var OpenAIAgentsProvider = class {
234
+ name = "openai-agents";
235
+ build(options) {
236
+ const { tool, ...mcpOptions } = options;
237
+ return buildCorsairToolDefs(mcpOptions).map((def) => {
238
+ const jsonSchema = zodToJsonSchema2(z4.object(def.shape));
239
+ const shapeKeys = new Set(Object.keys(def.shape));
240
+ return tool({
241
+ name: def.name,
242
+ description: def.description,
243
+ parameters: jsonSchema,
244
+ strict: false,
245
+ execute: async (input) => {
246
+ try {
247
+ const raw = typeof input === "string" ? JSON.parse(input) : input;
248
+ if (shapeKeys.has("args") && typeof raw.args !== "object") {
249
+ const extra = {};
250
+ for (const [k, v] of Object.entries(raw)) {
251
+ if (!shapeKeys.has(k)) extra[k] = v;
252
+ }
253
+ if (Object.keys(extra).length > 0) raw.args = extra;
254
+ }
255
+ const args = z4.object(def.shape).parse(raw);
256
+ const result = await def.handler(args);
257
+ return result.content.filter((c) => c.type === "text").map((c) => "text" in c ? c.text : "").join("\n");
258
+ } catch (err) {
259
+ const message = err instanceof Error ? err.message : String(err);
260
+ return `Error: ${message}`;
261
+ }
262
+ }
263
+ });
264
+ });
265
+ }
266
+ };
267
+
189
268
  // src/adapters/vercel-ai.ts
190
269
  async function createVercelAiMcpClient(options) {
191
270
  const { createMCPClient } = await import("@ai-sdk/mcp");
@@ -202,7 +281,7 @@ async function createVercelAiMcpClient(options) {
202
281
 
203
282
  // src/core/base.ts
204
283
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
205
- import { z as z3 } from "zod";
284
+ import { z as z5 } from "zod";
206
285
  function createBaseMcpServer(options) {
207
286
  const server = new McpServer({
208
287
  name: "corsair",
@@ -212,7 +291,7 @@ function createBaseMcpServer(options) {
212
291
  for (const def of buildCorsairToolDefs(options)) {
213
292
  server.registerTool(
214
293
  def.name,
215
- { description: def.description, inputSchema: z3.object(def.shape) },
294
+ { description: def.description, inputSchema: z5.object(def.shape) },
216
295
  def.handler
217
296
  );
218
297
  }
@@ -278,13 +357,6 @@ function createMcpRouter(createServer) {
278
357
  return router;
279
358
  }
280
359
 
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
360
  // src/core/stdio.ts
289
361
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
290
362
  async function runStdioMcpServer(options) {
@@ -293,9 +365,11 @@ async function runStdioMcpServer(options) {
293
365
  await server.connect(transport);
294
366
  }
295
367
  export {
368
+ AnthropicProvider,
296
369
  BaseProvider,
297
370
  ClaudeProvider,
298
371
  MastraProvider,
372
+ OpenAIAgentsProvider,
299
373
  createBaseMcpServer,
300
374
  createMcpRouter,
301
375
  createVercelAiMcpClient,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@corsair-dev/mcp",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
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
- "corsair": "0.1.34"
23
+ "zod-to-json-schema": "^3.25.0",
24
+ "corsair": "0.1.36"
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",