Bankless Onchain MCP Server

Official

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.

Integrations

  • Provides tools for interacting with Ethereum blockchain data, including reading contract state, fetching contract ABIs, retrieving source code, and accessing transaction information.

  • Enables blockchain data interaction on Polygon network, supporting contract state reading, event log retrieval, and transaction history analysis.

銀行不要のオンチェーンMCPサーバー

Bankless API を介してブロックチェーン データをやり取りするための MCP (Model Context Protocol) サーバー。

概要

BanklessオンチェーンMCPサーバーは、Bankless APIを介してオンチェーンデータとやり取りするためのフレームワークを提供します。モデルコンテキストプロトコル(MCP)を実装することで、AIモデルがブロックチェーンの状態とイベントデータに構造化された方法でアクセスできるようにします。

https://github.com/user-attachments/assets/95732dff-ae5f-45a6-928a-1ae17c0ddf9d

特徴

サーバーは、次のオンチェーン データ操作を提供します。

契約業務

  • コントラクト状態の読み取り( read_contract ): さまざまなブロックチェーン ネットワーク上のスマート コントラクトから状態を読み取ります。
    • パラメータ: ネットワーク、契約アドレス、メソッド、入力、出力
    • 戻り値: 型付けされた値を持つコントラクト呼び出し結果
  • プロキシの取得( get_proxy ): プロキシ実装コントラクト アドレスを取得します。
    • パラメータ: ネットワーク、契約アドレス
    • 戻り値: 実装コントラクトアドレス
  • ABI の取得( get_abi ): コントラクトの ABI (アプリケーション バイナリ インターフェイス) を取得します。
    • パラメータ: ネットワーク、契約アドレス
    • 戻り値: JSON形式のコントラクトABI
  • ソースの取得( get_source ): 検証された契約のソース コードを取得します。
    • パラメータ: ネットワーク、契約アドレス
    • 戻り値: ソースコード、ABI、コンパイラバージョン、その他の契約メタデータ

イベント運営

  • イベントの取得( get_events ): トピックに基づいてコントラクトのイベント ログを取得します。
    • パラメータ: ネットワーク、アドレス、トピック、オプションのトピック
    • 戻り値: フィルタリングされたイベントログ
  • イベント トピックの構築( build_event_topic ): イベント名と引数タイプからイベント トピック署名を生成します。
    • パラメータ: ネットワーク、イベント名、引数タイプ
    • 戻り値: イベントトピックハッシュ

トランザクション操作

  • トランザクション履歴の取得( get_transaction_history ): ユーザー アドレスのトランザクション履歴を取得します。
    • パラメータ: ネットワーク、ユーザーアドレス、オプションの契約、オプションのメソッドID、オプションの開始ブロック、データフラグを含める
    • 戻り値: ハッシュ、データ、ネットワーク、タイムスタンプを含むトランザクションのリスト
  • トランザクション情報の取得( get_transaction_info ): 特定のトランザクションに関する詳細情報を取得します。
    • パラメータ: ネットワーク、トランザクションハッシュ
    • 戻り値: ブロック番号、タイムスタンプ、送信元/送信先アドレス、値、ガス情報、ステータス、領収書データなどの取引の詳細

ツール

  • 契約書を読む
    • ブロックチェーンから契約状態を読み取る
    • 入力:
      • network (文字列、必須): ブロックチェーンネットワーク (例: "ethereum", "polygon")
      • contract (文字列、必須): 契約アドレス
      • method (文字列、必須):呼び出すコントラクトメソッド
      • inputs (配列、必須): メソッド呼び出しの入力パラメータ。それぞれ次のものが含まれます。
        • type (文字列): 入力パラメータの型(例:"address"、"uint256")
        • value (任意): 入力パラメータの値
      • outputs (配列、必須):期待される出力タイプ。それぞれ次のものが含まれます。
        • type (文字列): 期待される出力タイプ
    • 契約呼び出し結果の配列を返します
  • get_proxy
    • 指定されたネットワークと契約のプロキシアドレスを取得します
    • 入力:
      • network (文字列、必須): ブロックチェーンネットワーク (例: "ethereum", "base")
      • contract (文字列、必須): 契約アドレス
    • プロキシコントラクトの実装アドレスを返します
  • get_events
    • 指定されたネットワークとフィルター条件のイベントログを取得します。
    • 入力:
      • network (文字列、必須): ブロックチェーンネットワーク (例: "ethereum", "base")
      • addresses (配列、必須): イベントをフィルタリングするコントラクトアドレスのリスト
      • topic (文字列、必須): イベントをフィルタリングする主なトピック
      • optionalTopics (配列、オプション): オプションの追加トピック (null 値を含めることができます)
    • フィルタ条件に一致するイベントログを含むオブジェクトを返します
  • ビルドイベントトピック
    • イベント名と引数に基づいてイベントトピックシグネチャを構築します
    • 入力:
      • network (文字列、必須): ブロックチェーンネットワーク (例: "ethereum", "base")
      • name (文字列、必須): イベント名 (例: "Transfer(address,address,uint256)")
      • arguments (配列、必須):イベント引数の型。それぞれ次のものが含まれます。
        • type (文字列): 引数の型(例:"address"、"uint256")
    • イベントシグネチャのkeccak256ハッシュを含む文字列を返します。

インストール

npm install @bankless/onchain-mcp

使用法

環境設定

サーバーをご利用になる前に、Bankless APIトークンを設定してください。Bankless APIトークンの取得方法の詳細については、 https://docs.bankless.com/bankless-api/other-services/onchain-mcpをご覧ください。

