cambios mcp remoto

This commit is contained in:
Jordan Diaz
2026-04-17 20:03:02 +00:00
parent d41a94b57d
commit 2ac01acd61
15 changed files with 344 additions and 123 deletions

View File

@@ -5,6 +5,7 @@ import { withAuth, getSessionCredentials } from "../../auth/index.js";
import { handleToolError, validateRequired } from "../helpers/errorHandler.js";
import { withAuthParams } from "../helpers/authSchema.js";
import { LOCAL_SERVER_URL } from "../../config/index.js";
import { resolveCurrentAcaiUser } from "../helpers/sessionHelpers.js";
export function registerCompileModuleTool(server) {
server.tool(
@@ -44,11 +45,16 @@ Pass the full path to the index-base.tpl file and the project directory.`,
? { project: projectSlug, relativePath, project_dir: projectDir }
: { file: filePath, project_dir: projectDir };
// Call the Python server compile endpoint
// Call the Python server compile endpoint. Inyectar X-Acai-User
// cuando hay sesion HTTP activa para que el endpoint autenticado
// resuelva el proyecto dentro de /opt/acai/webs/<user>/.
const acaiUser = resolveCurrentAcaiUser();
const headers = { "Content-Type": "application/json" };
if (acaiUser) headers["X-Acai-User"] = acaiUser;
const response = await axios.post(
`${LOCAL_SERVER_URL}/api/compile-module`,
payload,
{ headers: { "Content-Type": "application/json" }, timeout: 30000 }
{ headers, timeout: 30000 }
);
if (response.data?.ok) {

View File

@@ -4,6 +4,8 @@ import { withAuth } from "../../auth/index.js";
import { handleToolError, validateRequired } from "../helpers/errorHandler.js";
import { withAuthParams } from "../helpers/authSchema.js";
import { LOCAL_SERVER_URL } from "../../config/index.js";
import { resolveCurrentProjectDir } from "../files/helpers.js";
import { resolveCurrentAcaiUser } from "../helpers/sessionHelpers.js";
export function registerCreateModuleTool(server) {
server.tool(
@@ -35,7 +37,7 @@ Parameters:
const validationError = validateRequired({ moduleId, html }, ['moduleId', 'html'], 'create_module');
if (validationError) return validationError;
const projectDir = process.env.ACAI_PROJECT_DIR || "";
const projectDir = resolveCurrentProjectDir();
if (!projectDir) {
return { content: [{ type: "text", text: "Error: ACAI_PROJECT_DIR not set" }], isError: true };
}
@@ -43,10 +45,15 @@ Parameters:
moduleId = moduleId.toLowerCase().replace(/\s+/g, '_'); // Ensure moduleId is lowercase and uses underscores
moduleId = moduleId + "_" + (Math.random().toString(36).substring(2, 8).toUpperCase());
// Inyectar X-Acai-User para que el endpoint autenticado del
// server Python resuelva rutas dentro de /opt/acai/webs/<user>/.
const acaiUser = resolveCurrentAcaiUser();
const headers = { "Content-Type": "application/json" };
if (acaiUser) headers["X-Acai-User"] = acaiUser;
const response = await axios.post(
`${LOCAL_SERVER_URL}/api/create-module`,
{ project_dir: projectDir, module_id: moduleId, html, css: css || "", js: js || "", label, description, php: php || "" },
{ headers: { "Content-Type": "application/json" }, timeout: 30000 }
{ headers, timeout: 30000 }
);
if (response.data?.success) {