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

@@ -6,12 +6,13 @@ import { withAuth } from "../../auth/index.js";
import { handleToolError } from "../helpers/errorHandler.js";
import { withAuthParams } from "../helpers/authSchema.js";
import { pythonPost } from "../helpers/pythonServerClient.js";
import { resolveCurrentProjectDir } from "../files/helpers.js";
// --- Verificacion de creditos ---
const WS_BASE = "https://ws.cocosolution.com/api/handler_acaicode.php";
function getAcaiToken() {
const projectDir = process.env.ACAI_PROJECT_DIR || "";
const projectDir = resolveCurrentProjectDir();
if (!projectDir) return null;
try {
const acaiFile = path.join(projectDir, ".acai");
@@ -56,7 +57,7 @@ export function registerGenerateImageTool(server) {
};
}
const projectSlug = path.basename(process.env.ACAI_PROJECT_DIR || "");
const projectSlug = path.basename(resolveCurrentProjectDir());
const safeFileName = fileName || `generated-${Date.now()}`;
const destRelativePath = `cms/uploads/generated/${safeFileName}.jpg`;
const fullPrompt = style ? `${style} style: ${prompt}` : prompt;

View File

@@ -6,6 +6,7 @@ import { handleToolError, validateRequired, handleApiResponse } from "../helpers
import { withAuthParams } from "../helpers/authSchema.js";
import { AcaiHttpClient } from "../helpers/acaiHttpClient.js";
import { pythonPost } from "../helpers/pythonServerClient.js";
import { resolveCurrentProjectDir } from "../files/helpers.js";
/**
* Helper: POST to mcp_respond.php via viewer_functions.php
@@ -78,7 +79,7 @@ async function resolveLocalImageAsBase64(imageUrl) {
}
// Intento B: resolver el pathname contra ACAI_PROJECT_DIR y leer del disco
const projectDir = process.env.ACAI_PROJECT_DIR || "";
const projectDir = resolveCurrentProjectDir();
if (projectDir && parsed.pathname) {
try {
const localPath = path.join(projectDir, parsed.pathname);
@@ -118,7 +119,7 @@ export function registerUploadRecordImageTool(server) {
);
if (validationError) return validationError;
const projectSlug = path.basename(process.env.ACAI_PROJECT_DIR || "");
const projectSlug = path.basename(resolveCurrentProjectDir());
// Intentar via Python server (tiene sync + optimizacion)
let result;