Skip to main content
Glama

Aptos Blockchain MCP

createAccount.ts2.02 kB
import { Tool } from "@modelcontextprotocol/sdk/types.js"; import { createNewAccount, getAccountAddress, getAccountPrivateKey, getAccountPublicKey } from "../../utils/account.js"; export const CREATE_ACCOUNT: Tool = { name: "create_account", description: "Create a new Aptos account with a random private key. This generates a new account that can be used for transactions on the Aptos blockchain. Returns the account address, private key, and public key.", inputSchema: { type: "object", properties: {}, required: [], }, }; /** * Creates a new Aptos account * @param args The arguments (none required) * @returns The new account details */ export async function createAccountHandler(args: Record<string, any> | undefined) { try { const results = await performCreateAccount(); return { content: [{ type: "text", text: results }], isError: false, }; } catch (error) { return { content: [ { type: "text", text: `Error creating account: ${error instanceof Error ? error.message : String(error)}`, }, ], isError: true, }; } } /** * Creates a new Aptos account * @returns The new account details as a formatted string */ export async function performCreateAccount(): Promise<string> { try { const account = createNewAccount(); const address = getAccountAddress(account); const privateKey = getAccountPrivateKey(account); const publicKey = getAccountPublicKey(account); return `New Aptos Account Created: Address: ${address} Private Key: ${privateKey} Public Key: ${publicKey} ⚠️ IMPORTANT: Save your private key securely! It cannot be recovered if lost. ⚠️ Never share your private key with anyone. ⚠️ This account needs to be funded before it can be used for transactions.`; } catch (error) { console.error('Error creating account:', error); throw new Error(`Failed to create account: ${error instanceof Error ? error.message : String(error)}`); } }

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/punkpeye/aptos-mcp'

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