UNPKG

@sanlim/mempool-mcp-server

Version:

A sample of MCP implementation using DDD structure with some APIs call.

25 lines (24 loc) 705 B
export class MempoolApiClientService { baseUrl; API_VERSION = "v1"; constructor(baseUrl) { this.baseUrl = baseUrl; } async makeRequest(endpoint) { const url = `${this.baseUrl}/${this.API_VERSION}/${endpoint}`; const headers = { Accept: "application/json", }; try { const response = await fetch(url, { headers }); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } return (await response.json()); } catch (error) { process.stderr.write("Error making Mempool request"); return null; } } }