Skip to main content
Glama

validate_address

Verify Bitcoin address validity to prevent errors in transactions and ensure proper format before use.

Instructions

Validate a Bitcoin address

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addressYesThe Bitcoin address to validate

Implementation Reference

  • The main handler function for the 'validate_address' tool. It parses input arguments using ValidateAddressSchema, calls bitcoinService.validateAddress, and returns a text response indicating validity.
    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 defining the input for the validate_address tool: an object with a required 'address' string.
    export const ValidateAddressSchema = z.object({ address: z.string().min(1, "Address is required"), });
  • Tool registration in the MCP server's listTools response, specifying name 'validate_address', description, and input schema.
    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 logic in the callTool request handler that routes 'validate_address' calls to handleValidateAddress.
    case "validate_address": { return handleValidateAddress(this.bitcoinService, args); }
  • Core helper method in BitcoinService that performs the actual address validation using bitcoinjs-lib's toOutputScript.
    validateAddress(address: string): boolean { try { bitcoin.address.toOutputScript(address, this.network); return true; } catch { return false; } }

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