system_list_local_keypairs
Retrieve and display NEAR accounts and their associated keypairs stored locally for a specified network (testnet or mainnet).
Instructions
List all NEAR accounts and their keypairs in the local keystore by network.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| networkId | No | mainnet |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"networkId": {
"default": "mainnet",
"enum": [
"testnet",
"mainnet"
],
"type": "string"
}
},
"type": "object"
}
Implementation Reference
- src/services.ts:467-483 (handler)The handler function that executes the tool logic: fetches accounts from the local keystore and retrieves their public keys for the given network.async (args, _) => { const keyPairs = await keystore.getAccounts(args.networkId); const result = { networkId: args.networkId, keypairs: await Promise.all( keyPairs.map(async (accountId) => ({ accountId, publicKey: (await keystore.getKey(args.networkId, accountId)) .getPublicKey() .toString(), })), ), }; return { content: [{ type: 'text', text: stringify_bigint(result) }], }; },
- src/services.ts:464-466 (schema)Zod input schema defining the networkId parameter (testnet or mainnet, defaults to mainnet).{ networkId: z.enum(['testnet', 'mainnet']).default('mainnet'), },
- src/services.ts:461-484 (registration)Registration of the tool using mcp.tool(), including name, description, schema, and inline handler.mcp.tool( 'system_list_local_keypairs', 'List all NEAR accounts and their keypairs in the local keystore by network.', { networkId: z.enum(['testnet', 'mainnet']).default('mainnet'), }, async (args, _) => { const keyPairs = await keystore.getAccounts(args.networkId); const result = { networkId: args.networkId, keypairs: await Promise.all( keyPairs.map(async (accountId) => ({ accountId, publicKey: (await keystore.getKey(args.networkId, accountId)) .getPublicKey() .toString(), })), ), }; return { content: [{ type: 'text', text: stringify_bigint(result) }], }; }, );