MCP Blockchain Server

Integrations

  • Handles environment variable configuration for the MCP Blockchain Server

  • Provides containerization support for running the PostgreSQL database, Redis cache, MCP Server, and Web DApp as a complete system

  • Enables reading balances, contract state, and other on-chain data from the Ethereum blockchain, as well as preparing unsigned transactions for user approval and signing

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

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

概要

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

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

  1. MCP サーバー: AI アシスタントが使用できるツールとしてブロックチェーン操作を公開するモデル コンテキスト プロトコル サーバー
  2. Web DApp : ウォレット接続とトランザクション署名のためのユーザーインターフェースを提供するReactアプリケーション
  3. データベース: ユーザー、API キー、トランザクション レコードを保存するための PostgreSQL データベース
  4. キャッシュ: 頻繁にアクセスされるデータをキャッシュするためのRedis

特徴

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ファイルを参照してください。

-
security - not tested
A
license - permissive license
-
quality - not tested

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

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

  1. Overview
    1. Features
      1. MCP Server Features
      2. Web DApp Features
    2. Security Principles
      1. Transaction Flow
        1. Getting Started
          1. Prerequisites
          2. Installation
          3. Using Docker Compose
        2. Development
          1. Server Structure
          2. Web DApp Structure
        3. Using the MCP Server
          1. Example Tool Usage
        4. Troubleshooting
          1. License

            Related MCP Servers

            • -
              security
              F
              license
              -
              quality
              Enables secure interactions with cryptocurrency daemon RPC interfaces through AI assistants, supporting transaction management, wallet operations, and daemon monitoring for Bitcoin-derived cryptocurrencies.
              Last updated -
              1
              TypeScript
              • Apple
            • A
              security
              A
              license
              A
              quality
              Enables AI assistants to interact with the Hive blockchain through the Model Context Protocol, allowing for account info retrieval, content reading/creation, cryptocurrency transfers, and cryptographic operations.
              Last updated -
              13
              53
              TypeScript
              ISC License
              • Apple
            • A
              security
              A
              license
              A
              quality
              Provides tools for AI assistants to interact with the Ethereum blockchain through standard JSON-RPC methods, enabling queries for account balances, gas prices, and smart contract code.
              Last updated -
              6
              3
              JavaScript
              MIT License
            • -
              security
              A
              license
              -
              quality
              A comprehensive toolkit for building AI agents with blockchain capabilities, enabling interactions with multiple blockchain networks for tasks like wallet management, fund transfers, smart contract interactions, and cross-chain asset bridging.
              Last updated -
              2
              TypeScript
              GPL 3.0
              • Linux
              • Apple

            View all related MCP servers

            ID: 1hfkunwb7p