get-block-header
Retrieve the block header in hexadecimal format using the block hash. Integrates with the Mempool MCP Server for real-time Bitcoin blockchain data access.
Instructions
Returns the block header in hex
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| hash | Yes | The block hash to get header for |
Implementation Reference
- src/interface/controllers/BlocksToolsController.ts:104-116 (registration)Registers the MCP tool 'get-block-header' with input schema validating block hash (64-char string), description, and handler that delegates to BlocksService.getBlockHeader, formatting the result as MCP text content.private registerGetBlockHeaderHandler(): void { this.server.tool( "get-block-header", "Returns the block header in hex", { hash: z.string().length(64).describe("The block hash to get header for"), }, async ({ hash }) => { const text = await this.blocksService.getBlockHeader({ hash }); return { content: [{ type: "text", text }] }; } ); }
- Intermediate helper in BlocksService that fetches block header from request service and formats it with 'Block Header: ' prefix.async getBlockHeader({ hash }: { hash: string }): Promise<string> { const data = await this.requestService.getBlockHeader({ hash }); return `Block Header: ${data}`; }
- Core handler logic in BlocksRequestService that executes the HTTP request to retrieve the block header hex via the API endpoint `block/${hash}/header`.async getBlockHeader({ hash }: { hash: string }): Promise<string | null> { return this.client.makeRequest<string>(`block/${hash}/header`); }