Skip to content

AI Features Overview

Drizzle Cube provides two approaches for AI-powered analytics:

  1. Built-in MCP Endpoints - Zero-config AI readiness using server-side NLU (no LLM required)
  2. Custom AI Endpoints - Full LLM-powered query generation (you implement with your preferred provider)

All framework adapters include a built-in MCP server at /mcp that lets AI agents discover and query your data:

ToolPurpose
drizzle_cube_discoverFind relevant cubes based on topic or intent
drizzle_cube_validateValidate queries and get auto-corrections
drizzle_cube_loadExecute queries and return results

Connect Claude, ChatGPT, n8n, or any MCP-compatible client to your semantic layer.

Learn more about the MCP Server →


For more sophisticated natural language understanding, you can implement custom AI endpoints using an LLM provider like Google Gemini.

Note: Custom AI endpoints (/api/ai/*) are not included in the drizzle-cube package. You must implement them yourself. We provide prompt templates, type definitions, and a complete reference implementation.

ComponentIncludedDescription
/mcp/* endpoints✅ Built-inMCP endpoints for AI agents (all adapters)
/cubejs-api/v1/explain✅ Built-inExecution plan endpoint (all adapters)
Prompt templates✅ ExportedbuildStep0Prompt, buildStep1Prompt, etc.
Type definitions✅ ExportedStep0Result, Step1Result, AIExplainAnalysis
/api/ai/* endpoints❌ You buildReference implementation provided

See our complete working implementation in the dev server:

  • ai-routes.ts - Complete AI endpoints (800+ lines)
  • app.ts - How to mount AI routes with middleware

Convert questions like “Show me sales by region this quarter” into properly structured semantic queries. The multi-stage generation pipeline fetches actual dimension values from your database, ensuring accurate filter values.

Learn more about Query Generation →

Analyze query execution plans with AI-powered recommendations. Get insights into:

  • Sequential scans that might benefit from indexes
  • Missing index opportunities
  • Query optimization suggestions
  • Performance assessments (good / warning / critical)

Learn more about Query Analysis →

To use AI features, you need:

  1. Google Gemini API Key - Get one free at Google AI Studio
  2. Server-side AI Routes - AI endpoints must be implemented in your server (not included in adapters)
┌────────────────────────────────────────────────────────────────────┐
│ Your Application │
├────────────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────────┐ ┌──────────────────┐ ┌───────────────────┐ │
│ │ Cube API │ │ MCP Server │ │ AI Routes │ │
│ │ /cubejs-api/v1 │ │ /mcp (built-in) │ │ /api/ai (custom) │ │
│ │ │ │ │ │ │ │
│ │ • /load │ │ • meta │ │ • /generate │ │
│ │ • /meta │ │ • discover │ │ • /explain/... │ │
│ │ • /explain │ │ • validate │ │ • /health │ │
│ │ • /batch │ │ • load │ │ │ │
│ └─────────────────┘ └──────────────────┘ └───────────────────┘ │
│ │ │ │ │
│ └────────────────────┴─────────────────────┘ │
│ │ │
│ ┌────────▼────────┐ │
│ │ Semantic Layer │ │
│ │ + Security Ctx │ │
│ └─────────────────┘ │
│ │
└────────────────────────────────────────────────────────────────────┘
┌─────────────────┐ ┌──────────────────┐
│ MCP Endpoints │ │ Custom AI │
│ (Built-in) │ │ (You implement) │
├─────────────────┤ ├──────────────────┤
│ • No LLM needed │ │ • LLM required │
│ • Zero config │ │ • Customizable │
│ • Server-side │ │ • Provider choice│
│ NLU │ │ • Full control │
└─────────────────┘ └──────────────────┘

AI features respect your security context at every step:

  • Dimension value lookups use your security context - users only see values from their tenant’s data
  • Generated queries are executed with the same security context
  • Input validation (Step 0) rejects injection attempts, off-topic requests, and malicious prompts
  • Rate limiting prevents abuse of server API keys
  1. Set up AI endpoints in your server
  2. Configure the client to use AI features:
<CubeProvider
apiOptions={{ apiUrl: '/cubejs-api/v1' }}
features={{
enableAI: true,
aiEndpoint: '/api/ai/generate'
}}
>
<AnalysisBuilder />
</CubeProvider>