LangChain Integration
Use Aerostack workspace tools as LangChain tools.
Every MCP tool becomes a DynamicStructuredTool — works with ReAct agents, LangGraph workflows, and any LLM.
Install
Section titled “Install”npm install @aerostack/sdk-langchain @langchain/openai @langchain/langgraphQuick Start
Section titled “Quick Start”import { ChatOpenAI } from '@langchain/openai';import { createReactAgent } from '@langchain/langgraph/prebuilt';import { getTools } from '@aerostack/sdk-langchain';
const { tools } = await getTools({ workspace: 'my-workspace', token: 'mwt_...',});
const agent = createReactAgent({ llm: new ChatOpenAI({ model: 'gpt-4o' }), tools,});
const result = await agent.invoke({ messages: [{ role: 'user', content: 'Create a GitHub issue for the login bug' }],});
console.log(result.messages.at(-1)?.content);The SDK:
- Fetches all MCP tools from your workspace
- Wraps each as a
DynamicStructuredToolwith name, description, and JSON schema - Each tool’s
funcproperty proxies calls through the workspace gateway - Errors are returned as string results (not thrown), keeping agent flow intact
Use Any LLM
Section titled “Use Any LLM”LangChain supports many providers. Aerostack tools work with all of them:
import { ChatAnthropic } from '@langchain/anthropic';import { getTools } from '@aerostack/sdk-langchain';
const { tools } = await getTools({ workspace: 'my-workspace', token: 'mwt_...',});
// Bind tools directly to a modelconst model = new ChatAnthropic({ model: 'claude-sonnet-4-20250514',}).bindTools(tools);
const response = await model.invoke('Search Notion for meeting notes');LangGraph Workflows
Section titled “LangGraph Workflows”Build multi-step workflows with LangGraph:
import { ChatOpenAI } from '@langchain/openai';import { createReactAgent } from '@langchain/langgraph/prebuilt';import { getTools } from '@aerostack/sdk-langchain';
const { tools } = await getTools({ workspace: 'my-workspace', token: 'mwt_...',});
const agent = createReactAgent({ llm: new ChatOpenAI({ model: 'gpt-4o' }), tools,});
// Multi-turn conversationconst thread = { configurable: { thread_id: 'my-session' } };
const r1 = await agent.invoke( { messages: [{ role: 'user', content: 'Find open GitHub issues labeled "bug"' }] }, thread,);
const r2 = await agent.invoke( { messages: [{ role: 'user', content: 'Create a Notion page summarizing them' }] }, thread,);Factory Pattern (Recommended for Production)
Section titled “Factory Pattern (Recommended for Production)”import { createAerostackLangChain } from '@aerostack/sdk-langchain';
const aerostack = createAerostackLangChain({ workspace: 'my-workspace', token: process.env.AEROSTACK_WORKSPACE_TOKEN!,});
// Reuse across requestsconst { tools } = await aerostack.tools();What getTools Returns
Section titled “What getTools Returns”const result = await getTools(config);
result.tools // DynamicStructuredTool[] — pass to agents or model.bindTools()result.raw // McpTool[] — raw MCP tool definitions for inspectionNext Steps
Section titled “Next Steps”- Create a workspace and connect MCP servers
- Browse 250+ MCP servers in the registry
- See the full API reference on GitHub