Expand MCP server with modular routers

This commit is contained in:
josedario87
2025-06-03 17:02:37 -06:00
parent 3cb001edac
commit 907ac9da0e
7 changed files with 391 additions and 139 deletions

15
mcp/lib/api.js Normal file
View File

@@ -0,0 +1,15 @@
export const API_BASE_URL = process.env.PLANILLA_API_URL || "http://localhost:4000";
export async function fetchJSON(path, options = {}) {
const method = options.method || "GET";
console.log(`[API] ${method} ${API_BASE_URL}${path}`);
const res = await fetch(`${API_BASE_URL}${path}`, {
headers: { "Content-Type": "application/json" },
...options,
});
if (!res.ok) {
const txt = await res.text();
throw new Error(`API request failed (${res.status}): ${txt}`);
}
return res.json();
}