@corsair-dev/mcp 0.1.27 → 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.
@@ -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>, any, unknown, unknown, import("@mastra/core/tools").ToolExecutionContext<unknown, unknown, unknown>, 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,7 @@
1
+ #!/usr/bin/env node
2
+ /** Package name for a plugin spec, and the named export it exposes. */
3
+ export declare function resolvePlugin(spec: string): {
4
+ pkg: string;
5
+ exportName: string;
6
+ };
7
+ //# sourceMappingURL=bin.d.ts.map
@@ -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
+ };