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: WETH

特徴

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.

Inputs: address (required), chainId (required).

get-chainsList supported chainsA
Read-only

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

Inputs: no named parameters.

get-transaction-statusGet transaction statusA
Read-only

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

Inputs: id (required).

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.

Inputs: to (required), chainId (required), data, value, +1 more.

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.

Inputs: method (required), address (required), chainId (required), abi, +1 more.

Tool Schema Changelog

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

Loading tool schema changelog…

    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 recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      Enables AI agents to check balances and send transactions across multiple blockchains with automatic spending limit protection and policy enforcement.
      3
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables AI agents to analyze Ethereum wallets, simulate transactions, and draft transfers with deterministic policy and risk scoring, requiring human approval before on-chain execution.
      12 npm
      ISC
    • A
      license
      A
      quality
      C
      maintenance
      Enables AI agents to query multichain balances, inspect smart contracts, and draft DeFi interactions while enforcing anti-drainer protections such as approval blocking, destination whitelisting, spend caps, and human approval gates.
      5
      Business Source 1.1