@corsair-dev/mcp 0.1.7 → 0.1.9

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.
@@ -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.js CHANGED
@@ -37,47 +37,21 @@ function buildCorsairToolDefs(options) {
37
37
  }
38
38
  },
39
39
  {
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'.",
40
+ name: "run_script",
41
+ 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
42
  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")
43
+ code: z.string().describe(
44
+ '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;'
45
+ )
45
46
  },
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
- }
47
+ handler: async ({ code }) => {
78
48
  try {
49
+ const fn = new Function(
50
+ "corsair",
51
+ `return (async () => { ${code} })()`
52
+ );
79
53
  const result = await fn(
80
- args
54
+ corsair
81
55
  );
82
56
  return {
83
57
  content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
@@ -92,7 +66,7 @@ Cause: ${String(err.cause)}` : "";
92
66
  content: [
93
67
  {
94
68
  type: "text",
95
- text: `Error running "${path}": ${message}${extra}
69
+ text: `Error running snippet: ${message}${extra}
96
70
  ${full}`
97
71
  }
98
72
  ]
@@ -109,9 +83,9 @@ ${full}`
109
83
  if (Object.keys(corsair).includes("withTenant")) {
110
84
  throw new Error("Cannot setup Corsair if it multiTenancy is enabled.");
111
85
  }
112
- await setupCorsair(corsair);
86
+ const text = await setupCorsair(corsair);
113
87
  return {
114
- content: [{ type: "text", text: "Corsair setup complete." }]
88
+ content: [{ type: "text", text: text || "Corsair setup complete." }]
115
89
  };
116
90
  } catch (err) {
117
91
  const message = err instanceof Error ? err.message : String(err);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@corsair-dev/mcp",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
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,7 +20,7 @@
20
20
  "@modelcontextprotocol/sdk": "^1.27.1",
21
21
  "express": "^4.21.0",
22
22
  "zod": "^3.25.0",
23
- "corsair": "0.1.31"
23
+ "corsair": "0.1.34"
24
24
  },
25
25
  "peerDependencies": {
26
26
  "@ai-sdk/mcp": ">=0.0.1",
@@ -53,6 +53,7 @@
53
53
  ],
54
54
  "scripts": {
55
55
  "build": "tsup && tsc -p tsconfig.build.json",
56
+ "build:watch": "tsup --watch",
56
57
  "typecheck": "tsc --noEmit"
57
58
  }
58
59
  }