区块链智能合约接口
STDIO安全区块链交互系统保护用户密钥
安全区块链交互系统保护用户密钥
A secure system enabling AI assistants to interact with blockchain smart contracts while ensuring users maintain complete control over their private keys and transaction signing.
This project addresses a key challenge in AI-blockchain integration: allowing AI assistants to read blockchain data and prepare transactions while ensuring users maintain exclusive control over transaction signing and private keys.
The system consists of:
git clone https://github.com/zhangzhongnan928/mcp-blockchain-server.git cd mcp-blockchain-server
npm install # or yarn install
.env
file in the root directory (or copy from .env.example
):cp .env.example .env # Edit .env with your configurations
# 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
See Database Setup Guide for detailed instructions on installing and configuring PostgreSQL.
npm run dev # or yarn dev
For a quick start using Docker:
# Create .env file with required environment variables cp .env.example .env # Edit .env with your configurations # Start the services docker-compose up -d
This will start:
src/mcp
: MCP server implementationsrc/services
: Core business logic servicessrc/utils
: Utility functionssrc/index.ts
: Main entry pointweb/src/components
: React componentsweb/src/hooks
: Custom React hooksweb/src/services
: API servicesweb/src/pages
: Page componentsThe MCP Server exposes several tools that can be used by AI assistants:
get-chains
: Get list of supported blockchain networksget-balance
: Get account balance for an addressread-contract
: Read data from a smart contractprepare-transaction
: Prepare an unsigned transaction for user approvalget-transaction-status
: Get the current status of a transaction// Example of using the get-balance tool const result = await callTool("get-balance", { chainId: "1", address: "0x742d35Cc6634C0532925a3b844Bc454e4438f44e" });
If you encounter issues with dependencies:
# MCP SDK issue - install directly from GitHub npm uninstall @modelcontextprotocol/sdk npm install modelcontextprotocol/typescript-sdk
For database connection issues, see the Database Setup Guide.
This project is licensed under the MIT License - see the LICENSE file for details.