Skip to main content
Glama

MCP ブロックチェーンサーバー & DApp

AI アシスタントがブロックチェーン スマート コントラクトと対話し、ユーザーが秘密鍵とトランザクション署名を完全に制御できるようにする安全なシステム。

概要

このプロジェクトは、AI とブロックチェーンの統合における重要な課題に取り組んでいます。つまり、ユーザーがトランザクションの署名と秘密鍵を排他的に制御できるようにしながら、AI アシスタントがブロックチェーン データを読み取り、トランザクションを準備できるようにします。

このシステムは以下から構成されます:

  1. MCP サーバー: AI アシスタントが使用できるツールとしてブロックチェーン操作を公開するモデル コンテキスト プロトコル サーバー

  2. Web DApp : ウォレット接続とトランザクション署名のためのユーザーインターフェースを提供するReactアプリケーション

  3. データベース: ユーザー、API キー、トランザクション レコードを保存するための PostgreSQL データベース

  4. キャッシュ: 頻繁にアクセスされるデータをキャッシュするためのRedis

Related MCP server: ows-mcp-wallet

特徴

MCP サーバーの機能

  • ブロックチェーンデータアクセス: 残高、契約状態、その他のオンチェーンデータを読み取る

  • トランザクションの準備: ユーザーの承認のために署名されていないトランザクションを作成する

  • マルチチェーンサポート: Ethereum、Polygon、その他のEVM互換チェーンで動作します

  • スマートコントラクトインタラクション: サポートされているネットワーク上の検証済みスマートコントラクトから読み取ります

  • セキュリティ第一の設計: 秘密鍵はユーザーのウォレットから出ません

Web DAppの機能

  • ウォレット統合: MetaMaskや他のWeb3ウォレットと接続

  • 取引レビュー: 署名前に取引の詳細を確認するための明確なUI

  • トランザクション署名: 接続されたウォレットでトランザクションに署名する

  • トランザクション追跡: 送信されたトランザクションのステータスを監視する

  • モバイル互換性: レスポンシブデザインはすべてのデバイスで動作します

セキュリティ原則

  1. 秘密鍵の分離: 鍵はユーザーのウォレットから出ない

  2. 取引検証: 取引の詳細を確認するための明確なUI

  3. API認証:安全なAPIキー管理

  4. レート制限:不正使用を防ぐ

  5. 入力検証: すべての入力をサニタイズする

  6. 監査ログ: すべての操作を追跡

  7. HTTPSのみ: 安全な通信

  8. コンテンツセキュリティポリシー: XSSの防止

取引フロー

  1. AIアシスタントがMCPサーバーを介してトランザクションを要求する

  2. MCPサーバーはUUIDを使用して署名されていないトランザクションを準備します

  3. MCPサーバーはAIアシスタントにトランザクションURLを返します

  4. AIアシスタントがユーザーにURLを提供

  5. ユーザーがブラウザでURLを開く

  6. ユーザーはウォレットを接続し、取引の詳細を確認します

  7. ユーザーはウォレットで取引を承認し署名する

  8. Web DAppが署名されたトランザクションをブロックチェーンに送信する

  9. 取引ステータスが更新され追跡されます

はじめる

前提条件

  • Node.js (v18以上)

  • npmまたはyarn

  • PostgreSQL

  • Redis(オプション、キャッシュ用)

  • Infura APIキー(ブロックチェーンアクセス用)

  • Etherscan API キー(コントラクト ABI 用)

インストール

  1. リポジトリをクローンします。

git clone https://github.com/zhangzhongnan928/mcp-blockchain-server.git
cd mcp-blockchain-server
  1. 依存関係をインストールします:

npm install
# or
yarn install
  1. 環境変数を設定します。ルート ディレクトリに.envファイルを作成します (または.env.exampleからコピーします)。

cp .env.example .env
# Edit .env with your configurations
  1. データベースを設定します。

# For detailed instructions, see the Database Setup Guide
# docs/database-setup.md

# Create the PostgreSQL database
createdb mcp_blockchain

# Run database migrations
npm run db:migrate
# or
yarn db:migrate

PostgreSQL のインストールと構成の詳細な手順については、データベース セットアップ ガイドを参照してください。

  1. サーバーを起動します。

npm run dev
# or
yarn dev

Docker Composeの使用

Docker をすぐに使い始めるには:

# Create .env file with required environment variables
cp .env.example .env
# Edit .env with your configurations

# Start the services
docker-compose up -d