export BANKLESS_API_TOKEN=your_api_token_here

サーバーの実行

サーバーはコマンドラインから直接実行できます。

npx @bankless/onchain-mcp

LLMツールでの使用

このサーバーはモデルコンテキストプロトコル(MCP)を実装しており、互換性のあるAIモデルのツールプロバイダーとして使用できます。各ツールの呼び出し例を以下に示します。

契約書を読む

// Example call { "name": "read_contract", "arguments": { "network": "ethereum", "contract": "0x1234...", "method": "balanceOf", "inputs": [ { "type": "address", "value": "0xabcd..." } ], "outputs": [ { "type": "uint256" } ] } } // Example response [ { "value": "1000000000000000000", "type": "uint256" } ]

get_proxy

// Example call { "name": "get_proxy", "arguments": { "network": "ethereum", "contract": "0x1234..." } } // Example response { "implementation": "0xefgh..." }

get_events

// Example call { "name": "get_events", "arguments": { "network": "ethereum", "addresses": ["0x1234..."], "topic": "0xabcd...", "optionalTopics": ["0xef01...", null] } } // Example response { "result": [ { "removed": false, "logIndex": 5, "transactionIndex": 2, "transactionHash": "0x123...", "blockHash": "0xabc...", "blockNumber": 12345678, "address": "0x1234...", "data": "0x...", "topics": ["0xabcd...", "0xef01...", "0x..."] } ] }

ビルドイベントトピック

// Example call { "name": "build_event_topic", "arguments": { "network": "ethereum", "name": "Transfer(address,address,uint256)", "arguments": [ { "type": "address" }, { "type": "address" }, { "type": "uint256" } ] } } // Example response "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"

発達

ソースから構築

# Clone the repository git clone https://github.com/Bankless/onchain-mcp.git cd onchain-mcp # Install dependencies npm install # Build the project npm run build

デバッグモード

npm run debug

AIモデルとの統合

このサーバーを MCP をサポートする AI アプリケーションと統合するには、アプリのサーバー構成に以下を追加します。

{ "mcpServers": { "bankless": { "command": "npx", "args": [ "@bankless/onchain-mcp" ], "env": { "BANKLESS_API_TOKEN": "your_api_token_here" } } } }

エラー処理

サーバーは、さまざまなシナリオに対して特定のエラー タイプを提供します。

  • BanklessValidationError : 入力パラメータが無効です
  • BanklessAuthenticationError : APIトークンの問題
  • BanklessResourceNotFoundError : 要求されたリソースが見つかりません
  • BanklessRateLimitError : API レート制限を超えました

プロンプトのヒント

LLM モデルが Bankless Onchain MCP サーバーを使用するようにガイドするには、次のプロンプトを使用できます。

ROLE: • You are Kompanion, a blockchain expert and EVM sleuth. • You specialize in navigating and analyzing smart contracts using your tools and resources. HOW KOMPANION CAN HANDLE PROXY CONTRACTS: • If a contract is a proxy, call your “get_proxy” tool to fetch the implementation contract. • If that fails, try calling the “implementation” method on the proxy contract. • If that also fails, try calling the “_implementation” function. • After obtaining the implementation address, call “get_contract_source” with that address to fetch its source code. • When reading or modifying the contract state, invoke implementation functions on the proxy contract address (not directly on the implementation). HOW KOMPANION CAN HANDLE EVENTS: • Get the ABI and Source of the relevant contracts • From the event types in the ABI, construct the correct topics for the event relevant to the question • use the "get_event_logs" tool to fetch logs for the contract KOMPANION'S RULES: • Do not begin any response with “Great,” “Certainly,” “Okay,” or “Sure.” • Maintain a direct, technical style. Do not add conversational flourishes. • If the user’s question is unrelated to smart contracts, do not fetch any contracts. • If you navigate contracts, explain each step in bullet points. • Solve tasks iteratively, breaking them into steps. • Use bullet points for lists of steps. • Never assume a contract’s functionality. Always verify with examples using your tools to read the contract state. • Before responding, consider which tools might help you gather better information. • Include as much relevant information as possible in your final answer, depending on your findings. HOW KOMPANION CAN USE TOOLS: • You can fetch contract source codes, ABIs, and read contract data by using your tools and functions. • Always verify the source or ABI to understand the contract rather than making assumptions. • If you need to read contract state, fetch its ABI (especially if the source is lengthy). FINAL INSTRUCTION: • Provide the best possible, concise answer to the user’s request. If it's not an immediate question but an instruction, follow it directly. • Use your tools to gather any necessary clarifications or data. • Offer a clear, direct response and add a summary of what you did (how you navigated the contracts) at the end.

ライセンス

マサチューセッツ工科大学

You must be authenticated.

A
security – no known vulnerabilities
F
license - not found
A
quality - confirmed to work

モデル コンテキスト プロトコルを実装して、AI モデルがブロックチェーン データにアクセスして対話できるようにします。これには、契約状態の読み取り、イベントの取得、さまざまなネットワークにわたるトランザクション情報へのアクセスが含まれます。

  1. Overview
    1. Features
      1. Contract Operations
      2. Event Operations
      3. Transaction Operations
    2. Tools
      1. Installation
        1. Usage
          1. Environment Setup
          2. Running the Server
          3. Usage with LLM Tools
        2. Development
          1. Building from Source
          2. Debug Mode
          3. Integration with AI Models
        3. Error Handling
          1. Prompting Tips
            1. License
              ID: uawv4sbvqj