BA
OfficialFinance

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.

Quick Install
npx -y @bankless/onchain-mcp

Overview

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:

npm install @bankless/onchain-mcp

Set your Bankless API token as an environment variable before running:

# macOS / Linux
export BANKLESS_API_TOKEN=your_api_token_here

# Windows (PowerShell)
$env:BANKLESS_API_TOKEN="your_api_token_here"

Run the server locally using npx:

npx @bankless/onchain-mcp

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 namePurposeKey inputsTypical output
read_contractCall contract view methodsnetwork, contract, method, inputs, outputsTyped return values (array)
get_abiGet contract ABInetwork, contractABI JSON
get_sourceGet verified source & metadatanetwork, contractSource code, compiler, metadata
get_proxyResolve proxy implementationnetwork, contractimplementation address
get_eventsQuery event logs by topicsnetwork, addresses, topic, optionalTopicsFiltered event logs
build_event_topicBuild keccak256 topic for eventnetwork, name, argumentstopic hash string
get_transaction_historyList transactions for an addressnetwork, user, contract?, methodId?, startBlock?, includeData?Transactions list
get_transaction_infoGet detailed tx infonetwork, txHashReceipt, block, gas, status

Use Cases

  1. Read token balances or contract state from an LLM tool chain
    • Tool: read_contract
    • Example call:
{
  "name": "read_contract",
  "arguments": {
    "network": "ethereum",
    "contract": "0x6B175474E89094C44Da98b954EedeAC495271d0F",
    "method": "balanceOf",
    "inputs": [{ "type": "address", "value": "0xYourAddress..." }],
    "outputs": [{ "type": "uint256" }]
  }
}
  • Example response:
[
  { "value": "1500000000000000000", "type": "uint256" }
]
  1. Listen or fetch historical events for a contract (e.g., Transfer events)
    • Tool: build_event_topic + get_events
// build_event_topic arguments
{ "name": "Transfer(address,address,uint256)", "arguments": [{ "type": "address" }, { "type": "address" }, { "type": "uint256" }]}
// get_events arguments
{
  "network": "ethereum",
  "addresses": ["0xTokenAddress..."],
  "topic": "0xddf252ad...", 
  "optionalTopics": [null, "0x000...UserAddress"]
}
  1. Investigate transactions for a user or contract (audit, analytics)
    • Tool: get_transaction_history, get_transaction_info
{
  "name": "get_transaction_history",
  "arguments": {
    "network": "polygon",
    "user": "0xUserAddress...",
    "startBlock": 30000000,
    "includeData": true
  }
}
  1. 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

Tags:finance