Skip to main content
Glama

list-accounts

Retrieve all cryptocurrency wallet accounts stored in the keys folder for managing tokens on the Pump.fun platform.

Instructions

List all accounts in the keys folder

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Core handler function that scans the .keys directory for .json keypair files (excluding mint-), parses them into Solana Keypairs, and returns a list of account names and public keys. Handles missing folder by creating it.
    export async function listAccounts() {
      try {
        console.error("Starting listAccounts function");
    
        const keysFolder = path.resolve(rootDir, ".keys");
        console.error(`Using keys folder path: ${keysFolder}`);
    
        console.error(
          `Checking if keys folder exists: ${fs.existsSync(keysFolder)}`
        );
        if (!fs.existsSync(keysFolder)) {
          console.error(`Creating keys folder: ${keysFolder}`);
          try {
            fs.mkdirSync(keysFolder, { recursive: true });
            console.error(`Keys folder created successfully`);
            return {
              success: true,
              message: `No accounts found. Keys folder created at ${keysFolder}. Use the create-token or buy-token tools to create an account.`,
              accounts: [],
            };
          } catch (mkdirError: any) {
            console.error(`Error creating keys folder:`, mkdirError);
            return {
              success: false,
              error: `Error creating keys folder: ${
                mkdirError.message || JSON.stringify(mkdirError)
              }`,
              accounts: [],
            };
          }
        }
    
        console.error(`Reading files from keys folder: ${keysFolder}`);
        const files = fs.readdirSync(keysFolder);
        console.error(`Found ${files.length} files in keys folder`);
    
        const accounts = files
          .filter((file) => !file.startsWith("mint-") && file.endsWith(".json"))
          .map((file) => {
            const name = file.replace(".json", "");
            console.error(`Processing account file: ${file}`);
            try {
              const keypairData = JSON.parse(
                fs.readFileSync(path.join(keysFolder, file), "utf-8")
              );
              const keypair = Keypair.fromSecretKey(new Uint8Array(keypairData));
              return { name, publicKey: keypair.publicKey.toString() };
            } catch (error: any) {
              console.error(`Error processing account file ${file}:`, error);
              return { name, publicKey: "Error reading keypair" };
            }
          });
    
        console.error(`Found ${accounts.length} accounts`);
    
        if (accounts.length === 0) {
          return {
            success: true,
            message: `No accounts found in ${keysFolder}. Use the create-token or buy-token tools to create an account.`,
            accounts: [],
          };
        }
    
        return {
          success: true,
          message: `Accounts in ${keysFolder}:`,
          accounts,
        };
      } catch (error: any) {
        console.error("Error listing accounts:", error);
        console.error("Error stack:", error.stack);
    
        let errorMessage = "Unknown error";
        if (error) {
          if (typeof error === "object") {
            if (error.message) {
              errorMessage = error.message;
            } else {
              try {
                errorMessage = JSON.stringify(error);
              } catch (e) {
                errorMessage = "Error object could not be stringified";
              }
            }
          } else {
            errorMessage = String(error);
          }
        }
    
        return { success: false, error: errorMessage, accounts: [] };
      }
    }
  • src/index.ts:245-273 (registration)
    MCP tool registration for 'list-accounts'. Defines empty input schema ({}), thin wrapper handler that calls listAccounts() and formatListAccountsResult(), wraps in MCP response.
    server.tool(
      "list-accounts",
      "List all accounts in the keys folder",
      {},
      async () => {
        try {
          console.error("Listing accounts");
    
          const result = await listAccounts();
          const formattedResult = formatListAccountsResult(result);
    
          return createMcpResponse(
            formattedResult || "Error: No account information available"
          );
        } catch (error: any) {
          console.error("Error listing accounts:", error);
          return {
            content: [
              {
                type: "text" as const,
                text: `Error listing accounts: ${
                  error?.message || "Unknown error"
                }`,
              },
            ],
          };
        }
      }
    );
  • Helper function to format the listAccounts result into a human-readable string, handling success/error and empty list cases.
    export function formatListAccountsResult(
      result: ReturnType<typeof listAccounts> extends Promise<infer T> ? T : never
    ) {
      if (!result.success) {
        return `Error listing accounts: ${result.error}`;
      }
    
      if (result.accounts.length === 0) {
        return result.message;
      }
    
      const accountsText = result.accounts
        .map((account) => `${account.name}: ${account.publicKey}`)
        .join("\n");
    
      return `${result.message}\n\n${accountsText}`;
    }
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. While 'List' implies a read-only operation, it doesn't specify whether this requires authentication, what format the output takes, whether results are paginated, or any rate limits. The description is minimal and lacks important behavioral context.

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 states exactly what the tool does with zero wasted words. It's appropriately sized for a simple listing tool with no parameters and gets straight to the point without 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?

For a zero-parameter listing tool with no output schema, the description provides the basic purpose but lacks important context about authentication requirements, output format, or behavioral characteristics. While simple tools need less documentation, the absence of annotations means the description should compensate more than it does.

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

Parameters4/5

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

The tool has 0 parameters with 100% schema description coverage, so the schema already fully documents the parameter situation. The description appropriately doesn't mention parameters since none exist, maintaining focus on the tool's purpose rather than parameter details.

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 ('List') and target resource ('all accounts in the keys folder'), providing a specific verb+resource combination. However, it doesn't explicitly differentiate from sibling tools like 'get-account-balance' which retrieves specific account information rather than listing all accounts.

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 'get-account-balance' or other sibling tools. There's no mention of prerequisites, context for usage, or comparison with other listing/filtering tools that might exist.

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

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/dexoryn/pumpfun-mcp-server'

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