Bankless Onchain MCP Server for Blockchain Data
Access blockchain data via the Bankless API with an MCP server for fast, secure onchain queries and integrations.
npx -y @bankless/onchain-mcpOverview
The Bankless Onchain MCP Server implements the Model Context Protocol (MCP) to expose blockchain state, events and transaction data through a standardized, model-friendly interface. It sits between AI models (or other MCP-capable clients) and the Bankless API, translating MCP tool calls into on-chain queries and returning typed, structured results. This makes it straightforward to integrate real-time onchain data into LLM workflows, bots, or backend services.
Designed for speed and security, the server supports multiple EVM networks (Ethereum, Polygon, Base, etc.), contract ABI lookups, event filtering, proxy resolution, and historical transaction lookup. Developers can run the server locally or as a service and use MCP-compatible LLM tooling to access blockchain context without modifying model internals.
Features
- Read smart contract state (typed method calls)
- Fetch verified contract source and ABI
- Resolve proxy implementations for upgradable contracts
- Build event topics and query event logs with topic filters
- Retrieve transaction histories and detailed transaction receipts
- MCP-compatible tool endpoints for smooth integration with LLMs and orchestration frameworks
- Supports multiple networks and returns typed values (e.g., uint256, address)
Installation / Configuration
Install the package via npm:
Set your Bankless API token as an environment variable before running:
# macOS / Linux
# Windows (PowerShell)
$env:BANKLESS_API_TOKEN="your_api_token_here"
Run the server locally using npx:
For CI / production, run the package in a container or a process manager and provide the BANKLESS_API_TOKEN securely (secrets manager, env vars).
Available Tools
The server exposes MCP-compatible tools that map to common onchain operations. Use these tools from any MCP client (LLM tool runner) by calling the tool name and passing the JSON arguments.
| Tool name | Purpose | Key inputs | Typical output |
|---|---|---|---|
| read_contract | Call contract view methods | network, contract, method, inputs, outputs | Typed return values (array) |
| get_abi | Get contract ABI | network, contract | ABI JSON |
| get_source | Get verified source & metadata | network, contract | Source code, compiler, metadata |
| get_proxy | Resolve proxy implementation | network, contract | implementation address |
| get_events | Query event logs by topics | network, addresses, topic, optionalTopics | Filtered event logs |
| build_event_topic | Build keccak256 topic for event | network, name, arguments | topic hash string |
| get_transaction_history | List transactions for an address | network, user, contract?, methodId?, startBlock?, includeData? | Transactions list |
| get_transaction_info | Get detailed tx info | network, txHash | Receipt, block, gas, status |
Use Cases
- Read token balances or contract state from an LLM tool chain
- Tool: read_contract
- Example call:
- Example response:
- Listen or fetch historical events for a contract (e.g., Transfer events)
- Tool: build_event_topic + get_events
// build_event_topic arguments
// get_events arguments
- Investigate transactions for a user or contract (audit, analytics)
- Tool: get_transaction_history, get_transaction_info
- Verify contract source or fetch ABI before decoding logs
- Tools: get_source, get_abi
Notes for developers
- The server expects a valid BANKLESS_API_TOKEN. See the Bankless docs for token provisioning.
- Responses are typed to make downstream parsing predictable for LLMs and code.
- Use the MCP tool names directly from your model orchestration layer to enable contextual onchain lookups without changing model weights.
Repository and source code: https://github.com/bankless/onchain-mcp