LangChain (Python)
Call the BCA Crypto Brain from a LangChain Python agent. Two paths:
- Native Python MCP (
bca-mcpon PyPI, v0.1.0 shipping) — 8 read-only tools, same REST API, same envelope. Fastest path for pure-Python shops. - TS server via stdio — spawns
@blockchainacademics/mcpas a subprocess throughlangchain-mcp-adapters. Gets you all 99 tools today.
Both feed the same api.blockchainacademics.com backend. Pick whichever matches your deployment story.
Native bca-mcp is narrow by design — v0.1 is 8 tools on purpose (tight surface, sharp descriptions). Later versions expand toward parity with the TS sibling at 99.
Path A — native bca-mcp (8 tools, pure Python)
pip install bca-mcp langchain langchain-openai langchain-mcp-adaptersbca_native_agent.py
import asyncio
import os
import sys
from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client
from langchain_mcp_adapters.tools import load_mcp_tools
from langchain_openai import ChatOpenAI
from langgraph.prebuilt import create_react_agent
async def main() -> None:
params = StdioServerParameters(
command=sys.executable,
args=["-m", "bca_mcp"],
env={**os.environ, "BCA_API_KEY": os.environ["BCA_API_KEY"]},
)
async with stdio_client(params) as (r, w), ClientSession(r, w) as s:
await s.initialize()
tools = await load_mcp_tools(s)
print(f"Loaded {len(tools)} BCA tools")
agent = create_react_agent(ChatOpenAI(model="gpt-4o-mini"), tools)
result = await agent.ainvoke({
"messages": [("user",
"Using BCA tools, list the top 3 stories about stablecoin "
"regulation this month with citations.")]
})
print(result["messages"][-1].content)
if __name__ == "__main__":
asyncio.run(main())Wrapping specific tools as LangChain Tools directly
from langchain.tools import StructuredTool
# After load_mcp_tools(session), you get a list of StructuredTool objects —
# pick the ones you want rather than passing all 8 to the agent:
search_news = next(t for t in tools if t.name == "search_news")
get_entity = next(t for t in tools if t.name == "get_entity")
get_price = next(t for t in tools if t.name == "get_price")
agent = create_react_agent(ChatOpenAI(model="gpt-4o-mini"),
[search_news, get_entity, get_price])Narrow tool surfaces keep reasoning loops tight and predictable — highly recommended for production agents.
Path B — TS server via stdio (all 99 tools today)
1. Install
pip install langchain langchain-openai langchain-mcp-adapters
# Node 18+ required for the stdio subprocess
node --version2. Set your API key
export BCA_API_KEY="bca_YOUR_KEY_HERE"3. Spin up the agent
bca_agent.py
import asyncio
import os
from langchain_mcp_adapters.client import MultiServerMCPClient
from langchain_openai import ChatOpenAI
from langgraph.prebuilt import create_react_agent
async def main() -> None:
async with MultiServerMCPClient(
{
"blockchainacademics": {
"command": "npx",
"args": ["-y", "@blockchainacademics/mcp"],
"transport": "stdio",
"env": {"BCA_API_KEY": os.environ["BCA_API_KEY"]},
}
}
) as client:
tools = await client.get_tools()
print(f"Loaded {len(tools)} BCA tools")
agent = create_react_agent(
ChatOpenAI(model="gpt-4o-mini"),
tools,
)
result = await agent.ainvoke(
{
"messages": [
(
"user",
"Using BCA tools, list the top 3 news stories about "
"stablecoin regulation this month with citations.",
)
]
}
)
print(result["messages"][-1].content)
if __name__ == "__main__":
asyncio.run(main())Run it:
python bca_agent.pyWhat you get back
Every tool response is wrapped in the BCA envelope:
{
"data": [ ... ], # tool payload
"attribution": {
"citations": [
{
"cite_url": "https://blockchainacademics.com/article/...?src=langchain",
"as_of": "2026-04-20T09:31:22Z",
"source_hash": "sha256:a9f1...",
}
]
},
"meta": {
"status": "complete",
"request_id": "req_01HABCDEF0123456789ABCDEFG",
"pageInfo": {
"hasNextPage": False,
"hasPreviousPage": False,
"startCursor": None,
"endCursor": None,
},
},
}Parse attribution.citations[0].cite_url into your agent’s final answer so downstream users can verify the claim.
Tips
- Rate limits: Free tier is 60 req/min. Agent loops with tool retries can burn through this — cache aggressively or upgrade.
- Long-running jobs:
due_diligenceandtokenomics_modelenqueue agent jobs that return a job ID; pollget_job_statusuntildone. See the Tool reference. - Attribution: The
src=langchainUTM is added automatically when the subprocess detects a LangChain client. No extra work needed.