WDK logoWDK documentation

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:

Terminal
npx @tetherto/wdk-mcp-toolkit serve

Pass WDK_SEED to enable wallet operations, or omit it to run with pricing tools only:

Terminal
# 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 serve

Default 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.

ModuleRegistersDefault
@tetherto/wdk-wallet-evmEthereum, Arbitrum, Polygon, Optimism, Base, Avalanche, BNB, Plasma, SparkEthereum + Arbitrum enabled
@tetherto/wdk-wallet-btcBitcoinEnabled
@tetherto/wdk-wallet-solanaSolanaNot enabled by default
@tetherto/wdk-wallet-tonTONNot enabled by default
@tetherto/wdk-wallet-tronTronNot enabled by default
@tetherto/wdk-protocol-swap-velora-evmSwap tools (Ethereum, Arbitrum)--
@tetherto/wdk-protocol-bridge-usdt0-evmBridge tools (Ethereum, Arbitrum)--
@tetherto/wdk-protocol-lending-aave-evmLending tools (Ethereum)--
@tetherto/wdk-protocol-fiat-moonpayFiat 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

Terminal
pip install langchain-mcp-adapters langgraph langchain-openai

Create your agent

agent.py
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

Terminal
export OPENAI_API_KEY="sk-..."
python agent.py

Security -- 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:

VariableRequiredDefaultDescription
WDK_SEEDNo--BIP-39 seed phrase. If omitted, only pricing tools are available
WDK_CHAINSNoethereum,arbitrum,bitcoinComma-separated list of chains to enable
WDK_MCP_ELICITATIONNotrueSet to "false" for programmatic agents that cannot handle confirmation dialogs
WDK_RPC_\<CHAIN\>NoBuilt-in defaultsOverride the RPC endpoint for a chain (e.g. WDK_RPC_ETHEREUM=https://my-rpc.com)
WDK_CONFIGNo--Path to a wdk.config.json file for custom chains and protocols
WDK_INDEXER_API_KEYNo--Enables indexer tools for balance and transfer history queries
MOONPAY_API_KEYNo--Enables fiat on/off-ramp tools
MOONPAY_SECRET_KEYNo--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:

Terminal
WDK_CONFIG=./wdk.config.json WDK_SEED="..." npx @tetherto/wdk-mcp-toolkit serve
wdk.config.json
{
  "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"]
}
FieldDescription
chainsAdd new chains or override config for built-in ones. New chains require a module field; overrides for existing chains can omit it
protocolsAdd custom protocols. Each entry requires module, label, and chains. The type field (swap, bridge, lending, fiat) maps to the corresponding built-in tool set
enabledChainsOverrides 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:

ProviderEnvironment VariablePython PackageTypeScript Package
OpenAIOPENAI_API_KEYlangchain-openai@langchain/openai
AnthropicANTHROPIC_API_KEYlangchain-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/.


Need Help?

On this page