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
| Name | Required | Description | Default |
|---|---|---|---|
| accountId | Yes | ||
| networkId | No | mainnet | |
| publicKey | Yes |
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
- src/services.ts:1561-1617 (handler)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}`, }, ], }; }, );
- src/services.ts:1557-1560 (schema)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(), },
- src/services.ts:1552-1556 (registration)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.`, {