Skip to main content
Glama
akc2267

Solana MCP Server

by akc2267

getKeypairInfo

Retrieve keypair details, including public key and balance, by providing the base58 encoded secret key using the Solana MCP Server tool.

Instructions

Get information about a keypair from its secret key

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
secretKeyYesBase58 encoded secret key or array of bytes

Implementation Reference

  • The handler function that implements the core logic of the getKeypairInfo tool: parses secretKey into Keypair, fetches balance and account info from Solana, formats and returns the information.
      async ({ secretKey }) => {
        try {
          // Handle both base58 encoded strings and byte arrays
          let keypair: Keypair;
          try {
            // First try parsing as comma-separated string
            const decoded = Uint8Array.from(secretKey.split(',').map(num => parseInt(num.trim())));
            keypair = Keypair.fromSecretKey(decoded);
          } catch {
            // If that fails, try as a byte array string
            keypair = Keypair.fromSecretKey(Uint8Array.from(JSON.parse(secretKey)));
          }
    
          // Get account info and balance
          const publicKey = keypair.publicKey;
          const balance = await connection.getBalance(publicKey);
          const accountInfo = await connection.getAccountInfo(publicKey);
    
          return {
            content: [
              {
                type: "text",
                text: `Keypair Information:
    Public Key: ${publicKey.toBase58()}
    Balance: ${balance / LAMPORTS_PER_SOL} SOL
    Account Program Owner: ${accountInfo?.owner?.toBase58() || 'N/A'}
    Account Size: ${accountInfo?.data.length || 0} bytes
    Is Executable: ${accountInfo?.executable || false}
    Rent Epoch: ${accountInfo?.rentEpoch || 0}`,
              },
            ],
          };
        } catch (err) {
          const error = err as Error;
          return {
            content: [
              {
                type: "text",
                text: `Failed to retrieve keypair information: ${error.message}`,
              },
            ],
          };
        }
      }
  • The input schema for the getKeypairInfo tool, defining the secretKey parameter using Zod.
    {
      secretKey: z.string().describe("Base58 encoded secret key or array of bytes"),
    },
  • src/index.ts:90-140 (registration)
    The registration of the getKeypairInfo tool using server.tool(), including name, description, schema, and inline handler.
    server.tool(
      "getKeypairInfo",
      "Get information about a keypair from its secret key",
      {
        secretKey: z.string().describe("Base58 encoded secret key or array of bytes"),
      },
      async ({ secretKey }) => {
        try {
          // Handle both base58 encoded strings and byte arrays
          let keypair: Keypair;
          try {
            // First try parsing as comma-separated string
            const decoded = Uint8Array.from(secretKey.split(',').map(num => parseInt(num.trim())));
            keypair = Keypair.fromSecretKey(decoded);
          } catch {
            // If that fails, try as a byte array string
            keypair = Keypair.fromSecretKey(Uint8Array.from(JSON.parse(secretKey)));
          }
    
          // Get account info and balance
          const publicKey = keypair.publicKey;
          const balance = await connection.getBalance(publicKey);
          const accountInfo = await connection.getAccountInfo(publicKey);
    
          return {
            content: [
              {
                type: "text",
                text: `Keypair Information:
    Public Key: ${publicKey.toBase58()}
    Balance: ${balance / LAMPORTS_PER_SOL} SOL
    Account Program Owner: ${accountInfo?.owner?.toBase58() || 'N/A'}
    Account Size: ${accountInfo?.data.length || 0} bytes
    Is Executable: ${accountInfo?.executable || false}
    Rent Epoch: ${accountInfo?.rentEpoch || 0}`,
              },
            ],
          };
        } catch (err) {
          const error = err as Error;
          return {
            content: [
              {
                type: "text",
                text: `Failed to retrieve keypair 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 action ('Get information') but doesn't describe what information is returned, whether it's read-only, if there are rate limits, or authentication requirements. For a tool with no annotations, 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 that directly states the tool's purpose without unnecessary words. It's appropriately sized and front-loaded, making it easy to parse quickly.

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?

Given the lack of annotations and no output schema, the description is incomplete. It doesn't explain what information is returned about the keypair (e.g., public key, balance, permissions), leaving the agent uncertain about the tool's output. For a tool with no structured output documentation, 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%, with the parameter 'secretKey' fully documented in the schema as 'Base58 encoded secret key or array of bytes'. The description adds no additional parameter semantics beyond what the schema provides, so it meets the baseline of 3 for high schema coverage.

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 information') and resource ('about a keypair'), making the purpose understandable. However, it doesn't differentiate from sibling tools like getAccountInfo or getBalance, which also retrieve information about different resources. The description is specific but lacks sibling distinction.

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 on when to use this tool versus alternatives. The description doesn't mention prerequisites, context for usage, or comparisons to sibling tools like getAccountInfo (which might retrieve different account details). This leaves the agent without explicit direction on 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