mcp tablas
This commit is contained in:
28
mcp-server/tools/tables/reorderTables.js
Normal file
28
mcp-server/tools/tables/reorderTables.js
Normal file
@@ -0,0 +1,28 @@
|
||||
import { z } from "zod";
|
||||
import { withAuth } from "../../auth/index.js";
|
||||
import { withAuthParams } from "../helpers/authSchema.js";
|
||||
import { handleToolError } from "../helpers/errorHandler.js";
|
||||
import { callSchemaEndpoint } from "./_schemaEndpoint.js";
|
||||
|
||||
// Tool: reorder_tables
|
||||
// Reasigna el menuOrder de cada tabla segun el orden de la lista recibida.
|
||||
// Idempotente. No afecta datos, solo el orden de presentacion en el admin.
|
||||
|
||||
export function registerReorderTablesTool(server) {
|
||||
server.tool(
|
||||
"reorder_tables",
|
||||
`Reorder tables in the admin sidebar. Pass the full ordered list of tableNames; the backend reassigns menuOrder sequentially. Only the sidebar order changes — data and schemas are untouched. Table names WITHOUT 'cms_' prefix.`,
|
||||
withAuthParams({
|
||||
order: z.array(z.string().min(1)).min(1).describe("Ordered list of tableNames (the new sidebar order)"),
|
||||
}),
|
||||
{ readOnlyHint: false, destructiveHint: false },
|
||||
withAuth(async ({ order }, _extra) => {
|
||||
try {
|
||||
const { mcp } = await callSchemaEndpoint("/api/schema/reorder-tables", { order });
|
||||
return mcp;
|
||||
} catch (error) {
|
||||
return handleToolError(error, "reorder_tables", { count: Array.isArray(order) ? order.length : 0 });
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user