Skip to main content
Glama
akc2267

Solana MCP Server

by akc2267

getAccountInfo

Retrieve detailed account information for any Solana address, including balance and data, using specified encoding formats like base58, base64, or jsonParsed.

Instructions

Get detailed account information for a Solana address

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addressYesSolana account address
encodingNoData encoding format

Implementation Reference

  • Handler function that executes the getAccountInfo tool: validates input, calls Solana RPC getAccountInfo, formats data based on encoding (base58/base64), and returns formatted account details or error.
      async ({ address, encoding = 'base64' }) => {
        try {
          const publicKey = new PublicKey(address);
          const accountInfo = await connection.getAccountInfo(
            publicKey,
            'confirmed'
          );
    
          if (!accountInfo) {
            return {
              content: [
                {
                  type: "text",
                  text: `No account found for address: ${address}`,
                },
              ],
            };
          }
    
          // Format the data based on encoding
          let formattedData: string;
          if (encoding === 'base58') {
            formattedData = bs58.encode(accountInfo.data);
          } else if (encoding === 'base64') {
            formattedData = Buffer.from(accountInfo.data).toString('base64');
          } else {
            // For jsonParsed, we'll still return base64 but note that it's not parsed
            formattedData = Buffer.from(accountInfo.data).toString('base64');
          }
    
          return {
            content: [
              {
                type: "text",
                text: `Account Information for ${address}:
    Lamports: ${accountInfo.lamports} (${accountInfo.lamports / LAMPORTS_PER_SOL} SOL)
    Owner: ${accountInfo.owner.toBase58()}
    Executable: ${accountInfo.executable}
    Rent Epoch: ${accountInfo.rentEpoch}
    Data Length: ${accountInfo.data.length} bytes
    Data (${encoding}): ${formattedData}`,
              },
            ],
          };
        } catch (err) {
          const error = err as Error;
          return {
            content: [
              {
                type: "text",
                text: `Failed to retrieve account information: ${error.message}`,
              },
            ],
          };
        }
      }
  • Zod input schema defining parameters for the getAccountInfo tool: required address (string) and optional encoding (enum: base58, base64, jsonParsed).
    {
      address: z.string().describe("Solana account address"),
      encoding: z.enum(['base58', 'base64', 'jsonParsed']).optional().describe("Data encoding format"),
    },
  • src/index.ts:142-205 (registration)
    Registration of the getAccountInfo tool using server.tool(), including name, description, schema, and handler function.
    server.tool(
      "getAccountInfo",
      "Get detailed account information for a Solana address",
      {
        address: z.string().describe("Solana account address"),
        encoding: z.enum(['base58', 'base64', 'jsonParsed']).optional().describe("Data encoding format"),
      },
      async ({ address, encoding = 'base64' }) => {
        try {
          const publicKey = new PublicKey(address);
          const accountInfo = await connection.getAccountInfo(
            publicKey,
            'confirmed'
          );
    
          if (!accountInfo) {
            return {
              content: [
                {
                  type: "text",
                  text: `No account found for address: ${address}`,
                },
              ],
            };
          }
    
          // Format the data based on encoding
          let formattedData: string;
          if (encoding === 'base58') {
            formattedData = bs58.encode(accountInfo.data);
          } else if (encoding === 'base64') {
            formattedData = Buffer.from(accountInfo.data).toString('base64');
          } else {
            // For jsonParsed, we'll still return base64 but note that it's not parsed
            formattedData = Buffer.from(accountInfo.data).toString('base64');
          }
    
          return {
            content: [
              {
                type: "text",
                text: `Account Information for ${address}:
    Lamports: ${accountInfo.lamports} (${accountInfo.lamports / LAMPORTS_PER_SOL} SOL)
    Owner: ${accountInfo.owner.toBase58()}
    Executable: ${accountInfo.executable}
    Rent Epoch: ${accountInfo.rentEpoch}
    Data Length: ${accountInfo.data.length} bytes
    Data (${encoding}): ${formattedData}`,
              },
            ],
          };
        } catch (err) {
          const error = err as Error;
          return {
            content: [
              {
                type: "text",
                text: `Failed to retrieve account information: ${error.message}`,
              },
            ],
          };
        }
      }
    );
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool 'gets' information, implying a read-only operation, but doesn't clarify whether this requires authentication, has rate limits, returns structured data, or involves network calls. For a tool with no annotation coverage, this leaves significant behavioral gaps.

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, efficient sentence with zero waste. It's front-loaded with the core purpose and appropriately sized for a simple lookup tool. Every word earns its place without redundancy or unnecessary elaboration.

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

Completeness3/5

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

Given the tool's low complexity (2 parameters, no nested objects) and 100% schema coverage, the description is minimally adequate. However, with no annotations and no output schema, it doesn't provide enough context about return values, error conditions, or behavioral traits. It meets the bare minimum but lacks completeness for safe and effective use.

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%, with clear descriptions for both parameters (address and encoding with enum values). The description adds no parameter-specific information beyond what's in the schema, such as format details for the address or when to use specific encodings. Baseline 3 is appropriate since the schema does the heavy lifting.

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 verb 'Get' and resource 'detailed account information for a Solana address', making the purpose unambiguous. It distinguishes from siblings like getBalance (balance only) and getKeypairInfo (keypair-specific), though it doesn't explicitly mention these distinctions. The description is specific but could be more precise about what 'detailed account information' includes.

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?

The description provides no guidance on when to use this tool versus alternatives like getBalance or getKeypairInfo. There's no mention of prerequisites, context, or exclusions. The agent must infer usage from the tool name and description alone, which is insufficient for optimal tool selection.

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