Skip to main content
Glama

Monad MCP Server

by lispking

Monad MCP 服务器

该 MCP(模型上下文协议)服务器旨在与 Monad 测试网交互。它为开发者提供了一套工具和功能,用于与 Monad 区块链交互,包括检查 MON 代币余额、发送交易、部署智能合约以及监控区块链事件。

什么是 MCP?

模型上下文协议 (MCP) 是一个标准化接口,使 AI 模型能够安全有效地与外部工具、服务和数据源交互。该服务器实现了 MCP,以便将 Monad 区块链功能暴露给兼容的 AI 代理或应用程序。

项目结构

该项目组织如下:

monad-mcp-server/ ├── .env.example # Example environment variables file ├── .gitignore # Specifies intentionally untracked files that Git should ignore ├── LICENSE # Project's software license ├── README.md # This file, providing an overview and instructions ├── package-lock.json # Records the exact versions of dependencies ├── package.json # Lists project dependencies and scripts ├── pnpm-lock.yaml # PNPM lockfile for dependency resolution ├── src/ # Source code directory │ ├── config/ # Configuration files │ │ └── server.ts # Server setup and Viem client initialization │ ├── index.ts # Main entry point of the application │ └── tools/ # MCP tools for interacting with Monad │ ├── block/ # Tools related to blockchain blocks (e.g., get-latest-block) │ ├── contract/ # Tools for smart contract interactions (e.g., deploy, watch events) │ ├── nft/ # Tools for Non-Fungible Tokens (e.g., query-mon-nft) │ └── wallet/ # Tools for wallet operations (e.g., get balance, send transactions) └── tsconfig.json # TypeScript compiler configuration

关键组件

  • src/index.ts :这是服务器的主入口。它初始化 MCP 服务器实例并注册所有可用工具(钱包、合约、NFT、区块)。
  • src/config/server.ts :此文件处理核心服务器配置。它设置McpServer实例的名称、版本和功能列表。它还初始化Viem公共客户端以便与 Monad 测试网交互,并提供了一个函数,可以使用来自环境变量的私钥创建Viem钱包客户端。服务器使用StdioServerTransport进行通信。
  • src/tools/ :此目录包含各种 MCP 工具的实现。每个子目录通常侧重于 Monad 交互的特定方面:
    • walletProvider :管理 MON 代币余额和交易。
    • contractProvider :处理智能合约部署和事件监视。
    • nftProvider :提供在 Monad 网络上查询 NFT 的功能。
    • blockProvider :提供检索块信息的工具。

先决条件

