The problem: LangChain agents are blind to live markets
LangChain makes it easy to build a reasoning agent, but the agent can only act through the tools you give it. Spin one up with no market tool and ask “is Bitcoin funding stretched?” and it will answer from the model's frozen memory — which means it will make the number up.
The fix is a custom Tool that calls a live crypto data API. Once the agent has it, the ReAct loop does the rest: it recognises the question needs market data, calls the tool, reads the JSON, and answers from real numbers.
Below is the whole thing — a one-call market tool, a typed coin-lookup tool, and how to drop them into an agent.
A crypto data Tool in ~20 lines
The modern LangChain way is the @tool decorator. The docstring becomes the tool description the model reads, so write it for the model:
import httpx
from langchain_core.tools import tool
BASE = "https://cryptodataapi.com/api/v1"
HEADERS = {"X-API-Key": "cdk_live_yourkey"}
@tool
def get_market_snapshot() -> dict:
"""Get a complete crypto market overview: prices, market health
score, derivatives positioning, sentiment, and macro. Use this
for any broad question about current market conditions."""
r = httpx.get(f"{BASE}/daily", headers=HEADERS, timeout=15)
return r.json()That is a fully working LangChain tool. The docstring is not decoration — it is the instruction the agent uses to decide when to call it, so state the trigger explicitly.
Wiring it into an agent
With the tool defined, bind it to a model and run the agent loop. Using LangGraph's prebuilt ReAct agent:
from langchain_anthropic import ChatAnthropic
from langgraph.prebuilt import create_react_agent
model = ChatAnthropic(model="claude-sonnet-5")
agent = create_react_agent(model, tools=[get_market_snapshot])
result = agent.invoke({
"messages": [("user", "Is the crypto market overheated today?")]
})
print(result["messages"][-1].content)The agent sees the question, calls get_market_snapshot, receives the real health score and sentiment, and answers from live data. Swap ChatAnthropic for ChatOpenAI and the exact same tool works — LangChain abstracts the provider away.
A StructuredTool with typed arguments
For tools that take arguments — like looking up a specific coin — give the model a typed schema so it fills the arguments correctly. A Pydantic model plus @tool does this cleanly:
from pydantic import BaseModel, Field
class CoinInput(BaseModel):
symbol: str = Field(description="Ticker symbol, e.g. BTC or ETH")
@tool(args_schema=CoinInput)
def get_coin_profile(symbol: str) -> dict:
"""Get price, market cap, and 24h/7d change for one coin."""
r = httpx.get(f"{BASE}/coins/{symbol}", headers=HEADERS, timeout=15)
return r.json()Now the agent knows the tool needs a symbol string and what it means. Pass both tools in a list — tools=[get_market_snapshot, get_coin_profile] — and the agent picks whichever the question calls for.
Native Tool vs the MCP adapter
LangChain can also consume our hosted MCP server through langchain-mcp-adapters. Two valid paths — pick by how much you want to hand-wire:
| Native @tool (this article) | MCP adapter | |
|---|---|---|
| Setup | Write a Python function per endpoint | Point the adapter at our /mcp URL |
| Control over shape | Full — you choose fields | Tools come as defined by the server |
| Endpoints exposed | Exactly the ones you write | All MCP tools at once |
| Best for | A tight, curated tool set | Fast access to everything |
Write native tools when you want a small, well-described set the agent chooses from quickly. Use the MCP adapter when you want the full toolset with zero per-endpoint code.
Best endpoints to expose and when to use this
Keep the toolset small and purpose-built. These five cover most agent tasks:
/daily— the one-call overview; make this your default market tool./market-health/summary— regime label plus long- and short-term scores./sentiment/fear-greed— sentiment as a single 0–100 number./derivatives/funding-rates— cross-exchange positioning./coins/{symbol}— per-coin drill-down (the StructuredTool above).
Use a native LangChain tool when you are building a Python agent and want tight control over exactly what it can query. To get a key with no signup form, one request does it:
curl -X POST https://cryptodataapi.com/api/v1/auth/keys \
-H "Content-Type: application/json" \
-d '{"email":"[email protected]"}'Ship the agent: grab a free key at cryptodataapi.com, paste the tool above, and your LangChain agent is reading live markets.



