LangChain Integration
Use WDK MCP tools in LangChain agents with zero-config server startup
You can use the WDK MCP Toolkit as a tool provider for LangChain agents in both Python and TypeScript. LangChain's MultiServerMCPClient spawns the MCP server as a subprocess and converts WDK tools into LangChain-compatible tools, giving your agent access to wallet operations, pricing, swaps, bridges, lending, and more.
This integration uses the serve CLI command, which starts a fully configured MCP server on stdio with no server script required.
This approach uses LangChain's MCP adapters to connect to the WDK MCP server. WDK does not ship a native LangChain integration, it leverages the standard MCP protocol that LangChain already supports.
Want more control? The serve command is the fastest way to get running, but you can also write your own MCP server with the programmatic API for full control over wallets, tools, and protocols. Then point LangChain's MultiServerMCPClient at it using node your-server.js instead of the serve command.
The serve Command
The serve command provides zero-config MCP server startup so you don't need to write a server script:
npx @tetherto/wdk-mcp-toolkit servePass WDK_SEED to enable wallet operations, or omit it to run with pricing tools only:
# With wallet operations
WDK_SEED="your twelve word seed phrase here" npx @tetherto/wdk-mcp-toolkit serve
# Pricing-only mode (no seed required)
npx @tetherto/wdk-mcp-toolkit serveDefault Chains
By default, serve enables three chains: Ethereum, Arbitrum, and Bitcoin. For each enabled chain it dynamically imports the required wallet package and skips any that aren't installed. You can change the enabled set with the WDK_CHAINS environment variable.
Built-in Registry
The command has built-in definitions for 13 chains and 4 protocol modules. When a chain is enabled and its package is installed, the wallet is registered automatically. Protocol modules are also auto-registered when their packages are installed and at least one of their target chains is enabled.
| Module | Registers | Default |
|---|---|---|
@tetherto/wdk-wallet-evm | Ethereum, Arbitrum, Polygon, Optimism, Base, Avalanche, BNB, Plasma, Spark | Ethereum + Arbitrum enabled |
@tetherto/wdk-wallet-btc | Bitcoin | Enabled |
@tetherto/wdk-wallet-solana | Solana | Not enabled by default |
@tetherto/wdk-wallet-ton | TON | Not enabled by default |
@tetherto/wdk-wallet-tron | Tron | Not enabled by default |
@tetherto/wdk-protocol-swap-velora-evm | Swap tools (Ethereum, Arbitrum) | -- |
@tetherto/wdk-protocol-bridge-usdt0-evm | Bridge tools (Ethereum, Arbitrum) | -- |
@tetherto/wdk-protocol-lending-aave-evm | Lending tools (Ethereum) | -- |
@tetherto/wdk-protocol-fiat-moonpay | Fiat tools (Ethereum) | Requires MOONPAY_* env vars |
Missing packages are silently skipped. Install only the modules you need and serve will pick them up. For chains or protocols not in the built-in registry, use a custom config file.
Quick Start
Install dependencies
pip install langchain-mcp-adapters langgraph langchain-openaiCreate your agent
import asyncio
from langchain_mcp_adapters.client import MultiServerMCPClient
from langgraph.prebuilt import create_react_agent
from langchain_openai import ChatOpenAI
async def main():
client = MultiServerMCPClient({
"wdk": {
"transport": "stdio",
"command": "npx",
"args": ["-y", "@tetherto/wdk-mcp-toolkit", "serve"],
"env": {
"WDK_SEED": "your twelve word seed phrase here",
"WDK_MCP_ELICITATION": "false",
},
}
})
tools = await client.get_tools()
agent = create_react_agent(ChatOpenAI(model="gpt-4o"), tools)
result = await agent.ainvoke({
"messages": [{"role": "user", "content": "What is my Ethereum address?"}]
})
print(result["messages"][-1].content)
await client.close()
asyncio.run(main())Run it
export OPENAI_API_KEY="sk-..."
python agent.pySecurity -- Always use a dedicated development wallet with limited funds. Set WDK_MCP_ELICITATION to "false" for programmatic agents since elicitation dialogs require a human in the loop.
Configuration
Environment Variables
Control serve behavior through environment variables:
| Variable | Required | Default | Description |
|---|---|---|---|
WDK_SEED | No | -- | BIP-39 seed phrase. If omitted, only pricing tools are available |
WDK_CHAINS | No | ethereum,arbitrum,bitcoin | Comma-separated list of chains to enable |
WDK_MCP_ELICITATION | No | true | Set to "false" for programmatic agents that cannot handle confirmation dialogs |
WDK_RPC_\<CHAIN\> | No | Built-in defaults | Override the RPC endpoint for a chain (e.g. WDK_RPC_ETHEREUM=https://my-rpc.com) |
WDK_CONFIG | No | -- | Path to a wdk.config.json file for custom chains and protocols |
WDK_INDEXER_API_KEY | No | -- | Enables indexer tools for balance and transfer history queries |
MOONPAY_API_KEY | No | -- | Enables fiat on/off-ramp tools |
MOONPAY_SECRET_KEY | No | -- | Required with MOONPAY_API_KEY |
Custom Config File
For chains or protocols not in the built-in defaults, create a wdk.config.json and pass its path via WDK_CONFIG:
WDK_CONFIG=./wdk.config.json WDK_SEED="..." npx @tetherto/wdk-mcp-toolkit serve{
"chains": {
"zksync": {
"module": "@myorg/wdk-wallet-zksync",
"config": { "provider": "https://mainnet.era.zksync.io" }
},
"ethereum": {
"config": { "provider": "https://my-private-rpc.com" }
}
},
"protocols": [
{
"module": "@myorg/wdk-protocol-swap-custom",
"label": "custom-swap",
"type": "swap",
"chains": ["zksync"]
}
],
"enabledChains": ["ethereum", "zksync", "bitcoin"]
}| Field | Description |
|---|---|
chains | Add new chains or override config for built-in ones. New chains require a module field; overrides for existing chains can omit it |
protocols | Add custom protocols. Each entry requires module, label, and chains. The type field (swap, bridge, lending, fiat) maps to the corresponding built-in tool set |
enabledChains | Overrides WDK_CHAINS env var. If omitted, WDK_CHAINS is used |
LLM Provider Support
Both the Python and TypeScript examples support OpenAI and Anthropic. Set the corresponding environment variable and install the matching package:
| Provider | Environment Variable | Python Package | TypeScript Package |
|---|---|---|---|
| OpenAI | OPENAI_API_KEY | langchain-openai | @langchain/openai |
| Anthropic | ANTHROPIC_API_KEY | langchain-anthropic | @langchain/anthropic |
The examples auto-detect which provider to use based on which API key is set. If both are set, OpenAI takes priority.
Full examples -- See the complete interactive agent examples with conversation loops on GitHub: examples/langchain/python/ and examples/langchain/typescript/.