开始之前,请确保已安装以下软件:

  • Node.js(版本 16 或更高版本)
  • Node.js 包管理器: npmyarnpnpm (本项目在其示例中使用pnpm
  • Claude Desktop(或任何与 MCP 兼容的客户端)与服务器交互。

环境变量(.env)

该项目使用环境变量来管理敏感信息,主要是您的 Monad 帐户的私钥。

  1. 复制示例文件:创建.env.example的副本并将其重命名为.env
    cp .env.example .env
  2. 编辑.env :在文本编辑器中打开新创建的.env文件。
  3. 设置PRIVATE_KEY :将你的 Monad 帐户的私钥填入PRIVATE_KEY变量中。此密钥对于发送交易或部署合约等操作是必需的。
    PRIVATE_KEY="0xyourprivatekeyhere"
    重要提示:确保您的私钥以0x开头。
  4. 安全性切勿将.env文件提交到 Git 仓库。.gitignore .gitignore已配置为防止这种情况发生,但请务必注意保护您的私钥。

入门

按照以下步骤设置并运行 Monad MCP 服务器:

  1. 克隆存储库如果还没有,请从 GitHub 克隆该项目:
    git clone https://github.com/lispking/monad-mcp-server.git cd monad-mcp-server
  2. 安装依赖项使用pnpm (或您首选的包管理器)安装package.json中列出的项目依赖项:
    pnpm install
  3. 构建项目该服务器是用 TypeScript 编写的,需要编译成 JavaScript。运行构建脚本:
    pnpm build
    此命令将使用package.json中定义的tsc (TypeScript 编译器)将src目录中的源文件编译到build目录中。

服务器现已构建并可供 MCP 客户端使用。

服务器功能

根据src/config/server.ts中的定义,服务器公开以下功能:

  • get-mon-balance :检索帐户的 MON 代币余额。
  • send-mon-transaction :将 MON 代币从一个账户发送到另一个账户。
  • deploy-mon-contract :将智能合约部署到 Monad 测试网。
  • watch-contract-events :监控并报告特定智能合约发出的事件。
  • query-mon-nft :查询有关 Monad 网络上非同质化代币的信息。
  • get-latest-block :获取 Monad 测试网上最新区块的详细信息。
  • get-block-by-number :通过块编号检索特定块。

将 MCP 服务器配置添加到您的客户端

要将此服务器与兼容 MCP 的客户端(例如 Claude Desktop)一起使用,您需要将其配置添加到客户端的设置中。具体方法可能因客户端而异,但通常涉及指定如何运行服务器。

以下是示例配置片段:

{ "mcpServers": { // ... other server configurations ... "monad-mcp": { "command": "node", "args": [ "/absolute/path/to/your/project/monad-mcp-server/build/index.js" ], "env": { "PRIVATE_KEY": "<your_monad_private_key_if_not_using_dotenv_or_to_override>" } } // ... other server configurations ... } }

配置字段说明

  • "monad-mcp" :您在客户端中分配给此服务器配置的唯一名称。
  • "command": "node" :指定服务器是 Node.js 应用程序。
  • "args" :传递给node命令的参数数组。
    • 第一个参数是服务器编译入口点的路径: /absolute/path/to/your/project/monad-mcp-server/build/index.js/absolute/path/to/your/project/替换为您克隆monad-mcp-server仓库的实际绝对路径。
  • "env" :为服务器进程设置环境变量的对象。
    • "PRIVATE_KEY" :您可以在此处设置私钥。不过,为了提高安全性,通常建议使用.env文件。如果在此处设置,它可能会覆盖.env中的值,具体取决于客户端的行为和服务器的环境变量加载顺序。

注意:确保"args"中的路径正确并指向项目目录中的build/index.js文件。

更多资源

有关所使用的技术和涉及的概念的更多详细信息,请参阅以下官方文档:

这个全面的自述文件应该能帮助您深入了解 Monad MCP 服务器、其设置和用法。

Install Server
A
security – no known vulnerabilities
A
license - permissive license
A
quality - confirmed to work

hybrid server

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

模型上下文协议服务器使 AI 模型能够与 Monad 测试网交互,以检查代币余额、发送交易和部署智能合约。

  1. 什么是 MCP?
    1. 项目结构
      1. 关键组件
    2. 先决条件
      1. 环境变量(.env)
    3. 入门
      1. 服务器功能
        1. 将 MCP 服务器配置添加到您的客户端
          1. 更多资源

            Related MCP Servers

            • A
              security
              A
              license
              A
              quality
              A Model Context Protocol server that enables AI agents to interact with 30+ Ethereum-compatible blockchain networks, providing services like token transfers, contract interactions, and ENS resolution through a unified interface.
              Last updated -
              28
              230
              252
              TypeScript
              MIT License
            • -
              security
              F
              license
              -
              quality
              A Model Context Protocol server that enables AI assistants to access Flow blockchain data and perform operations such as checking balances, resolving domains, executing scripts, and submitting transactions.
              Last updated -
              JavaScript
              • Linux
              • Apple
            • -
              security
              F
              license
              -
              quality
              A Model Context Protocol server that enables AI agents to interact with the Flow blockchain through RPC calls, supporting account balances, script execution, transactions, domain resolution, and contract interactions.
              Last updated -
              82
              JavaScript
            • -
              security
              A
              license
              -
              quality
              A production-ready Model Context Protocol server implementation that connects AI assistants to the TON blockchain, allowing them to query wallet balances, transaction details, smart contracts, and other blockchain data.
              Last updated -
              TypeScript
              MIT License

            View all related MCP servers

            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/lispking/monad-mcp-server'

            If you have feedback or need assistance with the MCP directory API, please join our Discord server