Skip to main content
Glama

account_delete_access_keys

Remove an access key from a NEAR blockchain account by specifying the account ID and public key, ensuring secure key management and access control.

Instructions

Delete an access key from an account based on it's public key.

Input Schema

NameRequiredDescriptionDefault
accountIdYes
networkIdNomainnet
publicKeyYes

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": { "accountId": { "type": "string" }, "networkId": { "default": "mainnet", "enum": [ "testnet", "mainnet" ], "type": "string" }, "publicKey": { "type": "string" } }, "required": [ "accountId", "publicKey" ], "type": "object" }

Implementation Reference

  • The handler function that executes the deletion of a specific access key from a NEAR account. It connects to the network, fetches the account, verifies the access key exists, and calls account.deleteKey(public_key).
    async (args, _) => { const connection = await connect({ networkId: args.networkId, keyStore: keystore, nodeUrl: getEndpointsByNetwork(args.networkId)[0]!, }); const accountResult: Result<Account, Error> = await getAccount( args.accountId, connection, ); if (!accountResult.ok) { return { content: [{ type: 'text', text: `Error: ${accountResult.error}` }], }; } const account = accountResult.value; const accessKeys = await account.getAccessKeys(); const accessKey = accessKeys.find( (key) => key.public_key === args.publicKey, ); if (!accessKey) { return { content: [{ type: 'text', text: 'Access key not found in account' }], }; } const deleteAccessKeyResult: Result<FinalExecutionOutcome, Error> = await (async () => { try { return { ok: true, value: await account.deleteKey(accessKey.public_key), }; } catch (e) { return { ok: false, error: new Error(e as string) }; } })(); if (!deleteAccessKeyResult.ok) { return { content: [ { type: 'text', text: `Error: ${deleteAccessKeyResult.error}\n\nFailed to delete access key ${args.publicKey} from account ${args.accountId}`, }, ], }; } return { content: [ { type: 'text', text: `Access key deleted: ${args.publicKey}`, }, ], }; }, );
  • Input schema validation using Zod for the tool parameters: accountId, networkId (default 'mainnet'), and publicKey.
    accountId: z.string(), networkId: z.enum(['testnet', 'mainnet']).default('mainnet'), publicKey: z.string(), },
  • Registration of the 'account_delete_access_keys' tool in the MCP server using mcp.tool().
    mcp.tool( 'account_delete_access_keys', noLeadingWhitespace` Delete an access key from an account based on it's public key.`, {

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