get-token-info
Retrieve detailed information about any Pump.fun token using its mint address to analyze token data and make informed trading decisions.
Instructions
Get information about a Pump.fun token
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tokenAddress | Yes | The token's mint address |
Implementation Reference
- src/get-token-info.ts:37-61 (handler)Core handler function that initializes PumpFunSDK, fetches the bonding curve account for the given token mint address, computes the formatted total supply, and returns structured token information.export async function getTokenInfo(tokenAddress: string) { const { sdk } = initializeSDK(); console.log("SDK initialized"); const mintPublicKey = new PublicKey(tokenAddress); console.log("Getting bonding curve account..."); const bondingCurveAccount = await sdk.getBondingCurveAccount(mintPublicKey); if (!bondingCurveAccount) { console.log(`No token found with address ${tokenAddress}`); return null; } const tokenTotalSupply = (bondingCurveAccount as any).tokenTotalSupply; const formattedSupply = tokenTotalSupply ? Number(tokenTotalSupply) / Math.pow(10, DEFAULT_DECIMALS) : "Unknown"; return { tokenAddress, bondingCurveAccount, formattedSupply, pumpfunUrl: `https://pump.fun/${tokenAddress}`, }; }
- src/index.ts:56-96 (registration)Registers the 'get-token-info' tool with the MCP server, defining its name, description, input schema, and a wrapper handler that delegates to getTokenInfo, handles errors, and formats the MCP response.server.tool( "get-token-info", "Get information about a Pump.fun token", { tokenAddress: z.string().describe("The token's mint address"), }, async ({ tokenAddress }, extra) => { try { console.error(`Checking token info for: ${tokenAddress}`); const tokenInfo = await getTokenInfo(tokenAddress); if (!tokenInfo) { return { content: [ { type: "text" as const, text: `No token found with address ${tokenAddress}`, }, ], }; } const formattedInfo = formatTokenInfo(tokenInfo); return createMcpResponse(formattedInfo); } catch (error: any) { console.error("Error getting token info:", error); return { content: [ { type: "text" as const, text: `Error getting token info: ${ error?.message || "Unknown error" }`, }, ], }; } } );
- src/index.ts:59-61 (schema)Zod input schema for the tool, requiring a 'tokenAddress' string parameter.{ tokenAddress: z.string().describe("The token's mint address"), },
- src/get-token-info.ts:10-35 (helper)Utility function to initialize the Solana connection and PumpFunSDK using the HELIUS_RPC_URL from environment variables.export function initializeSDK() { const rpcUrl = process.env.HELIUS_RPC_URL; if (!rpcUrl) { throw new Error("HELIUS_RPC_URL environment variable is not set"); } const connection = new Connection(rpcUrl); const provider = new AnchorProvider( connection, { publicKey: new PublicKey("11111111111111111111111111111111"), signTransaction: async () => { throw new Error("Not implemented"); }, signAllTransactions: async () => { throw new Error("Not implemented"); }, }, { commitment: "confirmed" } ); return { sdk: new PumpFunSDK(provider), connection, }; }
- src/get-token-info.ts:63-73 (helper)Helper function to format the token information into a human-readable string with token address, supply, and Pump.fun URL.export function formatTokenInfo( tokenInfo: ReturnType<typeof getTokenInfo> extends Promise<infer T> ? NonNullable<T> : never ) { return [ `Token: ${tokenInfo.tokenAddress}`, `Supply: ${tokenInfo.formattedSupply}`, `Pump.fun URL: ${tokenInfo.pumpfunUrl}`, ].join("\n"); }