@corsair-dev/mcp 0.1.8 → 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.
@@ -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"}
@@ -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,CAmMlB"}
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"}
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';
@@ -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,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AAC;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";
@@ -37,47 +41,21 @@ function buildCorsairToolDefs(options) {
37
41
  }
38
42
  },
39
43
  {
40
- name: "corsair_run",
41
- description: "Execute any Corsair API endpoint by its dot-path. Use list_operations to discover paths and get_schema to understand required args. Example path: 'slack.api.channels.list'.",
44
+ name: "run_script",
45
+ description: "Run a JavaScript script with `corsair` as the only variable in scope. Call Corsair operations, filter or transform the results inline, and return only what you need. The return value becomes the tool output.",
42
46
  shape: {
43
- path: z.string().describe("Full API dot-path, e.g. 'slack.api.messages.post'"),
44
- args: z.record(z.unknown()).default({}).describe("Arguments object for the operation")
47
+ code: z.string().describe(
48
+ 'Async JS script with `corsair` in scope. Return the value you want. Example:\nconst result = await corsair.slack.api.channels.list({});\nconst channel = result.channels?.find(c => c.name === "general");\nreturn channel?.id;'
49
+ )
45
50
  },
46
- handler: async ({ path, args }) => {
47
- const parts = path.split(".");
48
- if (parts.length < 3) {
49
- return {
50
- isError: true,
51
- content: [
52
- {
53
- type: "text",
54
- text: `Invalid path "${path}". Expected format: "plugin.api.group.method". Use list_operations to see valid paths.`
55
- }
56
- ]
57
- };
58
- }
59
- let fn = corsair;
60
- for (const part of parts) {
61
- if (typeof fn !== "object" || fn === null) {
62
- fn = void 0;
63
- break;
64
- }
65
- fn = fn[part];
66
- }
67
- if (typeof fn !== "function") {
68
- return {
69
- isError: true,
70
- content: [
71
- {
72
- type: "text",
73
- text: `Path "${path}" is not a callable operation. Use list_operations to see valid paths.`
74
- }
75
- ]
76
- };
77
- }
51
+ handler: async ({ code }) => {
78
52
  try {
53
+ const fn = new Function(
54
+ "corsair",
55
+ `return (async () => { ${code} })()`
56
+ );
79
57
  const result = await fn(
80
- args
58
+ corsair
81
59
  );
82
60
  return {
83
61
  content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
@@ -92,7 +70,7 @@ Cause: ${String(err.cause)}` : "";
92
70
  content: [
93
71
  {
94
72
  type: "text",
95
- text: `Error running "${path}": ${message}${extra}
73
+ text: `Error running snippet: ${message}${extra}
96
74
  ${full}`
97
75
  }
98
76
  ]
@@ -161,6 +139,37 @@ ${full}`
161
139
  return defs;
162
140
  }
163
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
+
164
173
  // src/adapters/claude.ts
165
174
  var ClaudeProvider = class {
166
175
  name = "claude";
@@ -173,7 +182,7 @@ var ClaudeProvider = class {
173
182
  };
174
183
 
175
184
  // src/adapters/mastra.ts
176
- import { z as z2 } from "zod";
185
+ import { z as z3 } from "zod";
177
186
  var MastraProvider = class {
178
187
  name = "mastra";
179
188
  async build(options) {
@@ -182,7 +191,7 @@ var MastraProvider = class {
182
191
  (def) => createTool({
183
192
  id: def.name,
184
193
  description: def.description,
185
- inputSchema: z2.object(def.shape),
194
+ inputSchema: z3.object(def.shape),
186
195
  execute: async (inputData) => {
187
196
  const result = await def.handler(
188
197
  inputData
@@ -203,6 +212,44 @@ var MastraProvider = class {
203
212
  }
204
213
  };
205
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
+
206
253
  // src/adapters/openai.ts
207
254
  function getOpenAIMcpConfig(baseUrl, headers) {
208
255
  return {
@@ -228,7 +275,7 @@ async function createVercelAiMcpClient(options) {
228
275
 
229
276
  // src/core/base.ts
230
277
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
231
- import { z as z3 } from "zod";
278
+ import { z as z5 } from "zod";
232
279
  function createBaseMcpServer(options) {
233
280
  const server = new McpServer({
234
281
  name: "corsair",
@@ -238,7 +285,7 @@ function createBaseMcpServer(options) {
238
285
  for (const def of buildCorsairToolDefs(options)) {
239
286
  server.registerTool(
240
287
  def.name,
241
- { description: def.description, inputSchema: z3.object(def.shape) },
288
+ { description: def.description, inputSchema: z5.object(def.shape) },
242
289
  def.handler
243
290
  );
244
291
  }
@@ -304,13 +351,6 @@ function createMcpRouter(createServer) {
304
351
  return router;
305
352
  }
306
353
 
307
- // src/core/provider.ts
308
- var BaseProvider = class {
309
- build(options) {
310
- return buildCorsairToolDefs(options).map((def) => this.wrapTool(def));
311
- }
312
- };
313
-
314
354
  // src/core/stdio.ts
315
355
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
316
356
  async function runStdioMcpServer(options) {
@@ -319,9 +359,11 @@ async function runStdioMcpServer(options) {
319
359
  await server.connect(transport);
320
360
  }
321
361
  export {
362
+ AnthropicProvider,
322
363
  BaseProvider,
323
364
  ClaudeProvider,
324
365
  MastraProvider,
366
+ OpenAIAgentsProvider,
325
367
  createBaseMcpServer,
326
368
  createMcpRouter,
327
369
  createVercelAiMcpClient,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@corsair-dev/mcp",
3
- "version": "0.1.8",
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
- "corsair": "0.1.33"
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",
@@ -53,6 +59,7 @@
53
59
  ],
54
60
  "scripts": {
55
61
  "build": "tsup && tsc -p tsconfig.build.json",
62
+ "build:watch": "tsup --watch",
56
63
  "typecheck": "tsc --noEmit"
57
64
  }
58
65
  }