Back to MCP directory
publicPublicdnsLocal runtime

metamask-mcp

MetaMask MCP是一个允许LLM通过MetaMask与区块链交互的MCP服务器,用户私钥安全存储在加密钱包中,AI代理签名或发送交易时无需接触私钥。

article

README

🚀 MetaMask MCP

MetaMask MCP 是一个模型上下文协议(MCP)服务器,它允许大语言模型(LLM)通过 MetaMask 与区块链进行交互。借助这些工具,你的私钥会安全地存储在加密钱包中,在签署消息或发送交易时,不会与 AI 代理共享。

🚀 快速开始

环境要求

  • Node.js(v20 或更高版本)
  • pnpm

项目搭建

  1. 克隆仓库
git clone https://github.com/Xiawpohr/metamask-mcp.git
cd metamask-mcp
  1. 安装依赖
pnpm install
  1. 构建项目
pnpm build

与 Claude Desktop 配合使用

按照指南 https://modelcontextprotocol.io/quickstart/user 操作,并添加以下配置:

{
  "mcpServers": {
    "metamask": {
      "command": "node",
      "args": [
        "/PATH/TO/YOUR_PROJECT/dist/index.ts"
      ]
    }
  }
}

✨ 主要特性

工具列表

  • call:立即执行新的消息调用,而不向网络提交交易。
  • get-chain-list:获取所有链信息的列表。
  • get-connect-uri:获取连接到 MetaMask 钱包的连接 URI。
  • show-connect-qrcode:显示给定连接 URI 的连接二维码。
  • deploy-contract:根据字节码和构造函数参数,将合约部署到网络。
  • disconnect:断开钱包连接。
  • estimate-fee-per-gas:估算交易在下一个区块中被包含的每单位 gas 费用(以 wei 为单位)。
  • estimate-gas:估算完成交易所需的 gas 量,而不向网络提交交易。
  • get-account:获取当前账户。
  • get-native-currency-balance:获取地址的原生货币余额。
  • get-token-balance:获取地址的代币余额。
  • get-block-number:获取最新区块编号。
  • get-block:获取指定编号、哈希或标签的区块信息。
  • get-chain-id:获取当前链 ID。
  • get-chains:获取已配置的链。
  • get-ens-address:获取 ENS 名称对应的地址。
  • get-ens-name:获取地址对应的主要 ENS 名称。
  • get-gas-price:获取当前 gas 价格(以 wei 为单位)。
  • get-token:获取代币信息。
  • get-transaction-reeceipt:根据交易哈希获取交易回执。
  • get-transaction:根据哈希或区块标识符获取交易信息。
  • read-contract:调用合约的只读函数并返回响应。
  • send-transaction:向网络发送交易。
  • sign-message:签署消息。
  • switch-chain:切换目标链。
  • verify-message:验证消息是否由指定地址签署。
  • wait-for-transaction-receipt:等待交易被包含在区块中,然后返回交易回执。
  • write-contract:执行合约的写入函数。

提示信息

📄 许可证

本项目采用 MIT 许可证。

预览

预览链接

贡献

欢迎贡献代码!请提交包含改进或修复的拉取请求。

help

Runtime guide

cloud

Hosted runtime

Hosted servers run from a provider-managed environment. You usually connect the MCP client to the hosted endpoint or follow the provider's authorization flow, without keeping a local process alive

  1. Open provider connection page
  2. Authorize or copy endpoint
  3. Connect from your MCP client
terminal

Local runtime / other methods

Local servers run on your own machine or infrastructure. You normally copy the server_config into your MCP client, install the required package, and provide env variables from env_schema when needed

  1. Copy server_config
  2. Install required package
  3. Fill env variables and restart client