Framework Integration

LangChain & LangGraph MCP Crypto Trading Agent

LangGraph shines when a trading system needs deterministic state transitions, checkpointing, and mandatory human approval interrupts before live capital is committed. Eterna MCP supplies the execution and technical analysis layer without custom CCXT boilerplate.

Updated: By Eterna Engineering (MCP & Agent Infrastructure Team)Read as Markdown
Quick Answer

Connect LangChain or LangGraph to Eterna AI using `langchain-mcp-adapters` (`MultiServerMCPClient`) with `transport: 'streamable_http'` pointed at `https://mcp.eterna.exchange/mcp`. LangGraph's state graph lets you separate market research nodes, deterministic risk-check nodes, and human-in-the-loop interrupts before `execute_code` places any order.

Adapter Packagelangchain-mcp-adaptersPython and TypeScript support
Architecture FitResearch -> Risk -> ExecuteDeterministic graph guardrails
Human Approvalinterrupt()Pause graph before live placeOrder()
Markets800+ perps / 380+ spotSingle MCP endpoint
https://mcp.eterna.exchange/mcp

1. Wire Eterna MCP into LangGraph (Python)

Load the 3 Eterna MCP tools dynamically via `MultiServerMCPClient` and bind them to a LangGraph ReAct or custom state graph.

langgraph_eterna_agent.py
import asyncio
import os
from langchain_mcp_adapters.client import MultiServerMCPClient
from langgraph.prebuilt import create_react_agent

async def main():
    client = MultiServerMCPClient(
        {
            "eterna": {
                "transport": "streamable_http",
                "url": "https://mcp.eterna.exchange/mcp",
                "headers": {
                    "Authorization": f"Bearer {os.environ['ETERNA_ACCESS_TOKEN']}"
                },
            }
        }
    )
    tools = await client.get_tools()
    agent = create_react_agent("anthropic:claude-sonnet-4-5", tools)

    res = await agent.ainvoke(
        {
            "messages": [
                (
                    "user",
                    "Use execute_code to fetch SOLUSDT 15m RSI, Bollinger Bands, and current open positions. Propose a limit entry with stopLoss and takeProfit, but do not submit the order.",
                )
            ]
        }
    )
    print(res["messages"][-1].content)

asyncio.run(main())
Note: Works identically with OpenAI, Anthropic, or Gemini chat models via LangChain model strings.

2. Recommended 3-Node Production Topology

Do not let a single unconstrained LLM loop hold unchecked order authority. Split execution across explicit graph nodes.

2. Recommended 3-Node Production Topology
Graph NodeResponsibilityEterna SDK Calls Allowed
1. Scanner NodePull tickers, orderbooks, RSI/MACD/EMA/VWAP across watchlistgetTickers, getOrderbook, getRsi, getMacd, getEma, getVwap
2. Risk Gate Node (deterministic)Verify equity, drawdown limit, max open positions, and max leveragegetBalance, getPositions, getOrders
3. Execution Node (optional interrupt)Set leverage and place bracket order with mandatory SL/TPsetLeverage, placeOrder, setTradingStop, closePosition
FAQ

Frequently asked questions

Can LangGraph run with Python even though Eterna's sandbox runs TypeScript?
Yes. Your LangGraph orchestration runs in Python, while the LLM writes small TypeScript snippets passed to `execute_code` on Eterna's remote Deno sandbox. You never need Node.js installed on your Python server.
How do I prevent runaway loops in LangGraph?
Set `recursion_limit`, enforce a deterministic pre-trade Risk Gate node in Python, and cap funds inside the isolated Eterna agent sub-account.
Primary Sources

References & verification links

Start Trading via MCP

Connect your AI agent in 30 seconds

One remote MCP URL. 800+ USDT perpetuals, 380+ spot pairs, 0.014% maker / 0.035% taker, no KYC.

View on GitHub