Skip to main content
Glama
akc2267

Solana MCP Server

by akc2267

getBalance

Check the SOL balance of a specific Solana account address using a simple RPC endpoint provided by the Solana MCP Server.

Instructions

Get balance for a Solana address

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addressYesSolana account address

Implementation Reference

  • The main execution logic for the getBalance tool. Parses the address into a PublicKey, retrieves the lamports balance from Solana RPC, converts to SOL, and returns formatted response or error.
    async ({ address }) => {
      try {
        const publicKey = new PublicKey(address);
        const balance = await connection.getBalance(publicKey);
        const solBalance = balance / LAMPORTS_PER_SOL; // Using LAMPORTS_PER_SOL constant
    
        return {
          content: [
            {
              type: "text",
              text: `Balance for ${address}:\n${solBalance} SOL`,
            },
          ],
        };
      } catch (err) {
        const error = err as Error;
        return {
          content: [
            {
              type: "text",
              text: `Failed to retrieve balance for address: ${error.message}`,
            },
          ],
        };
      }
    }
  • Zod input schema validating the 'address' parameter as a string with description.
    {
      address: z.string().describe("Solana account address"),
    },
  • src/index.ts:56-88 (registration)
    Calls server.tool() to register the getBalance tool with its name, description, schema, and handler function.
    server.tool(
      "getBalance",
      "Get balance for a Solana address",
      {
        address: z.string().describe("Solana account address"),
      },
      async ({ address }) => {
        try {
          const publicKey = new PublicKey(address);
          const balance = await connection.getBalance(publicKey);
          const solBalance = balance / LAMPORTS_PER_SOL; // Using LAMPORTS_PER_SOL constant
    
          return {
            content: [
              {
                type: "text",
                text: `Balance for ${address}:\n${solBalance} SOL`,
              },
            ],
          };
        } catch (err) {
          const error = err as Error;
          return {
            content: [
              {
                type: "text",
                text: `Failed to retrieve balance for address: ${error.message}`,
              },
            ],
          };
        }
      }
    );
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It states it 'gets' data (implying read-only), but doesn't mention potential limitations like network requirements, error conditions, rate limits, or what format the balance is returned in. This leaves significant gaps for a tool that interacts with blockchain data.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, clear sentence with zero wasted words. It's front-loaded with the essential information and appropriately sized for a simple tool with one parameter.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a blockchain balance query tool with no annotations and no output schema, the description is insufficient. It doesn't explain what the balance represents (native SOL, tokens, etc.), units, precision, or error handling. Given the complexity of blockchain interactions and lack of structured metadata, more context is needed.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100% (the 'address' parameter is fully documented in the schema), so the baseline is 3. The description adds no additional parameter information beyond what's already in the schema, but doesn't need to compensate for gaps either.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Get balance') and target resource ('for a Solana address'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'getAccountInfo' which might also provide balance information, preventing a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided about when to use this tool versus alternatives like 'getAccountInfo' or 'getKeypairInfo'. The description only states what it does, not when it's appropriate or what distinguishes it from similar tools.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

Latest Blog Posts

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/akc2267/solana-mcp-server'

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