Bankless Onchain MCP Server
MCP (Model Context Protocol) server for blockchain data interaction through the Bankless API.
Overview
The Bankless Onchain MCP Server provides a framework for interacting with on-chain data via the Bankless API. It implements the Model Context Protocol (MCP) to allow AI models to access blockchain state and event data in a structured way.
https://github.com/user-attachments/assets/95732dff-ae5f-45a6-928a-1ae17c0ddf9d
Features
The server provides the following onchain data operations:
Contract Operations
- Read Contract State (
read_contract
): Read state from smart contracts on various blockchain networks.- Parameters: network, contract address, method, inputs, outputs
- Returns: Contract call results with typed values
- Get Proxy (
get_proxy
): Retrieve proxy implementation contract addresses.- Parameters: network, contract address
- Returns: Implementation contract address
- Get ABI (
get_abi
): Fetch the ABI (Application Binary Interface) for a contract.- Parameters: network, contract address
- Returns: Contract ABI in JSON format
- Get Source (
get_source
): Retrieve the source code for a verified contract.- Parameters: network, contract address
- Returns: Source code, ABI, compiler version, and other contract metadata
Event Operations
- Get Events (
get_events
): Fetch event logs for a contract based on topics.- Parameters: network, addresses, topic, optional topics
- Returns: Filtered event logs
- Build Event Topic (
build_event_topic
): Generate an event topic signature from event name and argument types.- Parameters: network, event name, argument types
- Returns: Event topic hash
Transaction Operations
- Get Transaction History (
get_transaction_history
): Retrieve transaction history for a user address.- Parameters: network, user address, optional contract, optional method ID, optional start block, include data flag
- Returns: List of transactions with hash, data, network, and timestamp
- Get Transaction Info (
get_transaction_info
): Get detailed information about a specific transaction.- Parameters: network, transaction hash
- Returns: Transaction details including block number, timestamp, from/to addresses, value, gas info, status, and receipt data
Tools
- read_contract
- Read contract state from a blockchain
- Input:
network
(string, required): The blockchain network (e.g., "ethereum", "polygon")contract
(string, required): The contract addressmethod
(string, required): The contract method to callinputs
(array, required): Input parameters for the method call, each containing:type
(string): The type of the input parameter (e.g., "address", "uint256")value
(any): The value of the input parameter
outputs
(array, required): Expected output types, each containing:type
(string): The expected output type
- Returns an array of contract call results
- get_proxy
- Gets the proxy address for a given network and contract
- Input:
network
(string, required): The blockchain network (e.g., "ethereum", "base")contract
(string, required): The contract address
- Returns the implementation address for the proxy contract
- get_events
- Fetches event logs for a given network and filter criteria
- Input:
network
(string, required): The blockchain network (e.g., "ethereum", "base")addresses
(array, required): List of contract addresses to filter eventstopic
(string, required): Primary topic to filter eventsoptionalTopics
(array, optional): Optional additional topics (can include null values)
- Returns an object containing event logs matching the filter criteria
- build_event_topic
- Builds an event topic signature based on event name and arguments
- Input:
network
(string, required): The blockchain network (e.g., "ethereum", "base")name
(string, required): Event name (e.g., "Transfer(address,address,uint256)")arguments
(array, required): Event arguments types, each containing:type
(string): The argument type (e.g., "address", "uint256")
- Returns a string containing the keccak256 hash of the event signature
Installation
Usage
Environment Setup
Before using the server, set your Bankless API token. For details on how to obtain your Bankless API token, head to https://docs.bankless.com/bankless-api/other-services/onchain-mcp
Running the Server
The server can be run directly from the command line:
Usage with LLM Tools
This server implements the Model Context Protocol (MCP), which allows it to be used as a tool provider for compatible AI models. Here are some example calls for each tool:
read_contract
get_proxy
get_events
build_event_topic
Development
Building from Source
Debug Mode
Integration with AI Models
To integrate this server with AI applications that support MCP, add the following to your app's server configuration:
Error Handling
The server provides specific error types for different scenarios:
BanklessValidationError
: Invalid input parametersBanklessAuthenticationError
: API token issuesBanklessResourceNotFoundError
: Requested resource not foundBanklessRateLimitError
: API rate limit exceeded
Prompting Tips
In order to guide an LLM model to use the Bankless Onchain MCP Server, the following prompts can be used:
License
MIT
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
Tools
实现模型上下文协议,允许 AI 模型访问和交互区块链数据,包括读取合约状态、检索事件以及访问跨各种网络的交易信息。
Related MCP Servers
- AsecurityAlicenseAqualityA Model Context Protocol server that enables AI agents to interact with 30+ Ethereum-compatible blockchain networks, providing services like token transfers, contract interactions, and ENS resolution through a unified interface.Last updated -28779302TypeScriptMIT License
- -securityFlicense-qualityA Model Context Protocol server that enables AI assistants to access Flow blockchain data and perform operations such as checking balances, resolving domains, executing scripts, and submitting transactions.Last updated -1JavaScript
- -securityFlicense-qualityA Model Context Protocol server that enables AI agents to interact with the Flow blockchain through RPC calls, supporting account balances, script execution, transactions, domain resolution, and contract interactions.Last updated -82JavaScript
- -security-license-qualityComprehensive Model Context Protocol server that enables AI agents to interact with 30+ Ethereum-compatible blockchain networks, supporting token transfers, smart contract interactions, and ENS name resolution through a unified interface.Last updated -1TypeScriptMIT License