Skip to main content
Glama

create_account

Generate a new Aptos blockchain account with random private key for transaction capabilities. Returns account address, private key, and public key.

Instructions

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.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The tool schema defining the 'create_account' tool name, description, and input schema (no parameters required).
    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: [],
      },
    };
  • The primary handler function that executes the create_account tool logic, calling the helper and handling errors.
    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,
        };
      }
    }
  • Helper function that creates a new Aptos account using utility functions and returns formatted account details.
    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)}`);
      }
    }
  • src/index.ts:37-57 (registration)
    Registration of the CREATE_ACCOUNT tool schema in the tools list returned by the MCP server's listTools handler (stdio server).
    const TOOLS_LIST = [
      // Account tools
      CREATE_ACCOUNT,
      GET_ACCOUNT_INFO,
      FUND_ACCOUNT,
    
      // Native APT tools
      GET_APT_BALANCE,
      TRANSFER_APT,
    
      // Coin tools
      GET_COIN_BALANCE,
      TRANSFER_COIN,
      DEPLOY_COIN,
      MINT_COIN,
      REGISTER_COIN,
    
      // Transaction tools
      GET_TRANSACTION_STATUS,
      GET_ACCOUNT_TRANSACTIONS,
    ];
  • src/index.ts:112-113 (registration)
    Handler dispatch registration for 'create_account' tool in the main switch statement of the MCP server's callTool handler.
    case "create_account":
      return await createAccountHandler(args);

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

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