Skip to main content
Glama
noahgsolomon

Pump.fun MCP Server

by noahgsolomon

list-accounts

Retrieve and display all accounts stored in the keys folder for managing token transactions on the Pump.fun platform via the MCP server.

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- files), loads them, extracts public keys using Solana Keypair, and returns a list of accounts with names and public keys, or handles folder creation/errors.
    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' with no input parameters (empty schema), thin wrapper handler calling listAccounts() and formatListAccountsResult(), returning MCP-formatted 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"
                }`,
              },
            ],
          };
        }
      }
    );
  • Formats the listAccounts result into a human-readable string, listing account names and public keys or error/no accounts messages.
    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}`;
    }
  • Input schema for the list-accounts tool: empty object, no parameters required.
    {},
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 this is a list operation, implying it's likely read-only, but doesn't clarify permissions, rate limits, pagination, or what 'keys folder' represents. The description adds minimal behavioral context beyond the basic action.

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 for a simple list operation and front-loads the essential information.

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 simple list tool with no parameters and no output schema, the description provides the basic purpose but lacks important context. Without annotations, it should ideally clarify what 'accounts' and 'keys folder' mean, the return format, and any behavioral constraints. The description is minimally adequate but leaves gaps.

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 discuss parameters, maintaining focus on the tool's purpose. Baseline for 0 parameters with full coverage is 4.

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 this tool from its siblings like 'get-account-balance', which might also retrieve account information but with different scope or detail.

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 'create-token'. It doesn't mention prerequisites, context, or exclusions, leaving the agent to infer usage from the tool name alone.

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

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