Skip to main content
Glama

account_list_access_keys

Retrieve all access keys for a specific NEAR account on either testnet or mainnet using the NEAR MCP server. Streamlines account management and permissions auditing.

Instructions

List all access keys for an given account.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
accountIdYes
networkIdNomainnet

Implementation Reference

  • Registration of the MCP tool 'account_list_access_keys'. Includes the tool name, description, input schema (accountId and networkId), and the complete handler function that fetches and returns the account's access keys.
    mcp.tool( 'account_list_access_keys', noLeadingWhitespace` List all access keys for an given account.`, { accountId: z.string(), networkId: z.enum(['testnet', 'mainnet']).default('mainnet'), }, async (args, _) => { const connection = await connect({ networkId: args.networkId, 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 accessKeys = await accountResult.value.getAccessKeys(); return { content: [{ type: 'text', text: stringify_bigint(accessKeys) }], }; }, );
  • The handler function for 'account_list_access_keys' tool. Connects to the specified NEAR network, retrieves the account using getAccount helper, fetches its access keys via account.getAccessKeys(), and returns them as stringified JSON in the MCP response format.
    async (args, _) => { const connection = await connect({ networkId: args.networkId, 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 accessKeys = await accountResult.value.getAccessKeys(); return { content: [{ type: 'text', text: stringify_bigint(accessKeys) }], }; },
  • Zod input schema for the tool: requires accountId (string), networkId optional enum with default 'mainnet'.
    accountId: z.string(), networkId: z.enum(['testnet', 'mainnet']).default('mainnet'), },
  • Helper function getAccount used by the tool handler to safely retrieve a NEAR Account object, verifying existence by checking balance.
    const getAccount = async ( accountId: string, connection: Near, ): Promise<Result<Account, Error>> => { try { const account = await connection.account(accountId); await account.getAccountBalance(); return { ok: true, value: account }; } catch (e) { return { ok: false, error: new Error( `Cannot find account by account id ${accountId}: ${e as string}`, ), }; } };

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