Skip to main content
1

Install

npm install corsair
2

Generate your encryption key

Corsair encrypts every stored credential with a Key Encryption Key (KEK). Click Generate to create one, or run the command yourself:
Keep this key safe If you lose it, you lose access to all stored credentials. Treat it like a root password.
3

Migrate the database

Corsair needs five tables. Run this once, then you’re done.
Install the driver, then run the migration:
npm install better-sqlite3
npm install --save-dev @types/better-sqlite3
migration.sql
CREATE TABLE IF NOT EXISTS corsair_integrations (
    id TEXT PRIMARY KEY,
    created_at INTEGER NOT NULL,
    updated_at INTEGER NOT NULL,
    name TEXT NOT NULL,
    config TEXT NOT NULL DEFAULT '{}',
    dek TEXT NULL
);

CREATE TABLE IF NOT EXISTS corsair_accounts (
    id TEXT PRIMARY KEY,
    created_at INTEGER NOT NULL,
    updated_at INTEGER NOT NULL,
    tenant_id TEXT NOT NULL,
    integration_id TEXT NOT NULL,
    config TEXT NOT NULL DEFAULT '{}',
    dek TEXT NULL,
    FOREIGN KEY (integration_id) REFERENCES corsair_integrations(id)
);

CREATE TABLE IF NOT EXISTS corsair_entities (
    id TEXT PRIMARY KEY,
    created_at INTEGER NOT NULL,
    updated_at INTEGER NOT NULL,
    account_id TEXT NOT NULL,
    entity_id TEXT NOT NULL,
    entity_type TEXT NOT NULL,
    version TEXT NOT NULL,
    data TEXT NOT NULL DEFAULT '{}',
    FOREIGN KEY (account_id) REFERENCES corsair_accounts(id)
);

CREATE TABLE IF NOT EXISTS corsair_events (
    id TEXT PRIMARY KEY,
    created_at INTEGER NOT NULL,
    updated_at INTEGER NOT NULL,
    account_id TEXT NOT NULL,
    event_type TEXT NOT NULL,
    payload TEXT NOT NULL DEFAULT '{}',
    status TEXT,
    FOREIGN KEY (account_id) REFERENCES corsair_accounts(id)
);
sqlite3 corsair.db < migration.sql
4

Install GitHub plugin and create corsair.ts

npm install @corsair-dev/github
This is the one file that wires everything together. Create it at src/server/corsair.ts:
src/server/corsair.ts
import 'dotenv/config';
import Database from 'better-sqlite3';
import { createCorsair } from 'corsair';
import { github } from '@corsair-dev/github';

const db = new Database('corsair.db');

export const corsair = createCorsair({
    plugins: [github()],
    database: db,
    kek: process.env.CORSAIR_KEK!,
});
You’ll add more plugins here later — slack(), linear(), gmail() — same pattern, just append to the array.
If process.env.CORSAIR_KEK is undefined at runtime, your .env file isn’t being picked up. Install dotenv and add one line at the top of src/server/corsair.ts:
npm install dotenv
src/server/corsair.ts
import 'dotenv/config'; // add this line
import Database from 'better-sqlite3';
// ...
5

Add your GitHub token and run setup

Use Corsair with any integration. Here’s an example of how to get started with Github.
  1. Go to GitHub → Settings → Developer settings → Personal access tokens (classic)
  2. Click Generate new token (classic)
  3. Select scopes: repo, read:org, read:user
  4. Copy the token — it starts with ghp_
export GITHUB_TOKEN=ghp_...
Run setup once with the Corsair CLI:
npm install @corsair-dev/cli
npx corsair setup --github api_key=$GITHUB_TOKEN --backfill
If pnpm corsair isn’t found, add this to your package.json so pnpm builds the native dependency correctly:
package.json
{
  "pnpm": {
    "onlyBuiltDependencies": [
      "better-sqlite3"
    ]
  }
}
Then re-run pnpm install and retry the setup command.
Corsair stores your token, creates the database rows, and fetches your GitHub data locally. Your agent can now query it instantly — no API call needed every time.
6

Interact with Corsair

There’s multiple ways to use Corsair. Here’s three easy ways:
Let the agent discover and call endpoints on its own. You prompt in plain English — Corsair handles the rest.Install the MCP adapter alongside your preferred framework:
npm install @corsair-dev/mcp @anthropic-ai/sdk
agent.ts
import Anthropic from '@anthropic-ai/sdk';
import { AnthropicProvider } from '@corsair-dev/mcp';
import { corsair } from './src/server/corsair';

async function main() {
    const provider = new AnthropicProvider();
    const tools = provider.build({ corsair });
    const client = new Anthropic();

    const message = await client.beta.messages.toolRunner({
        model: 'claude-sonnet-4-6',
        max_tokens: 4096,
        tools,
        messages: [{
            role: 'user',
            content: 'Use Corsair to list my GitHub repos with the most open issues.',
        }],
    });

    for (const block of message.content) {
        if (block.type === 'text') console.log(block.text);
    }
}

main().catch(console.error);
npm install @corsair-dev/mcp @anthropic-ai/claude-agent-sdk
agent.ts
import { createSdkMcpServer, query } from '@anthropic-ai/claude-agent-sdk';
import { ClaudeProvider } from '@corsair-dev/mcp';
import { corsair } from './src/server/corsair';

async function main() {
    const provider = new ClaudeProvider();
    const tools = await provider.build({ corsair });
    const server = createSdkMcpServer({ name: 'corsair', tools });

    const stream = query({
        prompt: 'Use Corsair to list my GitHub repos with the most open issues.',
        options: {
            model: 'claude-opus-4-6',
            mcpServers: { corsair: server },
            allowedTools: ['mcp__corsair__corsair_setup', 'mcp__corsair__list_operations', 'mcp__corsair__get_schema', 'mcp__corsair__run_script'],
        },
    });

    for await (const event of stream) {
        if ('result' in event) process.stdout.write(event.result);
    }
}

main().catch(console.error);
npm install @corsair-dev/mcp @openai/agents
agent.ts
import { OpenAIAgentsProvider } from '@corsair-dev/mcp';
import { Agent, run, tool } from '@openai/agents';
import { corsair } from './src/server/corsair';

async function main() {
    const provider = new OpenAIAgentsProvider();
    const tools = provider.build({ corsair, tool });

    const agent = new Agent({
        name: 'corsair-agent',
        model: 'gpt-4.1',
        instructions:
            'You have access to Corsair tools. Use list_operations to discover ' +
            'available APIs, get_schema to understand arguments, and run_script ' +
            'to execute them.',
        tools,
    });

    const result = await run(agent, 'Use Corsair. List my GitHub repos with the most open issues.');
    console.log(result.finalOutput);
}

main().catch(console.error);
Your agent gets four tools automatically — regardless of which framework you use:
ToolWhat it does
corsair_setupCheck auth and get credential instructions
list_operationsDiscover every available API endpoint
get_schemaInspect parameters for a specific endpoint
run_scriptExecute a JS snippet with corsair in scope
See MCP Adapters for Vercel AI SDK, Mastra, and more.

What’s next

Set up Webhooks

Get ngrok running, register your endpoint, and react to GitHub stars and PR events in real time.

Vibe Code Your Dashboard

Scaffold a Next.js + tRPC + SQLite project and build a live GitHub dashboard — just copy the prompt.

Multi-Tenancy

Building a product? Flip one flag and every user gets their own data and credentials.

Workflows

Chain events across plugins — PR merged → Slack notification → Linear issue, all in TypeScript.