Skip to main content
Glama

account_delete_account

Delete a NEAR account and transfer its remaining balance to a beneficiary. The account and its keypair are removed 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

  • Registration of the 'account_delete_account' tool using mcp.tool() with schema definition and handler callback.
      '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}`,
            },
          ],
        };
      },
    );
  • Handler function for account_delete_account: validates both account and beneficiary exist, signs with local keystore, calls deleteAccount from @near-js/client, and returns the result.
    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}`,
          },
        ],
      };
    },
  • Input schema for account_delete_account: accountId (string), beneficiaryAccountId (string), networkId (enum testnet/mainnet with default mainnet).
    {
      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'),
    },
Behavior4/5

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

With no annotations, the description covers the main behaviors: deleting from blockchain and from local keystore. It does not detail irreversibility or balance handling, but the beneficiary parameter addresses that.

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?

Two sentences, no redundancy. Directly states the action and additional effects.

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

Completeness4/5

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

For a delete operation with 3 parameters and no output schema, the description covers the key action and local side effect. Could mention success confirmation but overall sufficient.

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 coverage is 67%, and the description adds no extra parameter meaning beyond the schema's descriptions. It does not compensate for the missing networkId description.

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 tool's function: 'Delete an account from the NEAR blockchain.' It also specifies additional effects like removing from local keystore and keypair. This distinguishes it from sibling tools like account_create_account or account_add_access_key.

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 (e.g., system_remove_local_account for local-only removal). No prerequisites or contraindications are mentioned.

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

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