これは次のように始まります:

  • PostgreSQLデータベース

  • Redisキャッシュ

  • MCPサーバー

  • ウェブDApp

発達

サーバー構造

  • src/mcp : MCP サーバーの実装

  • src/services : コアビジネスロジックサービス

  • src/utils : ユーティリティ関数

  • src/index.ts : メインエントリポイント

Web DAppの構造

  • web/src/components : Reactコンポーネント

  • web/src/hooks : カスタム React フック

  • web/src/services : API サービス

  • web/src/pages : ページコンポーネント

MCPサーバーの使用

MCP サーバーは、AI アシスタントが使用できるいくつかのツールを公開します。

  • get-chains : サポートされているブロックチェーンネットワークのリストを取得する

  • get-balance : アドレスのアカウント残高を取得する

  • read-contract : スマートコントラクトからデータを読み取る

  • prepare-transaction : ユーザーの承認を得るために署名されていないトランザクションを準備する

  • get-transaction-status : トランザクションの現在のステータスを取得する

ツールの使用例

// Example of using the get-balance tool
const result = await callTool("get-balance", {
  chainId: "1",
  address: "0x742d35Cc6634C0532925a3b844Bc454e4438f44e"
});

トラブルシューティング

依存関係に関する問題が発生した場合:

# MCP SDK issue - install directly from GitHub
npm uninstall @modelcontextprotocol/sdk
npm install modelcontextprotocol/typescript-sdk

データベース接続の問題については、データベース設定ガイドを参照してください。

ライセンス

このプロジェクトは MIT ライセンスに基づいてライセンスされています - 詳細についてはLICENSEファイルを参照してください。

Available Tools

5 tools
get-balanceGet native balanceA
Read-only

Get an address's native-token balance (e.g. ETH) on a given chain.

ParametersJSON Schema
NameRequiredDescriptionDefault
addressYesThe wallet/contract address to check.
chainIdYesChain id, e.g. "1" for Ethereum or "11155111" for Sepolia.

TDQS

A3.6/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already provide readOnlyHint=true and openWorldHint=true, so the agent knows it's a safe, read-only operation. The description clarifies the asset type (native token) but adds no further behavioral traits like error handling or rate limits.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, concise sentence containing all essential information with no redundant words.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple balance query tool with readOnlyHint, the description is largely complete. However, it omits the return format (e.g., wei or decimal) and potential error conditions, which could be helpful given no output schema.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Input schema has 100% coverage with descriptions for both parameters (address, chainId). The description adds context about native tokens but no additional parameter-level details beyond what the schema provides, aligning with baseline for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses a specific verb ('Get') and identifies the resource ('native-token balance') with an example ('ETH'). It clearly states the scope ('on a given chain'), differentiating it from sibling tools like 'get-chains' or 'get-transaction-status'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It does not mention prerequisites, contexts where it is appropriate, or when to avoid it, such as for token balances other than native.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

get-chainsList supported chainsA
Read-only

List the blockchain networks this server supports, with their chain ids and native currencies.

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

TDQS

A4.1/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint=true (safe read) and openWorldHint=true (dynamic results). The description adds that it returns chain ids and native currencies, which is consistent and adds value. No further behavioral traits disclosed.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Single sentence, front-loaded with the verb and resource, no extraneous words. Each word earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given zero parameters, no output schema, and annotations covering safety and dynamism, the description is fully adequate for a simple listing tool. It specifies what is returned (chain ids and native currencies) without needing more.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

No parameters exist (schema coverage 100%), so the description's job of explaining the tool's action is fulfilled. The description adds meaning beyond the empty schema by detailing the output content.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool lists blockchain networks with chain ids and native currencies. The verb 'list' and resource 'supported chains' are specific and distinguish it from siblings like get-balance or prepare-transaction.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No explicit when-to-use or alternatives given, but the context implies it is for retrieving supported networks. Since siblings are functionally distinct, no exclusion guidance is needed, though mentioning its use as a prerequisite could improve clarity.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

get-transaction-statusGet transaction statusA
Read-only

Check the current status of a prepared transaction by its id.

ParametersJSON Schema
NameRequiredDescriptionDefault
idYesThe transaction id returned by prepare-transaction.

TDQS

