Skip to main content
Glama

create-token

Create new meme tokens on the Pump.fun platform by specifying name, symbol, description, and initial SOL buy amount. This tool enables AI assistants to launch tokens on Solana with optional image URLs and account management.

Instructions

Create a new Pump.fun token

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesToken name
symbolYesToken symbol
descriptionYesToken description
imageUrlNoURL to token image (optional)
initialBuyAmountYesInitial buy amount in SOL
accountNameNoName of the account to use (will be created if it doesn't exist)default

Implementation Reference

  • The core handler function that implements the create-token tool logic. It initializes the SDK, manages the account keypair, checks SOL balance, generates a mint keypair, optionally loads an image, calls PumpFunSDK.createAndBuy, saves the mint key, fetches token balance, and returns success details or error.
    export async function createToken( name: string, symbol: string, description: string, imageUrl: string | undefined, initialBuyAmount: number, accountName: string = "default" ) { try { const { sdk, connection } = initializeSDK(); const keysFolder = path.resolve(rootDir, ".keys"); const account = getOrCreateKeypair(keysFolder, accountName); const balance = await connection.getBalance(account.publicKey); const requiredBalance = initialBuyAmount * LAMPORTS_PER_SOL + 0.003 * LAMPORTS_PER_SOL; if (balance < requiredBalance) { return { success: false, error: `Insufficient SOL balance. Account ${account.publicKey.toString()} has ${ balance / LAMPORTS_PER_SOL } SOL, but needs at least ${ requiredBalance / LAMPORTS_PER_SOL } SOL. Please send SOL to this address and try again.`, }; } const mint = Keypair.generate(); let fileBlob: Blob | undefined; if (imageUrl) { const imageData = fs.readFileSync(imageUrl); fileBlob = new Blob([imageData], { type: "image/png" }); } const tokenMetadata: any = { name, symbol, description, file: fileBlob, }; const result = await sdk.createAndBuy( account, mint, tokenMetadata, BigInt(initialBuyAmount * LAMPORTS_PER_SOL), DEFAULT_SLIPPAGE_BASIS_POINTS, DEFAULT_PRIORITY_FEES ); if (!result.success) { return { success: false, error: result.error || "Unknown error", }; } fs.writeFileSync( path.join(keysFolder, `mint-${mint.publicKey.toString()}.json`), safeStringify(Array.from(mint.secretKey)) ); const tokenBalance = await getSPLBalance( connection, mint.publicKey, account.publicKey ); return { success: true, tokenAddress: mint.publicKey.toString(), tokenName: name, tokenSymbol: symbol, tokenBalance, signature: result.signature, pumpfunUrl: `https://pump.fun/${mint.publicKey.toString()}`, }; } catch (error: any) { console.error("Error creating token:", error); return { success: false, error: error?.message || "Unknown error" }; } }
  • src/index.ts:98-150 (registration)
    The MCP tool registration for 'create-token', including the tool name, description, input schema using Zod, and the thin wrapper handler that calls the core createToken function and formats the response.
    server.tool( "create-token", "Create a new Pump.fun token", { name: z.string().describe("Token name"), symbol: z.string().describe("Token symbol"), description: z.string().describe("Token description"), imageUrl: z.string().optional().describe("URL to token image (optional)"), initialBuyAmount: z .number() .min(0.0001) .describe("Initial buy amount in SOL"), accountName: z .string() .default("default") .describe( "Name of the account to use (will be created if it doesn't exist)" ), }, async ({ name, symbol, description, imageUrl, initialBuyAmount, accountName, }) => { try { const result = await createToken( name, symbol, description, imageUrl, initialBuyAmount, accountName ); const formattedResult = formatCreateTokenResult(result); return createMcpResponse(formattedResult); } catch (error: any) { console.error("Error creating token:", error); return { content: [ { type: "text", text: `Error creating token: ${error?.message || "Unknown error"}`, }, ], }; } } );
  • The Zod input schema defining parameters for the create-token tool: name, symbol, description, optional imageUrl, initialBuyAmount (min 0.0001), and accountName (default 'default').
    name: z.string().describe("Token name"), symbol: z.string().describe("Token symbol"), description: z.string().describe("Token description"), imageUrl: z.string().optional().describe("URL to token image (optional)"), initialBuyAmount: z .number() .min(0.0001) .describe("Initial buy amount in SOL"), accountName: z .string() .default("default") .describe( "Name of the account to use (will be created if it doesn't exist)" ), }, async ({ name, symbol,
  • Helper function to format the result of createToken into a human-readable string for the MCP response.
    export function formatCreateTokenResult( result: ReturnType<typeof createToken> extends Promise<infer T> ? T : never ) { if (!result.success) { return `Error creating token: ${result.error}`; } return [ `Successfully created token!`, `Token Address: ${result.tokenAddress}`, `Token Name: ${result.tokenName}`, `Token Symbol: ${result.tokenSymbol}`, `Your Balance: ${result.tokenBalance}`, `Transaction Signature: ${result.signature}`, `Pump.fun URL: ${result.pumpfunUrl}`, ].join("\n"); }

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