Skip to main content
Glama

account_view_account_summary

Retrieve account summary information on the NEAR blockchain by specifying the account ID and network. This tool queries public RPC endpoints to provide detailed account insights.

Instructions

Get summary information about any NEAR account. This calls a public RPC endpoint to get this information.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
accountIdYes
networkIdNomainnet

Implementation Reference

  • The handler function that implements the core logic of the 'account_view_account_summary' tool. It connects to the NEAR network, retrieves the account details (balance, state, access keys), formats the information, and returns it as a stringified JSON.
    async (args, _) => { console.log('args', 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 account = accountResult.value; const balance = await account.getAccountBalance(); const state = await account.state(); const accessKeys = await account.getAccessKeys(); const accountInfo = { balance: { totalBalance: NearToken.parse_yocto_near(balance.total).as_near(), availableBalance: NearToken.parse_yocto_near( balance.available, ).as_near(), stakedBalance: NearToken.parse_yocto_near(balance.staked).as_near(), }, state: { blockHeight: state.block_height, codeHash: state.code_hash, storageUsage: state.storage_usage, }, accessKeys: accessKeys, }; return { content: [{ type: 'text', text: stringify_bigint(accountInfo) }], }; }, );
  • The input schema using Zod for validating parameters: accountId (required string) and networkId (optional enum defaulting to 'mainnet').
    accountId: z.string(), networkId: z.enum(['testnet', 'mainnet']).default('mainnet'), },
  • The MCP tool registration call that defines the tool name, description, input schema, and handler function.
    'account_view_account_summary', noLeadingWhitespace` Get summary information about any NEAR account. This calls a public RPC endpoint to get this information.`, { accountId: z.string(), networkId: z.enum(['testnet', 'mainnet']).default('mainnet'), }, async (args, _) => { console.log('args', 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 account = accountResult.value; const balance = await account.getAccountBalance(); const state = await account.state(); const accessKeys = await account.getAccessKeys(); const accountInfo = { balance: { totalBalance: NearToken.parse_yocto_near(balance.total).as_near(), availableBalance: NearToken.parse_yocto_near( balance.available, ).as_near(), stakedBalance: NearToken.parse_yocto_near(balance.staked).as_near(), }, state: { blockHeight: state.block_height, codeHash: state.code_hash, storageUsage: state.storage_usage, }, accessKeys: accessKeys, }; return { content: [{ type: 'text', text: stringify_bigint(accountInfo) }], }; }, );
  • Helper function used by the handler to safely retrieve a NEAR Account object, confirming existence by fetching 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