@corsair-dev/mcp 0.1.26 → 0.1.28
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/README.md +87 -0
- package/dist/adapters/mastra.d.ts +1 -1
- package/dist/bin.d.ts +7 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +126 -0
- package/dist/chunk-3H436GYZ.js +4415 -0
- package/dist/index.js +13 -4399
- package/dist/langchain.d.ts +2 -0
- package/dist/langchain.d.ts.map +1 -0
- package/dist/langchain.js +2 -0
- package/dist/llamaindex.d.ts +2 -0
- package/dist/llamaindex.d.ts.map +1 -0
- package/dist/llamaindex.js +2 -0
- package/dist/mastra.d.ts +2 -0
- package/dist/mastra.d.ts.map +1 -0
- package/dist/mastra.js +2 -0
- package/package.json +67 -4
package/README.md
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# @corsair-dev/mcp
|
|
2
|
+
|
|
3
|
+
MCP server and framework adapters for [Corsair](https://corsair.dev), the open-source integration layer for AI agents. Give any agent framework 200+ integrations as tools with a single adapter call.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@corsair-dev/mcp)
|
|
6
|
+
[](https://github.com/corsairdev/corsair/blob/main/LICENSE)
|
|
7
|
+
[](https://discord.gg/uNgCP3mSzU)
|
|
8
|
+
|
|
9
|
+
Corsair handles the parts of an integration you would rather not maintain: OAuth, token refresh, webhook verification, and rate limits. Credentials stay encrypted in your own database. This package puts all of that behind the tool interface your agent framework already speaks.
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install @corsair-dev/mcp
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Install the framework you use alongside it. The Mastra quickstart below needs `npm install @mastra/core @ai-sdk/anthropic`. Each adapter treats its framework as an optional peer dependency.
|
|
18
|
+
|
|
19
|
+
## Quickstart
|
|
20
|
+
|
|
21
|
+
Build tools from a configured `corsair` instance and hand them to a Mastra agent:
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
import { Agent } from '@mastra/core/agent';
|
|
25
|
+
import { anthropic } from '@ai-sdk/anthropic';
|
|
26
|
+
import { MastraProvider } from '@corsair-dev/mcp';
|
|
27
|
+
import { corsair } from './corsair';
|
|
28
|
+
|
|
29
|
+
const provider = new MastraProvider();
|
|
30
|
+
const tools = await provider.build({ corsair });
|
|
31
|
+
|
|
32
|
+
const agent = new Agent({
|
|
33
|
+
name: 'corsair-agent',
|
|
34
|
+
model: anthropic('claude-sonnet-4-6'),
|
|
35
|
+
instructions:
|
|
36
|
+
'You have Corsair tools. Use list_operations to discover APIs, get_schema to read arguments, and run_script to execute.',
|
|
37
|
+
tools: Object.fromEntries(tools.map((t) => [t.id, t])),
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const response = await agent.generate('List all Slack channels.');
|
|
41
|
+
console.log(response.text);
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Setting up the `corsair` instance is covered in the [setup guide](https://docs.corsair.dev/hub/setup).
|
|
45
|
+
|
|
46
|
+
## Adapters
|
|
47
|
+
|
|
48
|
+
Each adapter exposes Corsair's tools in the shape its framework expects, so there is no manual schema wiring. More frameworks are on the way.
|
|
49
|
+
|
|
50
|
+
| Adapter | Use case |
|
|
51
|
+
|---|---|
|
|
52
|
+
| [Anthropic SDK](https://docs.corsair.dev/mcp-adapters/anthropic-sdk) | Native tool use with Claude models |
|
|
53
|
+
| [Claude Agent SDK](https://docs.corsair.dev/mcp-adapters/claude-sdk) | In-process MCP with the Claude Agent SDK |
|
|
54
|
+
| [OpenAI Agents](https://docs.corsair.dev/mcp-adapters/openai) | OpenAI Agents SDK tools |
|
|
55
|
+
| [OpenAI](https://docs.corsair.dev/mcp-adapters/openai) | OpenAI function calling |
|
|
56
|
+
| [Vercel AI SDK](https://docs.corsair.dev/mcp-adapters/vercel-ai) | Tools for `useChat` and `streamText` |
|
|
57
|
+
| [Mastra](https://docs.corsair.dev/mcp-adapters/mastra) | Mastra agent tools |
|
|
58
|
+
|
|
59
|
+
Full list and options: [docs.corsair.dev/mcp-adapters](https://docs.corsair.dev/mcp-adapters/mcp-adapters).
|
|
60
|
+
|
|
61
|
+
## How it works
|
|
62
|
+
|
|
63
|
+
Every adapter exposes the same three tools, so the agent works the same way across 200+ integrations instead of reading a flat list of every endpoint:
|
|
64
|
+
|
|
65
|
+
| Tool | What it does |
|
|
66
|
+
|---|---|
|
|
67
|
+
| `list_operations` | Discover the available API endpoints |
|
|
68
|
+
| `get_schema` | Inspect the parameters for one endpoint |
|
|
69
|
+
| `run_script` | Execute a call with `corsair` in scope |
|
|
70
|
+
|
|
71
|
+
The agent calls `list_operations` to find what it can do, `get_schema` to learn the arguments, then `run_script` to run it. Add a plugin and its endpoints show up with no code change.
|
|
72
|
+
|
|
73
|
+
`run_script` evaluates the model's JavaScript in your process with the `corsair` instance in scope. It is not a sandbox, so keep the caller trusted, the same as any code your agent runs. Build the tools with `runOptions: { readonly: true }` to block write and destructive Corsair endpoints; note this restricts Corsair calls only, not other side effects in the script.
|
|
74
|
+
|
|
75
|
+
For coding agents over stdio (Claude Code, Cursor, Codex), see [Coding agents](https://docs.corsair.dev/mcp-adapters/claude-code).
|
|
76
|
+
|
|
77
|
+
## Links
|
|
78
|
+
|
|
79
|
+
- Docs: https://docs.corsair.dev
|
|
80
|
+
- Adapters: https://docs.corsair.dev/mcp-adapters/mcp-adapters
|
|
81
|
+
- Repository: https://github.com/corsairdev/corsair
|
|
82
|
+
- Discord: https://discord.gg/uNgCP3mSzU
|
|
83
|
+
- X: https://x.com/corsairdotdev
|
|
84
|
+
|
|
85
|
+
## License
|
|
86
|
+
|
|
87
|
+
Apache-2.0. See [LICENSE](https://github.com/corsairdev/corsair/blob/main/LICENSE).
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { BaseMcpOptions } from '../core/adapters.js';
|
|
2
2
|
export declare class MastraProvider {
|
|
3
3
|
readonly name = "mastra";
|
|
4
|
-
build(options: BaseMcpOptions): Promise<import("@mastra/core/tools").Tool<Record<string, unknown>,
|
|
4
|
+
build(options: BaseMcpOptions): Promise<import("@mastra/core/tools").Tool<Record<string, unknown>, unknown, unknown, unknown, import("@mastra/core/tools").ToolExecutionContext<unknown, unknown, unknown>, string, unknown>[]>;
|
|
5
5
|
}
|
|
6
6
|
//# sourceMappingURL=mastra.d.ts.map
|
package/dist/bin.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";AAmDA,uEAAuE;AACvE,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG;IAC5C,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;CACnB,CAKA"}
|
package/dist/bin.js
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
runStdioMcpServer
|
|
4
|
+
} from "./chunk-3H436GYZ.js";
|
|
5
|
+
|
|
6
|
+
// src/bin.ts
|
|
7
|
+
import { createCorsair } from "corsair";
|
|
8
|
+
var SCHEMA = `
|
|
9
|
+
CREATE TABLE IF NOT EXISTS corsair_integrations (
|
|
10
|
+
id TEXT PRIMARY KEY, created_at TEXT NOT NULL, updated_at TEXT NOT NULL,
|
|
11
|
+
name TEXT NOT NULL, config TEXT NOT NULL, dek TEXT NULL
|
|
12
|
+
);
|
|
13
|
+
CREATE TABLE IF NOT EXISTS corsair_accounts (
|
|
14
|
+
id TEXT PRIMARY KEY, created_at TEXT NOT NULL, updated_at TEXT NOT NULL,
|
|
15
|
+
tenant_id TEXT NOT NULL, integration_id TEXT NOT NULL, config TEXT NOT NULL, dek TEXT NULL
|
|
16
|
+
);
|
|
17
|
+
CREATE TABLE IF NOT EXISTS corsair_entities (
|
|
18
|
+
id TEXT PRIMARY KEY, created_at TEXT NOT NULL, updated_at TEXT NOT NULL,
|
|
19
|
+
account_id TEXT NOT NULL, entity_id TEXT NOT NULL, entity_type TEXT NOT NULL,
|
|
20
|
+
version TEXT NOT NULL, data TEXT NOT NULL,
|
|
21
|
+
UNIQUE (account_id, entity_type, entity_id)
|
|
22
|
+
);
|
|
23
|
+
CREATE TABLE IF NOT EXISTS corsair_events (
|
|
24
|
+
id TEXT PRIMARY KEY, created_at TEXT NOT NULL, updated_at TEXT NOT NULL,
|
|
25
|
+
account_id TEXT NOT NULL, event_type TEXT NOT NULL, payload TEXT NOT NULL, status TEXT
|
|
26
|
+
);
|
|
27
|
+
CREATE INDEX IF NOT EXISTS corsair_events_account_type_created_idx
|
|
28
|
+
ON corsair_events (account_id, event_type, created_at);
|
|
29
|
+
CREATE TABLE IF NOT EXISTS corsair_permissions (
|
|
30
|
+
id TEXT PRIMARY KEY, created_at TEXT NOT NULL, updated_at TEXT NOT NULL,
|
|
31
|
+
token TEXT NOT NULL, plugin TEXT NOT NULL, endpoint TEXT NOT NULL,
|
|
32
|
+
args TEXT NOT NULL, tenant_id TEXT NOT NULL DEFAULT 'default',
|
|
33
|
+
status TEXT NOT NULL DEFAULT 'pending', expires_at TEXT NOT NULL, error TEXT NULL
|
|
34
|
+
);
|
|
35
|
+
`;
|
|
36
|
+
function resolvePlugin(spec) {
|
|
37
|
+
const trimmed = spec.trim();
|
|
38
|
+
const pkg = trimmed.includes("/") ? trimmed : `@corsair-dev/${trimmed}`;
|
|
39
|
+
const exportName = pkg.replace(/^@corsair-dev\//, "");
|
|
40
|
+
return { pkg, exportName };
|
|
41
|
+
}
|
|
42
|
+
function required(name) {
|
|
43
|
+
const value = process.env[name];
|
|
44
|
+
if (!value) {
|
|
45
|
+
console.error(`[corsair-mcp] missing required env ${name}`);
|
|
46
|
+
process.exit(1);
|
|
47
|
+
}
|
|
48
|
+
return value;
|
|
49
|
+
}
|
|
50
|
+
async function main() {
|
|
51
|
+
const kek = required("CORSAIR_KEK");
|
|
52
|
+
const projectApiKey = required("CORSAIR_API_KEY");
|
|
53
|
+
const signingSecret = required("CORSAIR_SIGNING_SECRET");
|
|
54
|
+
const specs = required("CORSAIR_PLUGINS").split(",").map((s) => s.trim()).filter(Boolean);
|
|
55
|
+
if (specs.length === 0) {
|
|
56
|
+
console.error("[corsair-mcp] CORSAIR_PLUGINS lists no plugins");
|
|
57
|
+
process.exit(1);
|
|
58
|
+
}
|
|
59
|
+
const sqliteModule = await import("better-sqlite3").catch(() => {
|
|
60
|
+
console.error(
|
|
61
|
+
'[corsair-mcp] needs "better-sqlite3" installed: npm i better-sqlite3'
|
|
62
|
+
);
|
|
63
|
+
process.exit(1);
|
|
64
|
+
});
|
|
65
|
+
const Database = sqliteModule.default;
|
|
66
|
+
const database = new Database(process.env.CORSAIR_DB_PATH ?? "./corsair.db");
|
|
67
|
+
database.exec(SCHEMA);
|
|
68
|
+
const permissionCols = new Set(
|
|
69
|
+
database.pragma("table_info(corsair_permissions)").map((c) => c.name)
|
|
70
|
+
);
|
|
71
|
+
for (const col of ["token", "plugin", "args", "tenant_id", "expires_at"]) {
|
|
72
|
+
if (!permissionCols.has(col)) {
|
|
73
|
+
console.error(
|
|
74
|
+
`[corsair-mcp] corsair_permissions in this database is missing the "${col}" column \u2014 it was created by an older schema. Delete the database file or migrate it, then restart.`
|
|
75
|
+
);
|
|
76
|
+
process.exit(1);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const plugins = [];
|
|
80
|
+
for (const spec of specs) {
|
|
81
|
+
const { pkg, exportName } = resolvePlugin(spec);
|
|
82
|
+
const mod = await import(pkg).catch(() => {
|
|
83
|
+
console.error(
|
|
84
|
+
`[corsair-mcp] plugin "${pkg}" is not installed: npm i ${pkg}`
|
|
85
|
+
);
|
|
86
|
+
process.exit(1);
|
|
87
|
+
});
|
|
88
|
+
const factory = mod[exportName] ?? mod.default;
|
|
89
|
+
if (typeof factory !== "function") {
|
|
90
|
+
console.error(
|
|
91
|
+
`[corsair-mcp] "${pkg}" has no "${exportName}" plugin export`
|
|
92
|
+
);
|
|
93
|
+
process.exit(1);
|
|
94
|
+
}
|
|
95
|
+
plugins.push(
|
|
96
|
+
factory({
|
|
97
|
+
authType: "managed"
|
|
98
|
+
})
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
const corsair = createCorsair({
|
|
102
|
+
database,
|
|
103
|
+
kek,
|
|
104
|
+
multiTenancy: process.env.CORSAIR_MULTITENANCY === "true",
|
|
105
|
+
hub: {
|
|
106
|
+
projectApiKey,
|
|
107
|
+
signingSecret,
|
|
108
|
+
// stdout is the JSON-RPC channel for a stdio MCP server; the dev tunnel
|
|
109
|
+
// logs its URL to stdout on a ck_dev_ key and would corrupt the stream.
|
|
110
|
+
tunnel: false
|
|
111
|
+
},
|
|
112
|
+
plugins
|
|
113
|
+
});
|
|
114
|
+
await runStdioMcpServer({
|
|
115
|
+
corsair,
|
|
116
|
+
runOptions: { readonly: process.env.CORSAIR_READONLY === "true" }
|
|
117
|
+
});
|
|
118
|
+
console.error(`[corsair-mcp] serving ${plugins.length} plugin(s) over stdio`);
|
|
119
|
+
}
|
|
120
|
+
main().catch((err) => {
|
|
121
|
+
console.error("[corsair-mcp]", err);
|
|
122
|
+
process.exit(1);
|
|
123
|
+
});
|
|
124
|
+
export {
|
|
125
|
+
resolvePlugin
|
|
126
|
+
};
|