Skip to main content
Glama

account_delete_account

Remove an account from the NEAR blockchain, transfer its remaining balance to a specified beneficiary, and delete associated keypair data from the local keystore.

Instructions

Delete an account from the NEAR blockchain. This will also remove the account from the local keystore and any associated keypair.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
accountIdYesThe account to delete.
beneficiaryAccountIdYesThe account that will receive the remaining balance of the deleted account.
networkIdNomainnet

Implementation Reference

  • Full implementation of the 'account_delete_account' MCP tool, including registration, input schema (using Zod), and the handler function that validates accounts, retrieves signer from keystore, and calls deleteAccount from @near-js/client to delete the account and transfer balance to beneficiary.
      'account_delete_account',
      noLeadingWhitespace`
      Delete an account from the NEAR blockchain. This will also remove the account from the local keystore and any associated keypair.`,
      {
        accountId: z.string().describe('The account to delete.'),
        beneficiaryAccountId: z
          .string()
          .describe(
            'The account that will receive the remaining balance of the deleted account.',
          ),
        networkId: z.enum(['testnet', 'mainnet']).default('mainnet'),
      },
      async (args, _) => {
        const rpcProvider = getProviderByNetwork(args.networkId);
        const connection = await connect({
          networkId: args.networkId,
          nodeUrl: getEndpointsByNetwork(args.networkId)[0]!,
        });
    
        // ensure both account and beneficiary account exist
        const accountIdResult: Result<Account, Error> = await getAccount(
          args.accountId,
          connection,
        );
        if (!accountIdResult.ok) {
          return {
            content: [{ type: 'text', text: `Error: ${accountIdResult.error}` }],
          };
        }
        const beneficiaryAccountIdResult: Result<Account, Error> =
          await getAccount(args.beneficiaryAccountId, connection);
        if (!beneficiaryAccountIdResult.ok) {
          return {
            content: [
              {
                type: 'text',
                text: `Error: ${beneficiaryAccountIdResult.error}`,
              },
            ],
          };
        }
    
        const signer: Result<MessageSigner, Error> = await getAccountSigner(
          args.accountId,
          args.networkId,
          keystore,
        );
        if (!signer.ok) {
          return {
            content: [
              {
                type: 'text',
                text: `Error: ${signer.error}\n\nCannot find the account ${args.accountId} in the keystore.`,
              },
            ],
          };
        }
    
        const deleteAccountResult: Result<
          {
            outcome: FinalExecutionOutcome;
            result: SerializedReturnValue;
          },
          Error
        > = await (async () => {
          try {
            return {
              ok: true,
              value: await deleteAccount({
                account: args.accountId,
                beneficiaryId: args.beneficiaryAccountId,
                deps: { rpcProvider, signer: signer.value },
              }),
            };
          } catch (e) {
            return { ok: false, error: new Error(e as string) };
          }
        })();
        if (!deleteAccountResult.ok) {
          return {
            content: [
              {
                type: 'text',
                text: `Error: ${deleteAccountResult.error}\n\nFailed to delete account ${args.accountId}`,
              },
            ],
          };
        }
    
        return {
          content: [
            {
              type: 'text',
              text: `Account deletion result: ${stringify_bigint(
                deleteAccountResult.value,
              )}`,
            },
            {
              type: 'text',
              text: `Account deleted: ${args.accountId}`,
            },
          ],
        };
      },
    );
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but only states the action without disclosing critical behavioral traits: it doesn't mention if deletion is irreversible, requires specific permissions, has rate limits, or what happens to associated data beyond the keystore. For a destructive operation, this is a significant gap in transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero waste—it front-loads the core action and includes essential side effects (keystore/keypair removal) without unnecessary elaboration. Every word earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the high complexity of a blockchain account deletion with no annotations and no output schema, the description is incomplete: it misses critical details like irreversibility, permissions, error conditions, or response format. For a destructive tool with 3 parameters, this leaves too many unknowns for safe agent use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 67% (2 of 3 parameters described), and the description adds no parameter-specific information beyond what the schema provides (e.g., it doesn't explain format constraints for account IDs or network implications). With moderate schema coverage, the baseline 3 is appropriate as the description doesn't compensate for gaps.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Delete an account from the NEAR blockchain') and distinguishes it from siblings like 'account_create_account' or 'system_remove_local_account' by specifying blockchain deletion with keystore/keypair removal. It uses precise verbs and identifies the resource explicitly.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'system_remove_local_account' (which might handle local removal only) or prerequisites such as account state or balance requirements. It lacks explicit when/when-not instructions or named alternatives.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

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/nearai/near-mcp'

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