@corsair-dev/mcp 0.1.19 → 0.1.22
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/openai-agents.d.ts.map +1 -1
- package/dist/core/json-schema.d.ts +4 -0
- package/dist/core/json-schema.d.ts.map +1 -0
- package/dist/core/schema-format.d.ts +9 -0
- package/dist/core/schema-format.d.ts.map +1 -0
- package/dist/core/tools.d.ts.map +1 -1
- package/dist/index.js +51 -28
- package/package.json +2 -3
|
@@ -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;
|
|
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;AAI1D,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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-schema.d.ts","sourceRoot":"","sources":["../../src/core/json-schema.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,KAAK,CAAC;AAGvC,gFAAgF;AAChF,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAK7E"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { AnyCorsairInstance } from 'corsair';
|
|
2
|
+
import { formatDocSchemaShape } from 'corsair';
|
|
3
|
+
export { formatDocSchemaShape };
|
|
4
|
+
/**
|
|
5
|
+
* Plain-text schema for a Corsair operation path, with `// description` notes
|
|
6
|
+
* on each top-level input/output field (from Zod `.describe()`).
|
|
7
|
+
*/
|
|
8
|
+
export declare function formatGetSchemaResponse(corsair: AnyCorsairInstance, path: string): string;
|
|
9
|
+
//# sourceMappingURL=schema-format.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-format.d.ts","sourceRoot":"","sources":["../../src/core/schema-format.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAa,MAAM,SAAS,CAAC;AAE1D,OAAO,EAAE,oBAAoB,EAAE,CAAC;AAEhC;;;GAGG;AACH,wBAAgB,uBAAuB,CACtC,OAAO,EAAE,kBAAkB,EAC3B,IAAI,EAAE,MAAM,GACV,MAAM,CAER"}
|
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;AAGpD,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,CA+LlB"}
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,27 @@
|
|
|
1
1
|
// src/adapters/anthropic-api.ts
|
|
2
|
+
import { z as z3 } from "zod";
|
|
3
|
+
|
|
4
|
+
// src/core/json-schema.ts
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
import * as z4mini from "zod/v4-mini";
|
|
7
|
+
function shapeToJsonSchema(shape) {
|
|
8
|
+
return z4mini.toJSONSchema(z.object(shape), {
|
|
9
|
+
target: "draft-7",
|
|
10
|
+
io: "input"
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// src/core/tools.ts
|
|
15
|
+
import { listOperations, setupCorsair } from "corsair";
|
|
2
16
|
import { z as z2 } from "zod";
|
|
3
|
-
|
|
17
|
+
|
|
18
|
+
// src/core/schema-format.ts
|
|
19
|
+
import { formatDocSchemaShape, getSchema } from "corsair";
|
|
20
|
+
function formatGetSchemaResponse(corsair, path) {
|
|
21
|
+
return getSchema(corsair, path);
|
|
22
|
+
}
|
|
4
23
|
|
|
5
24
|
// src/core/tools.ts
|
|
6
|
-
import { getSchema, listOperations, setupCorsair } from "corsair";
|
|
7
|
-
import { z } from "zod";
|
|
8
25
|
function buildCorsairToolDefs(options) {
|
|
9
26
|
const {
|
|
10
27
|
corsair,
|
|
@@ -18,8 +35,8 @@ function buildCorsairToolDefs(options) {
|
|
|
18
35
|
name: "list_operations",
|
|
19
36
|
description: "List available Corsair operations. Without options returns all API endpoints across every plugin. Filter by plugin (e.g. 'slack') and/or type ('api' | 'webhooks' | 'db').",
|
|
20
37
|
shape: {
|
|
21
|
-
plugin:
|
|
22
|
-
type:
|
|
38
|
+
plugin: z2.string().optional().describe("Plugin ID to filter by, e.g. 'slack' or 'github'"),
|
|
39
|
+
type: z2.enum(["api", "webhooks", "db"]).optional().describe("Operation type: 'api' (default), 'webhooks', or 'db'")
|
|
23
40
|
},
|
|
24
41
|
handler: async ({ plugin, type }) => {
|
|
25
42
|
const result = listOperations(corsair, {
|
|
@@ -35,12 +52,15 @@ function buildCorsairToolDefs(options) {
|
|
|
35
52
|
name: "get_schema",
|
|
36
53
|
description: "Get the schema and metadata for a Corsair operation path. Accepts API paths ('slack.api.channels.list'), webhook paths ('slack.webhooks.messages.message'), or DB paths ('slack.db.messages.search').",
|
|
37
54
|
shape: {
|
|
38
|
-
path:
|
|
55
|
+
path: z2.string().describe(
|
|
39
56
|
"Full dot-path from list_operations, e.g. 'slack.api.channels.list'"
|
|
40
57
|
)
|
|
41
58
|
},
|
|
42
59
|
handler: async ({ path }) => {
|
|
43
|
-
const result =
|
|
60
|
+
const result = formatGetSchemaResponse(
|
|
61
|
+
corsair,
|
|
62
|
+
path
|
|
63
|
+
);
|
|
44
64
|
return {
|
|
45
65
|
content: [{ type: "text", text: result }]
|
|
46
66
|
};
|
|
@@ -50,7 +70,7 @@ function buildCorsairToolDefs(options) {
|
|
|
50
70
|
name: "run_script",
|
|
51
71
|
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.",
|
|
52
72
|
shape: {
|
|
53
|
-
code:
|
|
73
|
+
code: z2.string().describe(
|
|
54
74
|
'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;'
|
|
55
75
|
)
|
|
56
76
|
},
|
|
@@ -64,7 +84,12 @@ function buildCorsairToolDefs(options) {
|
|
|
64
84
|
corsair
|
|
65
85
|
);
|
|
66
86
|
return {
|
|
67
|
-
content: [
|
|
87
|
+
content: [
|
|
88
|
+
{
|
|
89
|
+
type: "text",
|
|
90
|
+
text: JSON.stringify(result ?? null, null, 2)
|
|
91
|
+
}
|
|
92
|
+
]
|
|
68
93
|
};
|
|
69
94
|
} catch (err) {
|
|
70
95
|
const message = err instanceof Error ? err.message : String(err);
|
|
@@ -90,7 +115,7 @@ ${full}`
|
|
|
90
115
|
name: "corsair_setup",
|
|
91
116
|
description: "Helps the user configure Corsair. Call this to see if any keys or tokens need to be set up. It will also provide the instructions to set them up. For multi-tenant Corsair instances, pass tenantId to set up a specific tenant.",
|
|
92
117
|
shape: {
|
|
93
|
-
tenantId:
|
|
118
|
+
tenantId: z2.string().optional().describe(
|
|
94
119
|
"Tenant ID to configure for multi-tenant Corsair instances. Defaults to the server's configured tenantId, then 'default'."
|
|
95
120
|
)
|
|
96
121
|
},
|
|
@@ -121,16 +146,16 @@ ${full}`
|
|
|
121
146
|
name: "request_permission",
|
|
122
147
|
description: "Request permission from the user to execute a protected endpoint. Call this when a script returns a [PERMISSION_REQUIRED] message. Returns an approval URL. After calling this, call ask_human with the approval URL so the user can review and approve.",
|
|
123
148
|
shape: {
|
|
124
|
-
endpoint:
|
|
149
|
+
endpoint: z2.string().describe(
|
|
125
150
|
'Full endpoint path from the PERMISSION_REQUIRED message, e.g. "slack.messages.post"'
|
|
126
151
|
),
|
|
127
|
-
args:
|
|
152
|
+
args: z2.record(z2.string(), z2.unknown()).describe(
|
|
128
153
|
"The arguments object from the PERMISSION_REQUIRED message"
|
|
129
154
|
),
|
|
130
|
-
description:
|
|
155
|
+
description: z2.string().describe(
|
|
131
156
|
'Short human-readable summary of what this action will do, e.g. "Post a message to #general in Slack"'
|
|
132
157
|
),
|
|
133
|
-
jid:
|
|
158
|
+
jid: z2.string().optional().describe(
|
|
134
159
|
"Optional chat/conversation ID for resuming after approval"
|
|
135
160
|
)
|
|
136
161
|
},
|
|
@@ -165,7 +190,7 @@ var BaseProvider = class {
|
|
|
165
190
|
var AnthropicProvider = class extends BaseProvider {
|
|
166
191
|
name = "anthropic";
|
|
167
192
|
wrapTool(def) {
|
|
168
|
-
const schema =
|
|
193
|
+
const schema = shapeToJsonSchema(def.shape);
|
|
169
194
|
return {
|
|
170
195
|
type: "custom",
|
|
171
196
|
name: def.name,
|
|
@@ -180,7 +205,7 @@ var AnthropicProvider = class extends BaseProvider {
|
|
|
180
205
|
return `Error: ${message}`;
|
|
181
206
|
}
|
|
182
207
|
},
|
|
183
|
-
parse: (content) =>
|
|
208
|
+
parse: (content) => z3.object(def.shape).parse(content)
|
|
184
209
|
};
|
|
185
210
|
}
|
|
186
211
|
};
|
|
@@ -201,7 +226,7 @@ var ClaudeProvider = class {
|
|
|
201
226
|
};
|
|
202
227
|
|
|
203
228
|
// src/adapters/mastra.ts
|
|
204
|
-
import { z as
|
|
229
|
+
import { z as z4 } from "zod";
|
|
205
230
|
var MastraProvider = class {
|
|
206
231
|
name = "mastra";
|
|
207
232
|
async build(options) {
|
|
@@ -214,7 +239,7 @@ var MastraProvider = class {
|
|
|
214
239
|
(def) => createTool({
|
|
215
240
|
id: def.name,
|
|
216
241
|
description: def.description,
|
|
217
|
-
inputSchema:
|
|
242
|
+
inputSchema: z4.object(def.shape),
|
|
218
243
|
execute: async (inputData) => {
|
|
219
244
|
const result = await def.handler(
|
|
220
245
|
inputData
|
|
@@ -236,12 +261,11 @@ var MastraProvider = class {
|
|
|
236
261
|
};
|
|
237
262
|
|
|
238
263
|
// src/adapters/ollama.ts
|
|
239
|
-
import { z as
|
|
240
|
-
import { zodToJsonSchema as zodToJsonSchema2 } from "zod-to-json-schema";
|
|
264
|
+
import { z as z5 } from "zod";
|
|
241
265
|
var OllamaProvider = class extends BaseProvider {
|
|
242
266
|
name = "ollama";
|
|
243
267
|
wrapTool(def) {
|
|
244
|
-
const schema =
|
|
268
|
+
const schema = shapeToJsonSchema(def.shape);
|
|
245
269
|
return {
|
|
246
270
|
type: "function",
|
|
247
271
|
function: {
|
|
@@ -261,7 +285,7 @@ var OllamaProvider = class extends BaseProvider {
|
|
|
261
285
|
execute: async (args) => {
|
|
262
286
|
try {
|
|
263
287
|
const raw = typeof args === "string" ? JSON.parse(args) : args;
|
|
264
|
-
const validated =
|
|
288
|
+
const validated = z5.object(def.shape).parse(raw);
|
|
265
289
|
const result = await def.handler(validated);
|
|
266
290
|
return result.content.filter((c) => c.type === "text").map((c) => "text" in c ? c.text : "").join("\n");
|
|
267
291
|
} catch (err) {
|
|
@@ -283,14 +307,13 @@ function getOpenAIMcpConfig(baseUrl, headers) {
|
|
|
283
307
|
}
|
|
284
308
|
|
|
285
309
|
// src/adapters/openai-agents.ts
|
|
286
|
-
import { z as
|
|
287
|
-
import { zodToJsonSchema as zodToJsonSchema3 } from "zod-to-json-schema";
|
|
310
|
+
import { z as z6 } from "zod";
|
|
288
311
|
var OpenAIAgentsProvider = class {
|
|
289
312
|
name = "openai-agents";
|
|
290
313
|
build(options) {
|
|
291
314
|
const { tool, ...mcpOptions } = options;
|
|
292
315
|
return buildCorsairToolDefs(mcpOptions).map((def) => {
|
|
293
|
-
const jsonSchema =
|
|
316
|
+
const jsonSchema = shapeToJsonSchema(def.shape);
|
|
294
317
|
const shapeKeys = new Set(Object.keys(def.shape));
|
|
295
318
|
return tool({
|
|
296
319
|
name: def.name,
|
|
@@ -307,7 +330,7 @@ var OpenAIAgentsProvider = class {
|
|
|
307
330
|
}
|
|
308
331
|
if (Object.keys(extra).length > 0) raw.args = extra;
|
|
309
332
|
}
|
|
310
|
-
const args =
|
|
333
|
+
const args = z6.object(def.shape).parse(raw);
|
|
311
334
|
const result = await def.handler(args);
|
|
312
335
|
return result.content.filter((c) => c.type === "text").map((c) => "text" in c ? c.text : "").join("\n");
|
|
313
336
|
} catch (err) {
|
|
@@ -340,7 +363,7 @@ async function createVercelAiMcpClient(options) {
|
|
|
340
363
|
|
|
341
364
|
// src/core/base.ts
|
|
342
365
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
343
|
-
import { z as
|
|
366
|
+
import { z as z7 } from "zod";
|
|
344
367
|
function createBaseMcpServer(options) {
|
|
345
368
|
const server = new McpServer({
|
|
346
369
|
name: "corsair",
|
|
@@ -350,7 +373,7 @@ function createBaseMcpServer(options) {
|
|
|
350
373
|
for (const def of buildCorsairToolDefs(options)) {
|
|
351
374
|
server.registerTool(
|
|
352
375
|
def.name,
|
|
353
|
-
{ description: def.description, inputSchema:
|
|
376
|
+
{ description: def.description, inputSchema: z7.object(def.shape) },
|
|
354
377
|
def.handler
|
|
355
378
|
);
|
|
356
379
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@corsair-dev/mcp",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.22",
|
|
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,8 +20,7 @@
|
|
|
20
20
|
"@modelcontextprotocol/sdk": "^1.27.1",
|
|
21
21
|
"express": "^4.21.0",
|
|
22
22
|
"zod": "^4.1.13",
|
|
23
|
-
"
|
|
24
|
-
"corsair": "0.1.69"
|
|
23
|
+
"corsair": "0.1.75"
|
|
25
24
|
},
|
|
26
25
|
"peerDependencies": {
|
|
27
26
|
"@ai-sdk/mcp": ">=0.0.1",
|