@stakpak/mcp
Version:
An MCP server that connects to Stakpak
26 lines (25 loc) • 784 B
JavaScript
const API_BASE_URL = "https://apiv2.stakpak.dev";
export const request = async (endpoint, apiKey, version = "v1", options = {}) => {
const url = `${API_BASE_URL}/${version}/${endpoint}`;
const headers = {
Authorization: `Bearer ${apiKey}`,
"Content-Type": "application/json",
...options.headers
};
try {
const response = await fetch(url, {
...options,
headers
});
const data = await response.json();
if (!response.ok) {
throw new Error(data.message || `Request failed with status ${response.status}`);
}
return data;
}
catch (error) {
throw error instanceof Error
? error
: new Error("Network error occurred");
}
};