businessmap-mcp
Version:
MCP server for Businessmap Kanbanize, exposing tools for managing business entities like boards, cards, and columns, facilitating LLM interaction.
47 lines (46 loc) • 1.55 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const BUSINESSMAP_API_URL = process.env.BUSINESSMAP_API_URL ?? "";
const BUSINESSMAP_API_KEY = process.env.BUSINESSMAP_API_KEY ?? "";
class Request {
baseUrl;
constructor(baseUrl = BUSINESSMAP_API_URL) {
this.baseUrl = baseUrl;
}
async request(method, path, data, headers) {
const url = `${this.baseUrl}${path}`;
const config = {
method,
headers: {
"Content-Type": "application/json",
APIKEY: BUSINESSMAP_API_KEY,
...headers,
},
};
if (data) {
config.body = JSON.stringify(data);
}
const response = await fetch(url, config);
if (!response.ok) {
const errorData = await response.json().catch(() => ({}));
throw new Error(`HTTP error! Status: ${response.status}, Message: ${errorData.message || response.statusText}`);
}
return response.json();
}
get(path, headers) {
return this.request("GET", path, undefined, headers);
}
post(path, data, headers) {
return this.request("POST", path, data, headers);
}
patch(path, data, headers) {
return this.request("PATCH", path, data, headers);
}
put(path, headers) {
return this.request("PUT", path, undefined, headers);
}
delete(path, headers) {
return this.request("DELETE", path, undefined, headers);
}
}
exports.default = Request;