MCP Blockchain Server
MCP 区块链服务器和 DApp
一个安全的系统,使人工智能助手能够与区块链智能合约交互,同时确保用户完全控制他们的私钥和交易签名。
概述
该项目解决了人工智能区块链集成中的一个关键挑战:允许人工智能助手读取区块链数据并准备交易,同时确保用户对交易签名和私钥保持独占控制。
该系统包括:
MCP 服务器:模型上下文协议服务器,将区块链操作公开为可供 AI 助手使用的工具
Web DApp :一个 React 应用程序,提供用于钱包连接和交易签名的用户界面
数据库:PostgreSQL 数据库,用于存储用户、API 密钥和交易记录
缓存:Redis 用于缓存经常访问的数据
Related MCP server: ows-mcp-wallet
特征
MCP 服务器功能
区块链数据访问:读取余额、合约状态和其他链上数据
交易准备:创建未签名的交易以供用户批准
多链支持:可与以太坊、Polygon 和其他 EVM 兼容链配合使用
智能合约交互:从支持网络上已验证的智能合约中读取
安全第一的设计:私钥永远不会离开用户的钱包
Web DApp 功能
钱包集成:连接 MetaMask 和其他 Web3 钱包
交易审查:清晰的用户界面,用于在签名前审查交易详情
交易签名:使用连接的钱包签署交易
交易跟踪:监控已提交交易的状态
移动兼容性:响应式设计适用于所有设备
安全原则
私钥隔离:密钥永远不会离开用户的钱包
交易验证:清晰的用户界面,用于审查交易详情
API 身份验证:安全 API 密钥管理
速率限制:防止滥用
输入验证:清理所有输入
审计日志:跟踪所有操作
仅 HTTPS :安全通信
内容安全策略:防止XSS
交易流程
AI助手通过MCP服务器请求交易
MCP 服务器使用 UUID 准备未签名交易
MCP 服务器返回交易 URL 给 AI 助手
AI助手向用户提供URL
用户在浏览器中打开 URL
用户连接钱包并查看交易详情
用户使用钱包批准并签署交易
Web DApp 将签名的交易提交至区块链
交易状态已更新并跟踪
入门
先决条件
Node.js(v18 或更高版本)
npm 或 yarn
PostgreSQL
Redis(可选,用于缓存)
Infura API 密钥(用于区块链访问)
Etherscan API 密钥(用于合约 ABI)
安装
克隆存储库:
git clone https://github.com/zhangzhongnan928/mcp-blockchain-server.git
cd mcp-blockchain-server安装依赖项:
npm install
# or
yarn install设置环境变量:在根目录中创建一个
.env文件(或从.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有关安装和配置 PostgreSQL 的详细说明,请参阅数据库设置指南。
启动服务器:
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 服务器
Web DApp
发展
服务器结构
src/mcp:MCP 服务器实现src/services:核心业务逻辑服务src/utils:实用程序函数src/index.ts:主入口点
Web DApp 结构
web/src/components:React 组件web/src/hooks:自定义 React hooksweb/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文件。
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseBqualityBmaintenanceTransforms AI assistants into autonomous crypto trading agents with real-time market analysis, portfolio management, and trade execution across 17+ blockchains.323252MIT
- AlicenseAqualityDmaintenanceEnables AI agents to check balances and send transactions across multiple blockchains with automatic spending limit protection and policy enforcement.3MIT
- FlicenseNot gradedqualityDmaintenanceEnable AI agents to manage Safe multisig wallets across multiple blockchains.
- AlicenseNot gradedqualityCmaintenanceNon-custodial TEE key management and signing for AI agents, supporting multiple blockchains.MIT
Related MCP Connectors
Provide AI agents and automation tools with contextual access to blockchain data including balance…
Bitcoin-anchored, tamper-evident audit log for AI agents — record, disclose and verify actions.
Durable wallet-addressed memory for AI agents: state that survives your process, opened by your key.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/zhangzhongnan928/mcp-blockchain-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server