create-token
Create new meme tokens on the Solana blockchain using Pump.fun platform. Specify token name, symbol, description, and initial buy amount to launch your cryptocurrency.
Instructions
Create a new Pump.fun token
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| accountName | No | Name of the account to use (will be created if it doesn't exist) | default |
| description | Yes | Token description | |
| imageUrl | No | URL to token image (optional) | |
| initialBuyAmount | Yes | Initial buy amount in SOL | |
| name | Yes | Token name | |
| symbol | Yes | Token symbol |
Implementation Reference
- src/index.ts:98-150 (registration)Registers the 'create-token' tool with the MCP server, defining its name, description, input schema using Zod, and a handler function that delegates to the core createToken function and handles errors.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"}`, }, ], }; } } );
- src/create-token.ts:22-105 (handler)Core handler function that performs the token creation: initializes SDK, manages account keypair, checks SOL balance, generates mint keypair, handles optional image metadata, executes sdk.createAndBuy, saves mint key, fetches token balance, and returns detailed result.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:101-116 (schema)Zod schema defining the input parameters for the 'create-token' tool.{ 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)" ), },
- src/create-token.ts:107-123 (helper)Helper function to format the result of createToken into a readable multi-line 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"); }