SVM-MCP

Interaja com a SOON e outras blockchains baseadas em SVM. Consulte saldos, busque transações recentes e visualize posições de tokens.

Documentação

SVM-MCP: Servidor SOON Model Context Protocol

Um servidor Model Context Protocol (MCP) que integra o Claude AI com a SOON e outras blockchains baseadas em SVM. O servidor fornece ferramentas para verificar saldos, buscar transações recentes e visualizar participações em tokens na testnet e mainnet da SOON, para saldos de contas, transações e participações em tokens.

SVM-MCP MCP server

Visão Geral

Este servidor MCP foi projetado para conectar o Claude ao ecossistema SOON, permitindo que ele:

  • Consulte saldos de carteiras na testnet e mainnet
  • Busque as transações mais recentes de um endereço
  • Verifique participações em tokens de qualquer conta

A implementação atual usa os endpoints RPC da SOON, mas pode ser facilmente modificada para funcionar com qualquer blockchain compatível com Solana ou implementação SVM personalizada.

Recursos

  • Obter Saldos: Busque saldos de tokens nativos para qualquer endereço na testnet ou mainnet da SOON
  • Obter Última Transação: Recupere a transação mais recente de um endereço
  • Obter Contas de Tokens: Liste todas as contas de tokens pertencentes a um endereço

Pré-requisitos

  • Node.js (v16+)
  • Gerenciador de pacotes NPM ou Bun
  • Claude Desktop (para testes locais)

Instalação

  1. Clone o repositório:
git clone https://github.com/rkmonarch/svm-mcp
cd svm-mcp
  1. Instale as dependências:
npm install
# or
bun install
  1. Compile o projeto:
npm run build
# or
bun run build

Estrutura do Projeto

A implementação principal do servidor está em src/index.ts:

import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import { Connection, PublicKey } from "@solana/web3.js";
import { z } from "zod";

const connectionTestnet = new Connection("https://rpc.testnet.soo.network/rpc");
const connectionMainnet = new Connection("https://rpc.mainnet.soo.network/rpc");

const server = new McpServer({
  name: "svm-mcp",
  version: "0.0.1",
  capabilities: [
    "get-soon-testnet-balance",
    "get-soon-testnet-last-transaction",
    "get-soon-testnet-account-tokens",
    "get-soon-mainnet-balance",
    "get-soon-mainnet-last-transaction",
    "get-soon-mainnet-account-tokens",
  ],
});

Implementações das Ferramentas

Obter Saldo

server.tool(
  "get-soon-testnet-balance",
  "Get the balance of a address on the Soon testnet",
  {
    address: z.string().describe("The Solana address to get the balance of"),
  },
  async ({ address }) => {
    try {
      const balance = await connectionTestnet.getBalance(new PublicKey(address));
      return {
        content: [
          {
            type: "text",
            text: `Balance: ${balance}`,
          },
        ],
      };
    } catch (error) {
      return {
        content: [
          {
            type: "text",
            text: `Error getting balance: ${error instanceof Error ? error.message : String(error)}`,
          },
        ],
      };
    }
  }
);

Obter Última Transação

server.tool(
  "get-soon-testnet-last-transaction",
  "Get the last transaction of an address on the Soon testnet",
  {
    address: z
      .string()
      .describe("The Solana address to get the last transaction for"),
  },
  async ({ address }) => {
    try {
      // Fetch the most recent transaction signatures for the address
      const signatures = await connectionTestnet.getSignaturesForAddress(
        new PublicKey(address),
        { limit: 1 } // Limit to just the most recent transaction
      );

      if (signatures.length === 0) {
        return {
          content: [
            {
              type: "text",
              text: "No transactions found for this address",
            },
          ],
        };
      }

      // Get the most recent transaction using its signature
      const latestSignature = signatures[0].signature;
      const transaction = await connectionTestnet.getConfirmedTransaction(
        latestSignature
      );

      return {
        content: [
          {
            type: "text",
            text: JSON.stringify(transaction),
          },
        ],
      };
    } catch (error) {
      return {
        content: [
          {
            type: "text",
            text: `Error getting transaction: ${error instanceof Error ? error.message : String(error)}`,
          },
        ],
      };
    }
  }
);

Obter Contas de Tokens

server.tool(
  "get-soon-testnet-account-tokens",
  "Get the tokens of a address on the Soon testnet",
  {
    address: z.string().describe("The Solana address to get the tokens of"),
  },
  async ({ address }) => {
    try {
      const tokens = await connectionTestnet.getTokenAccountsByOwner(
        new PublicKey(address),
        {
          programId: new PublicKey("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"),
        }
      );
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify(tokens),
          },
        ],
      };
    } catch (error) {
      return {
        content: [
          {
            type: "text",
            text: `Error getting tokens: ${error instanceof Error ? error.message : String(error)}`,
          },
        ],
      };
    }
  }
);

Inicialização do Servidor

async function main() {
  try {
    console.error("Starting MCP server...");
    const transport = new StdioServerTransport();
    console.error("Transport initialized, connecting to server...");
    await server.connect(transport);
    console.error("Server connection established successfully");
    // The server will keep running in this state
  } catch (error) {
    console.error("There was an error connecting to the server:", error);
    process.exit(1);
  }
}

main().catch((err) => {
  console.error("There was an error starting the server:", err);
  process.exit(1);
});

Configuração

Configuração do Claude Desktop

Para usar este servidor MCP com o Claude Desktop, adicione o seguinte ao seu arquivo claude_desktop_config.json:

{
  "mcpServers": {
    "svm-mcp": {
      "command": "bun",
      "args": ["/path/to/svm-mcp/build/index.js"]
    }
  }
}

Personalizando Endpoints RPC

Para usar endpoints RPC diferentes ou conectar-se a uma blockchain compatível com Solana diferente, edite as URLs de conexão em src/index.ts:

const connectionTestnet = new Connection("YOUR_TESTNET_RPC_URL");
const connectionMainnet = new Connection("YOUR_MAINNET_RPC_URL");

Uso com o Claude

Depois que o servidor MCP estiver em execução e conectado ao Claude, você pode usar os seguintes comandos:

Verificando o Saldo de um Endereço

Can you check the balance of this SOON testnet address: <address>

Buscando Transações Recentes

What is the last transaction made by <address> on SOON testnet?

Recuperando Participações em Tokens

What tokens does <address> hold on SOON mainnet?

Agradecimentos