Skip to main content
corsairTools turns a Corsair instance into LangChain.js tools, one tool per API operation. Hand them to createReactAgent({ tools }) or model.bindTools(...) and the model can call Slack, GitHub, Gmail, Linear, Stripe, and the rest of the plugin catalog. The credentials never leave your database. Corsair runs OAuth server-side, stores the encrypted tokens under your own key, and the tool call reads them at execution time. The model sees tool names and results, never a token.

Install

Then add one @corsair-dev/* package per service you connect, plus your LangChain model and agent runtime:
@langchain/core is a peer dependency. The adapter imports it lazily, so installing @corsair-dev/langchain alone never pulls LangChain into a project that does not use this entrypoint.

Quickstart

1

Create the Corsair instance

Build it once and reuse it. authType: 'managed' lets Corsair hold the OAuth connection; the tokens stay encrypted in your database under your kek.
corsair.ts
2

Build the tools

corsairTools is async. It returns one DynamicStructuredTool per operation, ready for any LangChain agent.
3

Give them to an agent

agent.ts
Route model calls through the Corsair LLM gateway (llm.corsair.dev, OpenAI-compatible) to keep spend on budget-limited keys. Point any @langchain/openai model at it with the configuration.baseURL shown above. See LLM gateway.

Choosing which tools

Scope the toolset so the model only sees what the task needs. Fewer tools means cleaner prompts and fewer wrong turns.

Multi-tenancy

On a multi-tenant instance, pin the tenant whose stored credentials the tools should use. Each tenant owns its own connections, so the same code serves every user:
Single-tenant instances ignore tenantId.

API

CorsairInstance
required
The value from createCorsair() (or corsair.withTenant(...)).
string
Include every operation of one plugin. Omit plugin and operations to include all registered plugins.
string[]
Include only these operation paths, e.g. slack.api.channels.list.
string
Use the stored credentials of this tenant. Ignored on single-tenant instances.

Notes

  • Tool names. The operation path becomes the tool name with . replaced by _ (slack.api.channels.list becomes slack_api_channels_list), so it satisfies the model’s function-name constraint.
  • Schemas. Corsair is on Zod v4, which current @langchain/core accepts directly. No JSON Schema conversion step.
  • Results. String results pass through; anything else is JSON-encoded into the tool message the model reads.
The tool runs whatever operation the model picks with the tenant’s real credentials. Scope with plugin or operations so an agent can only reach the APIs the task actually needs.