UNPKG

mcp-server-ddd-sample

Version:

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

23 lines (22 loc) 694 B
export class MempoolApiClientService { BASE_API = "https://mempool.space/api"; API_VERSION = "v1"; constructor() { } async makeRequest(endpoint) { const url = `${this.BASE_API}/${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; } } }