feat(mcp): tools de idiomas y traducciones

- Nueva categoria tools/languages: list_web_languages,
  get_record_translations y set_record_translations (registros, config,
  textos_generales y vars de modulo via builder_custom).
- Param lang opcional en list_table_records y get_record
  (options.translates de CocoDB).
- Docs actualizados (03/04/06/09/11b + ACAI_ENDPOINTS) con el modelo de
  cms_traducciones y los workflows de traduccion.
This commit is contained in:
Jordan Diaz
2026-07-16 20:09:47 +00:00
parent d475845c27
commit d46c204ed0
13 changed files with 382 additions and 3 deletions

View File

@@ -0,0 +1,54 @@
import { withAuth, getSessionCredentials } from "../../auth/index.js";
import { handleToolError, handleApiResponse } from "../helpers/errorHandler.js";
import { AcaiHttpClient } from "../helpers/acaiHttpClient.js";
import { withAuthParams } from "../helpers/authSchema.js";
export function registerListWebLanguagesTool(server) {
server.tool(
"list_web_languages",
`List the active languages configured for the current website (from settings.dat.php [idiomas]).
Returns an array of languages, each with:
- name: internal code (e.g. 'espanol')
- label: human label
- prefix: the translation prefix stored in cms_traducciones. The prefix "www" is the BASE language (its URLs have NO path prefix). Any other prefix (e.g. "en") is a secondary language served under /<urlPrefix>/...
- urlPrefix: the URL path segment for that language ('' for the base language, e.g. 'en' otherwise)
- isDefault: true for the base language
Also returns defaultLanguage. Use the prefix values here when calling get_record_translations / set_record_translations.`,
withAuthParams({}),
{ readOnlyHint: true, destructiveHint: false },
withAuth(async (_args, extra) => {
try {
const credentials = await getSessionCredentials(extra.sessionId);
const response = await AcaiHttpClient.postViewerAction(
credentials,
"getLanguages",
{},
credentials.token,
credentials.tokenHash,
{},
15000
);
const apiError = handleApiResponse(response.data, "list_web_languages");
if (apiError) return apiError;
return {
content: [{
type: "text",
text: JSON.stringify({
success: true,
action: "list_web_languages",
languages: response.data?.languages || [],
defaultLanguage: response.data?.defaultLanguage,
}, null, 2)
}],
};
} catch (error) {
return handleToolError(error, "list_web_languages");
}
})
);
}