Skip to main content
Glama

get_address_from_private_key

Retrieve the EVM address from a private key using this tool on the bnbchain-mcp server. Input a private key in hex format for secure address derivation.

Instructions

Get the EVM address derived from a private key

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
privateKeyNoPrivate key in hex format (with or without 0x prefix). SECURITY: This is used only for address derivation and is not stored.0x5a2b7e4d9c8f1a3e6b0d2c5f4e3d2a1b0c9f8e7d6a5b4c3d2e1f0a9b8c7d6e5f4

Implementation Reference

  • Handler function that formats the input private key (ensuring 0x prefix) and delegates to the service to derive the EVM address.
    async ({ privateKey }) => {
      try {
        // Ensure the private key has 0x prefix
        const formattedKey = privateKey.startsWith("0x")
          ? (privateKey as Hex)
          : (`0x${privateKey}` as Hex)
    
        const address = services.getAddressFromPrivateKey(formattedKey)
    
        return mcpToolRes.success({
          address
        })
      } catch (error) {
        return mcpToolRes.error(error, "deriving address from private key")
      }
    }
  • Registers the 'get_address_from_private_key' tool on the MCP server with description, input schema, and handler.
      "get_address_from_private_key",
      "Get the EVM address derived from a private key",
      {
        privateKey: privateKeyParam
      },
      async ({ privateKey }) => {
        try {
          // Ensure the private key has 0x prefix
          const formattedKey = privateKey.startsWith("0x")
            ? (privateKey as Hex)
            : (`0x${privateKey}` as Hex)
    
          const address = services.getAddressFromPrivateKey(formattedKey)
    
          return mcpToolRes.success({
            address
          })
        } catch (error) {
          return mcpToolRes.error(error, "deriving address from private key")
        }
      }
    )
  • Zod schema definition for the privateKey input parameter used in the tool schema.
    export const privateKeyParam = z
      .string()
      .describe(
        "Private key in hex format (with or without 0x prefix). SECURITY: This is used only for address derivation and is not stored. The private key will not be logged or displayed in chat history."
      )
      .default(process.env.PRIVATE_KEY as string)
  • Core utility function that derives an EVM address from a private key using viem's privateKeyToAccount.
    export function getAddressFromPrivateKey(privateKey: Hex): Address {
      const account = privateKeyToAccount(privateKey)
      return account.address
    }
Behavior3/5

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

With no annotations provided, the description carries the full burden. It states the tool derives an address and implies it's a read-only operation, but doesn't disclose behavioral traits like security handling (e.g., whether the private key is transmitted securely), error conditions, or performance aspects. The description adds basic context but lacks depth for a security-sensitive tool.

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 a single, efficient sentence that directly states the tool's purpose without unnecessary words. It's front-loaded and wastes no space, making it easy to parse quickly.

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

Completeness3/5

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

Given the tool's moderate complexity (involves cryptographic derivation) and no output schema, the description is minimally adequate. It covers the basic purpose but lacks details on output format (e.g., address format), error handling, or security implications, which are important for a tool handling private keys. With no annotations, it should provide more context.

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?

Schema description coverage is 100%, with the parameter 'privateKey' well-documented in the schema (including format and security note). The description doesn't add any meaningful semantics beyond what the schema provides, such as examples or edge cases, so it meets the baseline for high schema coverage.

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 verb ('Get') and resource ('EVM address derived from a private key'), making the purpose specific and understandable. It doesn't explicitly differentiate from siblings like 'resolve_ens' or 'get_chain_info', but the focus on private key derivation is distinct enough for most contexts.

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?

No guidance is provided on when to use this tool versus alternatives. For example, it doesn't mention if this is for address derivation only (vs. resolving ENS names or checking balances), or any prerequisites like needing a valid private key format. The description lacks context for tool selection.

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/bnb-chain/bnbchain-mcp'

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