UNPKG

scrapeless-mcp-server

Version:
28 lines (27 loc) 865 B
import axios from "axios"; export class ScrapelessClient { api; constructor(config) { this.api = axios.create({ baseURL: config.baseURL, headers: { "Content-Type": "application/json", "x-api-token": config.token, }, }); } async sendRequest(endpoint, actor, inputData) { try { const response = await this.api.post(endpoint, { actor, input: inputData }); return { content: [{ type: "text", text: `Response:\n\n${JSON.stringify(response.data, null, 2)}` }], }; } catch (error) { console.error("Scrapeless API Error:", error); return { content: [{ type: "text", text: `Failed to fetch data. Error: ${error.message}` }], }; } } }