From fd936efc020452dd13ffaebe15e0065188462d57 Mon Sep 17 00:00:00 2001 From: josedario87 Date: Tue, 28 Oct 2025 15:46:48 -0600 Subject: [PATCH] Corregir outputSchema en todas las herramientas MCP - Cambiar z.any() a { result: z.any() } - Cambiar z.array(z.any()) a { collections/databases/dashboards: z.array(z.any()) } - Agregar type assertion 'as T' en metabaseFetch - Soluciona errores de TypeScript con ZodRawShape --- mcp-metabase-server/src/index.ts | 34 +++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/mcp-metabase-server/src/index.ts b/mcp-metabase-server/src/index.ts index 6f10eee..41ee552 100644 --- a/mcp-metabase-server/src/index.ts +++ b/mcp-metabase-server/src/index.ts @@ -40,7 +40,7 @@ async function metabaseFetch( throw new Error(`Metabase API error (${response.status}): ${errorText}`); } - return await response.json(); + return await response.json() as T; } catch (error) { console.error(`Error en petición a ${endpoint}:`, error); throw error; @@ -123,7 +123,9 @@ server.registerTool( inputSchema: { card_id: z.number().describe('ID de la card'), }, - outputSchema: z.any() + outputSchema: { + result: z.any() + } }, async ({ card_id }) => { try { @@ -156,7 +158,9 @@ server.registerTool( value: z.any().describe('Valor del parámetro'), })).optional().describe('Parámetros para la query'), }, - outputSchema: z.any() + outputSchema: { + result: z.any() + } }, async ({ card_id, parameters }) => { try { @@ -206,7 +210,9 @@ server.registerTool( visualization_settings: z.record(z.any()).optional().describe('Configuración de visualización'), collection_id: z.number().optional().describe('ID de la colección'), }, - outputSchema: z.any() + outputSchema: { + result: z.any() + } }, async ({ name, description, dataset_query, display, visualization_settings, collection_id }) => { try { @@ -255,7 +261,9 @@ server.registerTool( name: z.string().optional().describe('Nuevo nombre'), description: z.string().optional().describe('Nueva descripción'), }, - outputSchema: z.any() + outputSchema: { + result: z.any() + } }, async ({ card_id, name, description }) => { try { @@ -293,7 +301,9 @@ server.registerTool( title: 'Listar Colecciones', description: 'Lista todas las colecciones disponibles en Metabase', inputSchema: {}, - outputSchema: z.array(z.any()) + outputSchema: { + collections: z.array(z.any()) + } }, async () => { try { @@ -321,7 +331,9 @@ server.registerTool( inputSchema: { include_tables: z.boolean().optional().default(false).describe('Incluir metadata de tablas'), }, - outputSchema: z.any() + outputSchema: { + databases: z.array(z.any()) + } }, async ({ include_tables }) => { try { @@ -366,7 +378,9 @@ server.registerTool( title: 'Listar Dashboards', description: 'Lista todos los dashboards disponibles', inputSchema: {}, - outputSchema: z.array(z.any()) + outputSchema: { + dashboards: z.array(z.any()) + } }, async () => { try { @@ -394,7 +408,9 @@ server.registerTool( inputSchema: { dashboard_id: z.number().describe('ID del dashboard'), }, - outputSchema: z.any() + outputSchema: { + result: z.any() + } }, async ({ dashboard_id }) => { try {