Tutorials & SDKs
Tutorial: Use Hive Tools in LangChain and CrewAI Agents
This tutorial shows how to add live Hive crypto data to LangChain and CrewAI agents. Use MCP when your framework can consume a remote tool server directly, and use REST custom tools when you want to expose only a small curated set of Hive calls.
Two ways to integrate
Option A: MCP Protocol (recommended)
LangChain and CrewAI both support MCP tool servers. This is the simplest path - your agent discovers and calls Hive tools at runtime through the MCP protocol.
LangChain with MCP:
from langchain_mcp_adapters.client import MultiServerMCPClient
from langgraph.prebuilt import create_react_agent
from langchain_anthropic import ChatAnthropic
model = ChatAnthropic(model="claude-sonnet-4-20250514")
async with MultiServerMCPClient(
{
"hive": {
"url": "https://mcp.hiveintelligence.xyz/mcp",
"transport": "streamable_http",
"headers": {"Authorization": "Bearer YOUR_HIVE_API_KEY"},
}
}
) as client:
tools = client.get_tools()
agent = create_react_agent(model, tools)
result = await agent.ainvoke(
{"messages": [{"role": "user", "content": "What's the current price of Bitcoin and is it safe to trade PEPE token?"}]}
)
Note: This uses the langchain-mcp-adapters package. Install with: pip install langchain-mcp-adapters langgraph langchain-anthropic
CrewAI with MCP:
CrewAI supports MCP servers natively. Add Hive to your crew config:
from crewai import Agent, Task, Crew
from crewai_tools import MCPServerAdapter
hive_tools = MCPServerAdapter(
server_url="https://mcp.hiveintelligence.xyz/mcp",
headers={"Authorization": "Bearer YOUR_HIVE_API_KEY"},
)
researcher = Agent(
role="Crypto Research Analyst",
goal="Provide accurate, real-time crypto market analysis",
tools=hive_tools.tools,
llm="claude-sonnet-4-20250514",
)
task = Task(
description="Analyze the top 5 DeFi protocols by TVL and check if their governance tokens are safe",
agent=researcher,
)
crew = Crew(agents=[researcher], tasks=[task])
result = crew.kickoff()
Option B: REST API as custom tools
If your framework doesn't support MCP, wrap the Hive REST API as custom LangChain tools:
from langchain_core.tools import tool
import requests
HIVE_API = "https://mcp.hiveintelligence.xyz/api/v1/execute"
HIVE_API_KEY = "YOUR_HIVE_API_KEY"
def hive_call(tool_name: str, args: dict) -> dict:
response = requests.post(
HIVE_API,
headers={"Authorization": f"Bearer {HIVE_API_KEY}", "Content-Type": "application/json"},
json={"tool": tool_name, "args": args},
timeout=30,
)
response.raise_for_status()
return response.json()
@tool
def get_crypto_price(coin_ids: str, currencies: str = "usd") -> str:
"""Get current prices for cryptocurrencies. coin_ids: comma-separated (e.g. 'bitcoin,ethereum')"""
result = hive_call("get_price", {"ids": coin_ids, "vs_currencies": currencies})
return str(result)
@tool
def check_token_security(chain_id: str, contract_address: str) -> str:
"""Check if a token contract is safe. chain_id: '1' for Ethereum, '56' for BSC."""
result = hive_call("get_token_security", {"chainId": chain_id, "contract_addresses": contract_address})
return str(result)
@tool
def get_defi_tvl(protocol: str = "") -> str:
"""Get DeFi protocol TVL data. Leave protocol empty for top protocols."""
result = hive_call("get_protocol_tvl", {"protocol": protocol} if protocol else {})
return str(result)
Then use with any LangChain agent:
from langchain_anthropic import ChatAnthropic
from langgraph.prebuilt import create_react_agent
model = ChatAnthropic(model="claude-sonnet-4-20250514")
agent = create_react_agent(model, [get_crypto_price, check_token_security, get_defi_tvl])
result = await agent.ainvoke(
{"messages": [{"role": "user", "content": "What's Bitcoin's price and is USDT safe?"}]}
)
Which approach to choose
| MCP (Option A) | REST Custom Tools (Option B) | |
|---|---|---|
| Setup | One connection, full catalog | Define each tool manually |
| Tool discovery | Automatic at runtime | Manual - you choose which tools to expose |
| Best for | Full access to Hive catalog | When you only need 3-5 specific tools |
| Framework support | LangChain, CrewAI, any MCP client | Any framework with custom tool support |
Category endpoints for focused agents
If your agent only needs market data, connect to the category endpoint instead of the root:
"hive-market-data": {
"url": "https://mcp.hiveintelligence.xyz/hive_market_data/mcp",
"transport": "streamable_http",
"headers": {"Authorization": "Bearer YOUR_HIVE_API_KEY"},
}
This gives your agent 70 market data tools instead of the full catalog - faster discovery, smaller context.
For broader research agents, keep the root endpoint and let the agent use Hive's compact discovery and routing flow. For production workflows with a fixed job, category endpoints usually make prompts easier to audit because the agent only sees the capability set it actually needs.
Next steps
- MCP Integration Tutorial - Connect Claude and Cursor
- REST API Tutorial - Direct HTTP integration
- Tools Reference - Browse all 10 categories
- Use Cases - See complete workflow examples