lightdash_get_analytics
Retrieve analytics data for a specific table in a Lightdash project by providing the project UUID and table name.
Instructions
Get analytics for a specific table in the data catalog
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectUuid | Yes | The UUID of the project. You can obtain it from the project list. | |
| table | Yes |
Implementation Reference
- src/mcp.ts:439-469 (handler)Handler for 'lightdash_get_analytics' tool. Parses args with GetAnalyticsRequestSchema, calls GET /api/v1/projects/{projectUuid}/dataCatalog/{table}/analytics, and returns the results.
case 'lightdash_get_analytics': { const args = GetAnalyticsRequestSchema.parse( request.params.arguments ); const { data, error } = await lightdashClient.GET( '/api/v1/projects/{projectUuid}/dataCatalog/{table}/analytics', { params: { path: { projectUuid: args.projectUuid, table: args.table, }, }, } ); if (error) { throw new Error( `Lightdash API error: ${error.error.name}, ${ error.error.message ?? 'no message' }` ); } return { content: [ { type: 'text', text: JSON.stringify(data.results, null, 2), }, ], }; } - src/schemas.ts:96-104 (schema)Zod schema for GetAnalyticsRequestSchema: expects projectUuid (UUID string) and table (string).
export const GetAnalyticsRequestSchema = z.object({ projectUuid: z .string() .uuid() .describe( 'The UUID of the project. You can obtain it from the project list.' ), table: z.string(), }); - src/mcp.ts:104-108 (registration)Registration of the 'lightdash_get_analytics' tool in the ListTools handler, with description and inputSchema.
{ name: 'lightdash_get_analytics', description: 'Get analytics for a specific table in the data catalog', inputSchema: zodToJsonSchema(GetAnalyticsRequestSchema), }, - src/mcp.ts:25-32 (helper)Lightdash client initialization used by the handler to make the API call.
const lightdashClient = createLightdashClient( process.env.LIGHTDASH_API_URL || 'https://app.lightdash.cloud', { headers: { Authorization: `ApiKey ${process.env.LIGHTDASH_API_KEY}`, }, } );