
MCP Blockchain Server
A secure system enabling AI assistants to interact with blockchain data and prepare transactions while ensuring users maintain exclusive control over their private keys and transaction signing.
zhangzhongnan928
README
MCP Blockchain Server & DApp
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.
Overview
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:
- MCP Server: A Model Context Protocol server that exposes blockchain operations as tools that can be used by AI assistants
- Web DApp: A React application that provides a user interface for wallet connection and transaction signing
- Database: PostgreSQL database for storing users, API keys, and transaction records
- Caching: Redis for caching frequently accessed data
Features
MCP Server Features
- Blockchain Data Access: Read balances, contract state, and other on-chain data
- Transaction Preparation: Create unsigned transactions for user approval
- Multi-Chain Support: Works with Ethereum, Polygon, and other EVM-compatible chains
- Smart Contract Interaction: Read from verified smart contracts on supported networks
- Security-First Design: Private keys never leave the user's wallet
Web DApp Features
- Wallet Integration: Connect with MetaMask and other Web3 wallets
- Transaction Review: Clear UI for reviewing transaction details before signing
- Transaction Signing: Sign transactions with connected wallet
- Transaction Tracking: Monitor status of submitted transactions
- Mobile Compatibility: Responsive design works on all devices
Security Principles
- Private Key Isolation: Keys never leave the user's wallet
- Transaction Verification: Clear UI for reviewing transaction details
- API Authentication: Secure API key management
- Rate Limiting: Prevent abuse
- Input Validation: Sanitize all inputs
- Audit Logging: Track all operations
- HTTPS Only: Secure communications
- Content Security Policy: Prevent XSS
Transaction Flow
- AI assistant requests transaction through MCP Server
- MCP Server prepares unsigned transaction with UUID
- MCP Server returns transaction URL to AI assistant
- AI assistant provides URL to user
- User opens URL in browser
- User connects wallet and reviews transaction details
- User approves and signs transaction with their wallet
- Web DApp submits signed transaction to blockchain
- Transaction status is updated and tracked
Getting Started
Prerequisites
- Node.js (v18 or higher)
- npm or yarn
- PostgreSQL
- Redis (optional, for caching)
- Infura API key (for blockchain access)
- Etherscan API key (for contract ABIs)
Installation
- Clone the repository:
git clone https://github.com/zhangzhongnan928/mcp-blockchain-server.git
cd mcp-blockchain-server
- Install dependencies:
npm install
# or
yarn install
- Set up environment variables:
Create a
.env
file in the root directory (or copy from.env.example
):
cp .env.example .env
# Edit .env with your configurations
- Set up the database:
# 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.
- Start the server:
npm run dev
# or
yarn dev
Using Docker Compose
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:
- PostgreSQL database
- Redis cache
- MCP Server
- Web DApp
Development
Server Structure
src/mcp
: MCP server implementationsrc/services
: Core business logic servicessrc/utils
: Utility functionssrc/index.ts
: Main entry point
Web DApp Structure
web/src/components
: React componentsweb/src/hooks
: Custom React hooksweb/src/services
: API servicesweb/src/pages
: Page components
Using the MCP Server
The 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 Tool Usage
// Example of using the get-balance tool
const result = await callTool("get-balance", {
chainId: "1",
address: "0x742d35Cc6634C0532925a3b844Bc454e4438f44e"
});
Troubleshooting
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.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Recommended Servers
Crypto Price & Market Analysis MCP Server
A Model Context Protocol (MCP) server that provides comprehensive cryptocurrency analysis using the CoinCap API. This server offers real-time price data, market analysis, and historical trends through an easy-to-use interface.
VirusTotal MCP Server
A MCP server for querying the VirusTotal API. This server provides tools for scanning URLs, analyzing file hashes, and retrieving IP address reports.
mcp-shodan
MCP server for querying the Shodan API and Shodan CVEDB. This server provides tools for IP lookups, device searches, DNS lookups, vulnerability queries, CPE lookups, and more.

Azure MCP Server
Enables natural language interaction with Azure services through Claude Desktop, supporting resource management, subscription handling, and tenant selection with secure authentication.

chromia-mcp
Enables AI to interact with Chromia Wallet for sending $CHR transactions.
TripleWhale MCP Server
An implementation of Model Context Protocol (MCP) that allows users to interact with TripleWhale's e-commerce analytics platform using natural language queries through Claude Desktop.
Adamik MCP Server
Enables read and write interactions with 60+ blockchain networks through Claude Desktop, providing a standardized multi-chain API for transaction management, account insights, staking, and token interactions.

Story SDK MCP Server
This server provides MCP (Model Context Protocol) tools for interacting with Story's Python SDK. Features Get license terms Mint and register IP Asset with PIL Terms Mint license tokens Send $IP to a wallet Upload image to ipfs via Pinata [External] Upload ip and nft metadata via Pinata [External]
Open-Ledger-MCP-Server
A Model Context Protocol (MCP) server implementation for the OpenLedger API. This server provides structured context to AI models according to the MCP specification.
ntropy-mcp MCP Server
Enables enriching banking data with the Ntropy API, providing tools to create account holders and enrich transactions efficiently.