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
| Name | Required | Description | Default |
|---|---|---|---|
| address | Yes | The Bitcoin address to validate |
Implementation Reference
- src/server/tools.ts:73-96 (handler)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[], }; }
- src/types.ts:118-120 (schema)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"), });
- src/server/base.ts:122-134 (registration)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,
- src/server/base.ts:203-205 (registration)Dispatch in callToolRequestHandler switch: routes 'validate_address' calls to handleValidateAddress.case "validate_address": { return handleValidateAddress(this.bitcoinService, args); }
- src/services/bitcoin.ts:114-121 (helper)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; } }