MD

monad-developers/monad-mcp-tutorial

Developer tools

이 페이지는 AI로 자동 번역되었습니다. 기술적인 세부 사항은 원문을 확인하세요. 원문 보기

22 stars 12 forks 품질 53 트렌드 0

Monad MCP 자습서

개요

이 프로젝트는 Monad Testnet과 상호 작용하는 MCP 서버를 만드는 방법을 설명합니다. MCP 서버는 Monad testnet에서 MON 토큰 잔액을 확인하기위한 도구를 제공합니다. Model Context Protocol (MCP)은 AI 모델이 외부 도구 및 서비스와 상호 작용할 수 있는 표준입니다. 이 튜토리얼에서, 우리는 MCP 클라이언트 (Claude Desktop)을 허용하는 MCP 서버를 만들고 Monad testnet를 쿼리하여 계정의 MON 잔액을 확인합니다. - Node.js (v16 이상) - npm 또는 원사 - Claude 데스크탑 Monad Testnet 관련 구성은 src 폴더에 index.ts에 이미 추가됩니다. 아래는 get-mon-balance 도구의 비계입니다. 도구에 MON 잔액 검사 구현을 추가하자 : 4. MCP 서버에 대한 세부 정보를 추가하고 파일을 저장하십시오.

개요(AI 번역)

이 프로젝트는 Monad Testnet과 상호 작용하는 MCP 서버를 만드는 방법을 설명합니다. MCP 서버는 Monad testnet에서 MON 토큰 잔액을 확인하기위한 도구를 제공합니다.

MCP는 무엇입니까?

Model Context Protocol (MCP)은 AI 모델이 외부 도구 및 서비스와 상호 작용할 수 있는 표준입니다.

이 튜토리얼에서, 우리는 MCP 클라이언트 (Claude Desktop)을 허용하는 MCP 서버를 만들고 Monad testnet를 쿼리하여 계정의 MON 잔액을 확인합니다.

필수품

  • Node.js (v16 이상)
  • npm 또는 yarn
  • Claude 데스크탑

시작하기

  1. Clone 이 저장소

  2. 의존성 설치:

MCP 서버 구축

Monad Testnet 관련 구성은 이미 index.ts]] 폴더에 추가됩니다.

서버 인스턴스 정의

# MON 밸런스 도구 정의

아래는 get-mon-balance] 도구의 비계입니다:

도구에 MON 잔액 검사 구현을 추가하자 :

main 함수에서 수송과 서버 초기화

프로젝트 구축

서버는 이제 사용할 준비가되었습니다!

Claude Desktop에 MCP 서버 추가

  1. "Claude Desktop"을 엽니다.

  2. 설정 열기

클로드 > 설정 > 주요 특징

  1. 오픈 claude_desktop_config.json

이 페이지는 AI로 자동 번역되었습니다. 기술적인 세부 사항은 원문을 확인하세요.

README

원문 README의 일부입니다. 원문 보기.

Monad MCP Tutorial

This project demonstrates how to create a MCP server that interacts with the Monad testnet. The MCP 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)
                        }`,
                    },
                ],
            };
GitHub에서 전체 README 보기

설치

This server does not publish a one-line install command.

Open the repository installation guide MCP 초보자라면? mcpskill.org 가이드부터 시작하세요 →

설정

{ "mcpServers": { ... "monad-mcp": { "command": "node", "args": [ "/<path-to-project>/build/index.js" ] } } }