mcp-server-ddd-sample
Version:
A sample of MCP implementation using DDD structure with some APIs call.
32 lines (31 loc) • 985 B
JavaScript
export class MempoolApiService {
API_BASE = "https://mempool.space/api";
API_VERSION = "v1";
// Helper function for making NWS API requests
async makeRequest(endpoint) {
const url = `${this.API_BASE}/${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) {
console.error("Error making Mempool request:", error);
return null;
}
}
async getPrices() {
return this.makeRequest("prices");
}
async getDifficultyAdjustment() {
return this.makeRequest("difficulty-adjustment");
}
async getFeesRecommended() {
return this.makeRequest("fees/recommended");
}
}