MCP ExplorerExplorer

Monad Mcp

@AlexVagranton a year ago
1 MIT
FreeCommunity
AI Systems
Monad MCP is a server for checking MON token balances on the Monad testnet.

Overview

What is Monad Mcp

Monad-MCP is a server that implements the Model Context Protocol (MCP) to facilitate interactions between AI models and external services. Specifically, it allows clients to query the Monad testnet for MON token balances.

Use cases

Use cases for Monad-MCP include developing financial applications that monitor token balances, creating dashboards for users to view their assets on the Monad testnet, and integrating with AI systems for automated balance checks.

How to use

To use Monad-MCP, clone the repository, install the necessary dependencies using npm or yarn, and define the server instance along with the tools for checking MON balances. The server is built using Node.js.

Key features

Key features of Monad-MCP include the ability to check MON token balances on the Monad testnet, support for defining custom tools, and integration with AI clients like Claude Desktop.

Where to use

Monad-MCP can be used in blockchain applications, particularly those that require balance checks for tokens on the Monad testnet. It is suitable for developers building tools that interact with blockchain data.

Content

Monad MCP Tutorial

This project demonstrates how to create a MCP server that interacts with the Monad testnet. The server provides a tool for checking MON token balances on the Monad testnet.

What is MCP?

The Model Context Protocol (MCP) is a standard that allows AI models to interact with external tools and services.

In this tutorial, we’re creating an MCP server that allows MCP Client (Claude Desktop) to query Monad testnet to check MON balance of an account.

Prerequisites

  • Node.js (v16 or later)
  • npm or yarn
  • Claude Desktop

Getting Started

  1. Clone this repository
git clone https://github.com/monad-developers/monad-mcp-tutorial.git
  1. Install dependencies:
npm install

Building the MCP server

Monad Testnet related configuration is already added to index.ts in the src folder.

Define the server instance

// Create a new MCP server instance
const server = new McpServer({
  name: "monad-testnet",
  version: "0.0.1",
  // Array of supported tool names that clients can call
  capabilities: ["get-mon-balance"]
});

Defining the MON balance tool

Below is the scaffold of the get-mon-balance tool:

server.tool(
    // Tool ID 
    "get-mon-balance",
    // Description of what the tool does
    "Get MON balance for an address on Monad testnet",
    // Input schema
    {
        address: z.string().describe("Monad testnet address to check balance for"),
    },
    // Tool implementation
    async ({ address }) => {
        // code to check MON balance
    }
);

Let’s add the MON balance check implementation to the tool:

server.tool(
    // Tool ID 
    "get-mon-balance",
    // Description of what the tool does
    "Get MON balance for an address on Monad testnet",
    // Input schema
    {
        address: z.string().describe("Monad testnet address to check balance for"),
    },
    // Tool implementation
    async ({ address }) => {
        try {
            // Check MON balance for the input address
            const balance = await publicClient.getBalance({
                address: address as `0x${string}`,
            });

            // Return a human friendly message indicating the balance.
            return {
                content: [
                    {
                        type: "text",
                        text: `Balance for ${address}: ${formatUnits(balance, 18)} MON`,
                    },
                ],
            };
        } catch (error) {
            // If the balance check process fails, return a graceful message back to the MCP client indicating a failure.
            return {
                content: [
                    {
                        type: "text",
                        text: `Failed to retrieve balance for address: ${address}. Error: ${
                        error instanceof Error ? error.message : String(error)
                        }`,
                    },
                ],
            };
        }
    }
);

Initialize the transport and server from the main function

async function main() {
    // Create a transport layer using standard input/output
    const transport = new StdioServerTransport();
    
    // Connect the server to the transport
     await server.connect(transport);
    
    console.error("Monad testnet MCP Server running on stdio");
}

Build the project

npm run build

The server is now ready to use!

Adding the MCP server to Claude Desktop

  1. Open “Claude Desktop”

claude desktop

  1. Open Settings

Claude > Settings > Developer

claude settings

  1. Open claude_desktop_config.json

claude config

  1. Add details about the MCP server and save the file.
  1. Restart “Claude Desktop”

Using the MCP server

You should now be able to see the tools in Claude!

tools

Here’s the final result

final result

Further Resources

Tools

No tools

Comments

Recommend MCP Servers

View All MCP Servers