Skip to main content
Glama
poddubnyoleg

Lightdash MCP Server

by poddubnyoleg

run-raw-query

Execute arbitrary metric queries against Lightdash explores for ad-hoc analysis, debugging, or dashboard-only charts.

Instructions

Execute a raw metric query against a Lightdash explore.

This tool allows you to run arbitrary queries by specifying dimensions, metrics, filters, and sorts directly. It is useful for:

  • Running ad-hoc analysis without creating a saved chart

  • Executing queries for dashboard-only charts (which don't have a saved chart UUID)

  • Debugging data issues by running simplified queries

Input:

  • explore_name: The name of the explore (table) to query.

  • metric_query: The query definition (dimensions, metrics, filters, etc.).

  • limit: Optional row limit.

═══════════════════════════════════════════════════════════════════ COMPLETE WORKING EXAMPLE: ═══════════════════════════════════════════════════════════════════

metric_query: { "dimensions": ["my_table_date_day"], "metrics": [], "filters": { "dimensions": { "id": "root", "and": [ { "id": "filter_1", "target": {"fieldId": "my_table_country"}, "operator": "equals", "values": ["US"] }, { "id": "filter_2", "target": {"fieldId": "my_table_date_day"}, "values": [30], "operator": "inThePast", "required": false, "settings": { "completed": false, "unitOfTime": "days" } } ] } }, "sorts": [{"fieldId": "my_table_date_day", "descending": true}], "limit": 500, "tableCalculations": [], "additionalMetrics": [ { "name": "dau", "label": "Daily Active Users", "description": "Count of unique users", "type": "count_distinct", "sql": "${TABLE}.user_id", "table": "my_table", "baseDimensionName": "user_id", "formatOptions": {"type": "default", "separator": "default"} } ] }

Key Rules:

  1. Field IDs: Use table_field format (e.g., orders_amount). Use get-explore-schema to find correct IDs.

  2. Filters:

    • Simple: {"operator": "equals", "values": ["value"]}

    • Time: {"operator": "inThePast", "values": [7], "settings": {"unitOfTime": "days", "completed": false}}

  3. Additional Metrics: Use this to create ad-hoc metrics (like count distinct) that aren't in the dbt model.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
explore_nameYesName of the explore (table) to query (e.g., 'orders', 'customers')
metric_queryYesJSON string of the metric query configuration. Must include 'dimensions', 'metrics', etc. See description for example.
limitNoOptional: Limit number of rows returned. Default is 500.
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description must carry the burden of behavioral disclosure. It describes the tool as executing queries but does not explicitly state that it is read-only, idempotent, or requires specific permissions. The description includes detailed input rules but omits safety or side-effect information, which is a gap for a query tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with headings, bullet points, and a complete example. It is informative but slightly lengthy; however, each sentence adds value. Could be trimmed slightly, but overall efficient.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The description thoroughly explains input configuration but lacks information about the return format, error handling, or how to interpret results. Since there is no output schema, the description should cover what the tool returns. This gap reduces completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% with descriptions for all three parameters. The description adds significant value beyond the schema, including a complete working example, key rules for field IDs, filter syntax, and additional metrics. This clarifies the complex 'metric_query' parameter effectively.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states 'Execute a raw metric query against a Lightdash explore', specifying the verb (execute) and resource (raw metric query). It distinguishes from siblings like 'run-chart-query' by noting use cases such as ad-hoc analysis, dashboard-only charts, and debugging, making the purpose unambiguous.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly lists when to use the tool (ad-hoc analysis, dashboard-only charts, debugging) and references 'get-explore-schema' for field IDs. However, it does not explicitly state when NOT to use it (e.g., prefer 'run-chart-query' for saved charts), though sibling tools provide context.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/poddubnyoleg/lightdash_mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server