cambios mcp remoto
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user