Skip to main content
Glama

wallet_get_public_key

Retrieve the public key from a wallet using a private key, mnemonic, or JSON input for Ethereum and EVM-compatible blockchain operations.

Instructions

Get the wallet public key

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
walletNoThe wallet (private key, mnemonic, or JSON). If not provided, uses PRIVATE_KEY environment variable if set.

Implementation Reference

  • The core handler function that implements the wallet_get_public_key tool. It retrieves the wallet instance using getWallet helper and returns the public key.
    export const getPublicKeyHandler = async (input: any): Promise<ToolResultSchema> => {
      try {
        const wallet = await getWallet(input.wallet);
    
        return createSuccessResponse(
        `Wallet public key retrieved successfully:
          Public Key: ${wallet.publicKey}
        `);
      } catch (error) {
        return createErrorResponse(`Failed to get wallet public key: ${(error as Error).message}`);
      }
    };
  • Input schema and tool metadata definition for wallet_get_public_key.
    {
      name: "wallet_get_public_key",
      description: "Get the wallet public key",
      inputSchema: {
        type: "object",
        properties: {
          wallet: { type: "string", description: "The wallet (private key, mnemonic, or JSON). If not provided, uses PRIVATE_KEY environment variable if set." }
        },
        required: []
      }
    },
  • src/tools.ts:556-608 (registration)
    Registration of tool names to their handler functions in the central handlers dictionary. Specifically maps 'wallet_get_public_key' to getPublicKeyHandler.
    export const handlers: HandlerDictionary = {
      // Provider Methods
      "wallet_provider_set": setProviderHandler,
      // Wallet Creation and Management
      "wallet_create_random": createWalletHandler,
      "wallet_from_private_key": fromPrivateKeyHandler,
      "wallet_from_mnemonic": fromMnemonicHandler,
      "wallet_from_encrypted_json": fromEncryptedJsonHandler,
      "wallet_encrypt": encryptWalletHandler,
    
      // Wallet Properties
      "wallet_get_address": getAddressHandler,
      "wallet_get_public_key": getPublicKeyHandler,
      "wallet_get_private_key": getPrivateKeyHandler,
    
      // Blockchain Methods
      "wallet_get_balance": getBalanceHandler,
      "wallet_get_chain_id": getChainIdHandler,
      "wallet_get_gas_price": getGasPriceHandler,
      "wallet_get_transaction_count": getTransactionCountHandler,
      "wallet_call": callHandler,
    
      // Transaction Methods
      "wallet_send_transaction": sendTransactionHandler,
      "wallet_sign_transaction": signTransactionHandler,
      "wallet_populate_transaction": populateTransactionHandler,
    
      // Signing Methods
      "wallet_sign_message": signMessageHandler,
      "wallet_sign_typed_data": signTypedDataHandler,
      "wallet_verify_message": verifyMessageHandler,
      "wallet_verify_typed_data": verifyTypedDataHandler,
    
      // Provider Methods
      "provider_get_block": getBlockHandler,
      "provider_get_transaction": getTransactionHandler,
      "provider_get_transaction_receipt": getTransactionReceiptHandler,
      "provider_get_code": getCodeHandler,
      "provider_get_storage_at": getStorageAtHandler,
      "provider_estimate_gas": estimateGasHandler,
      "provider_get_logs": getLogsHandler,
      "provider_get_ens_resolver": getEnsResolverHandler,
      "provider_lookup_address": lookupAddressHandler,
      "provider_resolve_name": resolveNameHandler,
    
      // Network Methods
      "network_get_network": getNetworkHandler,
      "network_get_block_number": getBlockNumberHandler,
      "network_get_fee_data": getFeeDataHandler,
    
      // Mnemonic Methods
      "wallet_create_mnemonic_phrase": createMnemonicPhraseHandler
    };
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states what the tool does but omits critical details: whether this operation is read-only or has side effects, if it requires authentication, potential rate limits, or what format the public key is returned in (e.g., hex, base64). For a cryptographic tool with security implications, this lack of transparency is a significant gap.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise at just four words, front-loading the core purpose without any fluff. Every word earns its place: 'Get' specifies the action, 'wallet' identifies the resource type, and 'public key' pinpoints the exact data retrieved. This efficiency makes it easy for an agent to parse quickly, though it sacrifices detail for brevity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of cryptographic operations and the lack of annotations or output schema, the description is insufficiently complete. It doesn't explain what a public key is used for, how it relates to other wallet tools, or what the return value looks like (e.g., a string in hex format). For a tool in a security-sensitive domain with many siblings, more context is needed to ensure safe and correct usage.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, with the single parameter 'wallet' fully documented in the schema itself. The description adds no additional parameter semantics beyond what's already in the schema (e.g., no examples of wallet formats or edge cases). Since the schema does the heavy lifting, the baseline score of 3 is appropriate, though the description could have clarified the relationship between the wallet input and the resulting public key.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Get') and the resource ('wallet public key'), making the purpose immediately understandable. It distinguishes itself from sibling tools like wallet_get_address or wallet_get_private_key by specifying the exact cryptographic key being retrieved. However, it doesn't explicitly mention that this is for cryptographic operations or blockchain interactions, which could further differentiate it from generic key retrieval tools.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention use cases like verifying wallet ownership, encryption, or signing operations, nor does it differentiate from siblings like wallet_get_address (which returns a different identifier) or wallet_get_private_key (which retrieves the sensitive counterpart). Without this context, an agent might struggle to choose between related wallet tools.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

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/dcSpark/mcp-cryptowallet-evm'

If you have feedback or need assistance with the MCP directory API, please join our Discord server