Skip to main content
Glama

validate_address

Check if a Bitcoin address is valid using the Bitcoin MCP Server. Ensure address integrity for secure transactions and network interactions with this address validation tool.

Instructions

Validate a Bitcoin address

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addressYesThe Bitcoin address to validate

Implementation Reference

  • Handler function that executes the validate_address tool: parses input with schema, calls bitcoinService.validateAddress, and returns validation result as text content.
    export async function handleValidateAddress( bitcoinService: BitcoinService, args: unknown ) { const result = ValidateAddressSchema.safeParse(args); if (!result.success) { throw new McpError( ErrorCode.InvalidParams, `Invalid parameters: ${result.error.message}` ); } const isValid = bitcoinService.validateAddress(result.data.address); return { content: [ { type: "text", text: isValid ? `Address ${result.data.address} is valid` : `Address ${result.data.address} is invalid`, }, ] as TextContent[], }; }
  • Zod schema for validating the input parameters of the validate_address tool (requires 'address' string).
    export const ValidateAddressSchema = z.object({ address: z.string().min(1, "Address is required"), });
  • Tool registration in listToolsRequestHandler: defines name, description, and inputSchema for validate_address.
    name: "validate_address", description: "Validate a Bitcoin address", inputSchema: { type: "object", properties: { address: { type: "string", description: "The Bitcoin address to validate", }, }, required: ["address"], } as any, } as Tool,
  • Dispatch in callToolRequestHandler switch: routes 'validate_address' calls to handleValidateAddress.
    case "validate_address": { return handleValidateAddress(this.bitcoinService, args); }
  • Core validation logic: uses bitcoinjs-lib to check if address is valid for the current network.
    validateAddress(address: string): boolean { try { bitcoin.address.toOutputScript(address, this.network); return true; } catch { return false; } }

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

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