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
@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
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: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.listbecomesslack_api_channels_list), so it satisfies the model’s function-name constraint. - Schemas. Corsair is on Zod v4, which current
@langchain/coreaccepts directly. No JSON Schema conversion step. - Results. String results pass through; anything else is JSON-encoded into the tool message the model reads.