Skip to main content
Glama
AbdelStark
by AbdelStark

generate_key

Create a new Bitcoin key pair and address for secure cryptocurrency transactions and wallet setup.

Instructions

Generate a new Bitcoin key pair and address

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function for the 'generate_key' tool. It calls BitcoinService.generateKey() and formats the response as MCP TextContent.
    export async function handleGenerateKey(bitcoinService: BitcoinService) {
      const key = await bitcoinService.generateKey();
      return {
        content: [
          {
            type: "text",
            text: `Generated new Bitcoin key pair:\nAddress: ${key.address}\nPrivate Key (WIF): ${key.privateKey}\nPublic Key: ${key.publicKey}`,
          },
        ] as TextContent[],
      };
    }
  • Registration of the 'generate_key' tool in the ListToolsRequestSchema handler, including name, description, and empty input schema.
    {
      name: "generate_key",
      description: "Generate a new Bitcoin key pair and address",
      inputSchema: { type: "object", properties: {}, required: [] },
    } as Tool,
  • Dispatch logic in the CallToolRequestSchema handler that routes 'generate_key' calls to handleGenerateKey.
    case "generate_key": {
      return handleGenerateKey(this.bitcoinService);
    }
  • Core implementation of key generation using bitcoinjs-lib, producing address, WIF private key, and hex public key.
    async generateKey(): Promise<GeneratedKey> {
      try {
        const keyPair = ECPair.makeRandom({ rng });
        const { address } = bitcoin.payments.p2pkh({
          pubkey: keyPair.publicKey,
          network: this.network,
        });
    
        if (!address) {
          throw new Error("Failed to generate address");
        }
    
        return {
          address,
          privateKey: keyPair.toWIF(),
          publicKey: keyPair.publicKey.toString("hex"),
        };
      } catch (error) {
        logger.error({ error }, "Failed to generate key");
        throw new BitcoinError(
          "Failed to generate key pair",
          BitcoinErrorCode.KEY_GENERATION_ERROR
        );
      }
    }
Behavior2/5

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

With no annotations provided, the description carries full burden but only states what the tool does without behavioral details. It doesn't disclose if this requires network connectivity, has rate limits, stores keys securely, or what format the output takes (e.g., public/private keys, address type). This leaves significant gaps for agent understanding.

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 function without unnecessary words. It is front-loaded with the core action and resource, making it highly concise and well-structured.

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 generating cryptographic keys and the lack of annotations and output schema, the description is incomplete. It doesn't explain return values (e.g., key formats), security implications, or error conditions, leaving the agent with insufficient context for safe and effective use.

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

Parameters4/5

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

The input schema has 0 parameters with 100% coverage, so no parameter documentation is needed. The description appropriately avoids discussing parameters, focusing on the tool's purpose. A baseline of 4 is applied as it compensates adequately for the lack of parameters.

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 ('Generate') and the resource ('a new Bitcoin key pair and address'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'validate_address' or 'pay_invoice', which prevents a perfect score.

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 like 'validate_address' for checking existing addresses or 'pay_invoice' for transactions. It lacks context about prerequisites, such as needing Bitcoin network access or when key generation is appropriate.

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

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/AbdelStark/bitcoin-mcp'

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