A3.7/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The description adds 'current status', implying time-sensitivity, beyond the readOnlyHint and openWorldHint annotations. However, it does not disclose what the status entails, potential behaviors, or any side effects, leaving some ambiguity.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, front-loaded sentence with no wasted words. Every word serves a purpose, making it highly efficient.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simplicity (one parameter, no output schema, annotations present), the description is minimally adequate but lacks clarity on the return value or possible status types, which could improve completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% with a clear parameter description. The tool description adds no additional meaning beyond what is already in the schema, so baseline score of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'check', the resource 'status of a prepared transaction', and the method 'by its id'. It distinguishes from siblings like get-balance and prepare-transaction by focusing on transaction status.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage when you have a transaction id from prepare-transaction, but it does not explicitly state when to use or when not to use this tool, nor does it mention alternatives among siblings.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

prepare-transactionPrepare a transaction for signingA

Create an unsigned transaction and return a URL the user opens to review and sign it in their own wallet. Private keys never reach this server. Share the returned URL with the user.

ParametersJSON Schema
NameRequiredDescriptionDefault
toYesRecipient address.
dataNoCalldata hex for contract interactions. Defaults to "0x".
valueNoAmount of native token to send, e.g. "0.01". Defaults to "0".
chainIdYesChain id, e.g. "1".
gasLimitNoOptional gas limit (integer). The wallet estimates if omitted.

TDQS

A4/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The description adds value beyond annotations by disclosing that private keys never reach the server, a key security trait. With annotations already indicating openWorldHint=true, the description reinforces the user-involved workflow.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences with zero waste. Purpose is front-loaded and essential information is efficiently conveyed.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

No output schema, but the description explains the return is a URL for the user to review and sign. This covers the essential output without needing further detail.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% and parameter descriptions in the schema are clear. The description does not need to duplicate param details, so baseline 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool creates an unsigned transaction and returns a URL for user signing. It distinguishes itself from sibling tools which are read-only or informational (get-balance, get-chains, etc.).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage when needing to prepare a transaction for signing, but does not explicitly state when not to use or provide alternatives. It gives practical instructions (share URL with user) but lacks exclusion criteria.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

read-contractRead a smart contractA
Read-only

Call a read-only (view/pure) contract method. Provide abi as human-readable signatures (e.g. ["function balanceOf(address) view returns (uint256)"]) for zero-config use, or set ETHERSCAN_API_KEY to auto-fetch verified ABIs.

ParametersJSON Schema
NameRequiredDescriptionDefault
abiNoOptional ABI: a signature string, array of signatures, or JSON ABI.
argsNoArguments for the method, in order.
methodYesMethod name to call, e.g. "balanceOf".
addressYesContract address.
chainIdYesChain id, e.g. "1".

TDQS

A4.4/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already provide readOnlyHint and openWorldHint. Description adds behavioral context: calls view/pure methods, details ABI handling (zero-config or auto-fetch). No contradictions. Adequate beyond annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two concise sentences; first sentence states core purpose, second explains ABI configuration. No unnecessary words, front-loaded with key information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no output schema and generic nature of the tool, the description sufficiently covers how to invoke it. Mentions zero-config and Etherscan integration. Could optionally mention return format, but not critical.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so baseline 3. Description adds specific meaning for the abi parameter (how to provide signatures or use Etherscan), going beyond the schema's generic 'Optional ABI' description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool calls read-only (view/pure) contract methods, with specific verb and resource ('call a... contract method'), and distinguishes from sibling tools like prepare-transaction by emphasizing read-only.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Provides clear context for when to use (calling read-only methods) and explains ABI provision options (human-readable signatures or Etherscan). Implicitly excludes state-changing methods, but no explicit when-not-to-use statement.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 5 tool updatesv0.4.0
    • First observedget-balance
    • First observedget-chains
    • First observedget-transaction-status
    • First observedprepare-transaction
    • First observedread-contract

TDQS

A4.1/5.0

Scored across 5 tools

Disambiguation5/5

Each tool targets a distinct blockchain operation: balance query, chain listing, transaction status, transaction preparation, and contract reading. No functional overlap.

Naming Consistency5/5

All tool names follow a consistent verb_noun pattern with snake_case (e.g., get-balance, prepare-transaction). No mixing of styles.

Tool Count5/5

With 5 tools, the server covers core blockchain interactions without being excessive or too sparse. Each tool serves a clear purpose.

Completeness4/5

The tool set covers essential operations: balance, chain info, contract reading, and transaction lifecycle. Missing features like event log retrieval or gas estimation, but for basic blockchain interactions it is largely complete.

Maintenance

ActivityInactive
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers