Bankless Onchain MCP Server について
Bankless Onchain MCP サーバーは、Bankless API から取得したオンチェーンデータを MCP クライアントに提供し、AI モデルがコントラクトの状態、ABI、イベントログを構造化された形で扱えるようにします。README によると、このプロジェクトは現在更新されていません。EVM コントラクトを扱う開発者や分析者を対象としています。
主な機能
- 01スマートコントラクトの状態とプロキシ実装の取得
- 02コントラクトの ABI と検証済みソースコードの取得
- 03アドレスとトピックによるイベントログのフィルタリング
- 04アドレスのトランザクション履歴と詳細の照会
- 05イベントトピックのシグネチャハッシュの生成
活用シーン
- 01AI モデルによるコントラクトの現在の状態の確認
- 02プロキシコントラクトから実装コントラクトへの追跡
- 03オンチェーン分析のためのフィルタ済みイベントログの取得
MCP 対応
MCP サーバーとして、read_contract、get_events、get_transaction_info などのツールを公開し、データは Bankless API から取得します。
設定
ローカルサーバーの設定はどのクライアントでも共通です。コピーしてクライアントの MCP 設定ファイルに貼り付けてください。
ツール
10掲載時のツール一覧 · 3 週間前に更新
| パラメーター | 型 | 必須 | 説明 |
|---|---|---|---|
| network | string | はい | ブロックチェーンネットワーク(例:"ethereum"、"base") |
| contract | string | はい | コントラクトアドレス |
| method | string | はい | 呼び出すコントラクトメソッド |
| inputs | array | はい | メソッド呼び出しの入力パラメーター |
| outputs | array | はい | メソッド呼び出しで想定される出力型です。 タプルの場合は tuple 型を使わず、内部の型(ソースに記載)を順番に指定してください。ネストされた構造体の場合は、子構造体の型を含めてください。 例: struct DataTypeA { DataTypeB b; //流動性インデックス。ray 単位で表現 uint128 liquidityIndex; } struct DataTypeB { address token; } 戻り値の型が DataTypeA(ABI ではタプル)の関数の場合、結果は outputs: [{"type": "address"}, {"type": "uint128"}] となります。 |
詳細
Bankless Onchain MCP サーバー
このプロジェクトは現在、更新されていません
Bankless API を通じてブロックチェーンデータを操作するための MCP(Model Context Protocol)サーバーです。
概要
Bankless Onchain MCP サーバーは、Bankless API を介してオンチェーンデータを操作するためのフレームワークを提供します。Model Context Protocol(MCP)を実装し、AI モデルがブロックチェーンの状態やイベントデータに構造化された方法でアクセスできるようにします。
https://github.com/user-attachments/assets/95732dff-ae5f-45a6-928a-1ae17c0ddf9d
機能
サーバーは、以下のオンチェーンデータ操作を提供します。
コントラクト操作
-
コントラクトの状態を読み取る(
read_contract):さまざまなブロックチェーンネットワーク上のスマートコントラクトから状態を読み取ります。- パラメーター:ネットワーク、コントラクトアドレス、メソッド、入力、出力
- 戻り値:型付きの値を含むコントラクト呼び出しの結果
-
プロキシを取得する(
get_proxy):プロキシの実装コントラクトアドレスを取得します。- パラメーター:ネットワーク、コントラクトアドレス
- 戻り値:実装コントラクトアドレス
-
ABI を取得する(
get_abi):コントラクトの ABI(Application Binary Interface)を取得します。- パラメーター:ネットワーク、コントラクトアドレス
- 戻り値:JSON 形式のコントラクト ABI
-
ソースを取得する(
get_source):検証済みコントラクトのソースコードを取得します。- パラメーター:ネットワーク、コントラクトアドレス
- 戻り値:ソースコード、ABI、コンパイラのバージョン、その他のコントラクトメタデータ
イベント操作
-
イベントを取得する(
get_events):トピックに基づいて、コントラクトのイベントログを取得します。- パラメーター:ネットワーク、アドレス、トピック、任意のトピック
- 戻り値:フィルタリングされたイベントログ
-
イベントトピックを構築する(
build_event_topic):イベント名と引数の型からイベントトピックのシグネチャを生成します。- パラメーター:ネットワーク、イベント名、引数の型
- 戻り値:イベントトピックのハッシュ
トランザクション操作
-
トランザクション履歴を取得する(
get_transaction_history):ユーザーアドレスのトランザクション履歴を取得します。- パラメーター:ネットワーク、ユーザーアドレス、任意のコントラクト、任意のメソッド ID、任意の開始ブロック、データを含めるかどうかのフラグ
- 戻り値:ハッシュ、データ、ネットワーク、タイムスタンプを含むトランザクションの一覧
-
トランザクション情報を取得する(
get_transaction_info):特定のトランザクションの詳細情報を取得します。- パラメーター:ネットワーク、トランザクションハッシュ
- 戻り値:ブロック番号、タイムスタンプ、送信元/送信先アドレス、値、ガス情報、ステータス、レシートデータなどのトランザクション詳細情報
ツール
-
read_contract
- ブロックチェーンからコントラクトの状態を読み取ります
- 入力:
network(string、必須):ブロックチェーンネットワーク(例:「ethereum」、「polygon」)contract(string、必須):コントラクトアドレスmethod(string、必須):呼び出すコントラクトメソッドinputs(array、必須):メソッド呼び出しの入力パラメーター。各要素には以下が含まれます:type(string):入力パラメーターの型(例:「address」、「uint256」)value(any):入力パラメーターの値
outputs(array、必須):期待される出力型。各要素には以下が含まれます:type(string):期待される出力型
- コントラクト呼び出しの結果を含む配列を返します
-
get_proxy
- 指定したネットワークとコントラクトのプロキシアドレスを取得します
- 入力:
network(string、必須):ブロックチェーンネットワーク(例:「ethereum」、「base」)contract(string、必須):コントラクトアドレス
- プロキシコントラクトの実装アドレスを返します
-
get_events
- 指定したネットワークとフィルター条件に一致するイベントログを取得します
- 入力:
network(string、必須):ブロックチェーンネットワーク(例:「ethereum」、「base」)addresses(array、必須):イベントをフィルタリングするコントラクトアドレスのリストtopic(string、必須):イベントをフィルタリングする主トピックoptionalTopics(array、任意):追加の任意トピック(null 値を含めることができます)
- フィルター条件に一致するイベントログを含むオブジェクトを返します
-
build_event_topic
- イベント名と引数に基づいてイベントトピックのシグネチャを作成します
- 入力:
network(string、必須):ブロックチェーンネットワーク(例:「ethereum」、「base」)name(string、必須):イベント名(例:「Transfer(address,address,uint256)」)arguments(array、必須):イベント引数の型。各要素には以下が含まれます:type(string):引数の型(例:「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 ツールでの使用
このサーバーは Model Context Protocol(MCP)を実装しているため、対応する AI モデル向けのツールプロバイダーとして使用できます。各ツールの呼び出し例を以下に示します:
read_contract
// 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..."]
}
]
}
build_event_topic
// 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 Server を使用するよう指示するには、以下のプロンプトを使用できます:
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.
ライセンス
MIT
コメント
AI アプリケーションが外部のツールやデータソースに統一的な方法で接続するためのオープンなプロトコルです。クライアントはモデルとの対話を担い、MCP サーバーはツール・リソース・プロンプトテンプレートを提供します。標準メッセージでやり取りするため、1 つのサーバーを複数のクライアントで再利用できます。