dax-query-server
Server Configuration
Describes the environment variables required to run the server.
| Name | Required | Description | Default |
|---|---|---|---|
| AZURE_CLI_PATH | No | Full path to az.cmd for custom Azure CLI installs, used for Power BI REST authentication. | |
| POWERBI_ACCESS_TOKEN | No | Environment variable used for Power BI REST authentication when a connection sets auth_mode to env. The default env var name is POWERBI_ACCESS_TOKEN. | |
| DAX_QUERY_MCP_CONNECTIONS_DIR | No | Absolute path to the Connections directory containing connection bundles. Used to share one Connections folder across workspaces. |
Instructions
Guidance the server publishes about itself, which clients place ahead of the tool catalog so the model reads it before choosing anything.
You are connected to the dax-query-server, which runs DAX queries against Power BI / Analysis Services semantic models.
Rules
ALWAYS EXECUTE queries — build the DAX AND call run_connection_query in the same turn. Never just show query text without running it.
Query tools return a COMPLETE, pre-formatted markdown response. Output the ENTIRE string verbatim as your response — including the data table AND the numbered "What would you like to do next?" list. Do NOT summarize, convert the table to bullet points, or omit the menu.
NEVER generate admin queries (INFO.(), $SYSTEM.DISCOVER_, DBCC, ALTER, CREATE, DELETE, DROP). Use get_connection_context for metadata.
Tool overview
Tool | Purpose |
list_connections | Discover available connections. |
get_connection_context | Schema overview — call BEFORE writing DAX. |
run_connection_query | Execute DAX against a named connection. |
run_ad_hoc_query | Execute DAX against a raw connection string. |
search_connection_context | Search context docs for tables, columns, filters. |
search_columns | Fuzzy search columns by name or description. |
search_measures | Fuzzy search measures by name or expression. |
export_to_csv | Save results to a timestamped CSV file. |
copy_to_clipboard | Copy results as TSV (Excel) or markdown. |
save_to_workstation | Save a query for iterative exploration. |
DAX best practices
Every query must start with EVALUATE and return a table.
Use SUMMARIZECOLUMNS (or SUMMARIZE) for grouped aggregations.
Use TREATAS for cross-table filtering instead of CALCULATETABLE.
Use TOPN to limit large result sets:
EVALUATE TOPN(100, 'Table').Quote table names with single quotes, columns with brackets:
'Sales'[Revenue].
Error codes and recovery
Code | Recovery |
ADMIN_QUERY_BLOCKED | Rewrite with EVALUATE or use get_connection_context. |
CONNECTION_NOT_FOUND | Call list_connections and retry. |
QUERY_TIMEOUT | Simplify query, add filters, or increase timeout. |
EXECUTION_FAILED | Check names via get_connection_context, fix syntax. |
INVALID_PARAMS | Read the suggestion field and correct the call. |
Follow-up options after query results
The query tool output already includes the numbered "What would you like to do next?" list. Do NOT generate your own version — the list is baked into the tool response and must appear exactly as returned.
Capabilities
Features and capabilities supported by this server
Protocol revision2025-11-25
| Capability | Details |
|---|---|
| tools | {
"listChanged": true
} |
| prompts | {
"listChanged": false
} |
| resources | {
"subscribe": false,
"listChanged": false
} |
| extensions | {
"io.modelcontextprotocol/ui": {}
} |
| experimental | {} |
Tools
Functions exposed to the LLM to take actions
| Name | Description |
|---|---|
| server_infoB | Return package, runtime, path, template, and follow-up diagnostics. |
| list_connectionsA | List configured connections as a markdown table by default. Call get_connection_context on a connection with overview/full context before writing DAX queries. Set output_format="json" for machine-readable output. |
| get_connection_contextA | Return metadata and context for a named connection. This is the PRIMARY way to discover tables, columns, measures, and filters. Always call this FIRST before writing any DAX query. detail levels:
|
| search_connection_contextA | Search the full connection context markdown for specific terms. Use this instead of loading the full context when you need to find specific information about tables, columns, filters, or query patterns. Returns matching lines with surrounding context. |
| get_data_dictionaryB | Return the data dictionary for a named connection as JSON. The data dictionary describes tables, columns, measures, and filters with human-readable descriptions and sample values. |
| get_schemaA | Return schema information for a connection, enriched with data dictionary descriptions when available. If a data dictionary file exists for the connection, the response
includes table, column, measure, and filter descriptions. Otherwise
a basic payload is returned suggesting |
| get_context_bundleA | Return a progressive, structured context bundle for a connection. detail="overview" returns compact counts and key names; "schema" returns structured tables, measures, filters, and relationships; "full" also includes available markdown context. Use table_names as a comma-separated allowlist to scope table-heavy schema output. |
| get_table_detailC | Return detailed structured context for a single table. |
| get_measure_detailC | Return detailed structured context for a single measure. |
| get_relationshipsB | Return relationship topology, optionally filtered to one table. |
| get_filter_suggestionsC | Return suggested filters and values from the data dictionary. |
| check_context_stalenessC | Compare live model metadata against the data dictionary for drift. |
| check_ai_readinessC | Assess whether context is descriptive enough for reliable DAX generation. |
| probe_tmschema_capabilitiesC | Probe optional TMSCHEMA metadata access without requiring it. |
| run_connection_queryC | Run a DAX query against a named connection. IMPORTANT: This tool returns a COMPLETE, pre-formatted response for the user. Output the returned string as your ENTIRE response — do NOT summarize, truncate, or convert the table to bullet points. The output includes a data table and a numbered follow-up menu that must both appear. |
| get_query_builder_schemaB | Return the expected JSON shape and a copyable example payload for save_query_builder. |
| save_query_builderA | Save .dax and .dax.queryBuilder artifacts from a structured query builder JSON payload. STOP — before calling this tool you MUST:
The JSON payload requires these fields:
|
| get_query_builderB | Load a saved query builder definition and generated DAX text by query name. |
| inspect_connectionA | Inspect model metadata using non-admin MDSCHEMA rowsets. Prefer get_connection_context first — it returns curated documentation without hitting the server. Use this only for live schema discovery. |
| list_queriesC | Backward-compatible helper for the older query-centric workflow. |
| run_named_queryB | Run a pre-configured named query and return a preview. IMPORTANT: This tool returns a COMPLETE, pre-formatted response for the user. Output the returned string as your ENTIRE response — do NOT summarize, truncate, or convert the table to bullet points. The output includes a data table and a numbered follow-up menu that must both appear. |
| run_ad_hoc_queryB | Run a DAX query against a raw connection string. IMPORTANT: This tool returns a COMPLETE, pre-formatted response for the user. Output the returned string as your ENTIRE response — do NOT summarize, truncate, or convert the table to bullet points. The output includes a data table and a numbered follow-up menu that must both appear. |
| inspect_model_metadataC | Backward-compatible metadata probe for raw connection strings. Present previews as markdown tables. |
| search_columnsA | Fuzzy-search columns across all tables for a connection. Searches column names (case-insensitive substring match) and also column descriptions when a data dictionary exists. Returns a JSON array sorted by relevance: exact match > starts-with > contains. |
| search_measuresA | Search measures for a connection by name, description, or expression. Performs a case-insensitive substring match on measure names and, when a data dictionary exists, measure descriptions and DAX expressions. Returns a JSON array sorted by relevance: exact match > starts-with > contains. Expressions are truncated to 100 characters. Required parameters: connection_name, search_term. Optional parameters: connections_dir, max_results (default 20). Use this when the user asks "which measure calculates revenue?" or similar discovery questions. |
| copy_to_clipboardB | Run a DAX query and copy the full result to the system clipboard. Use format="tsv" (default) to paste into Excel, or format="markdown" for a markdown table. Returns a JSON summary with row_count and a short preview. |
| scaffold_dax_workspaceB | Scaffold a portable DAX workspace folder with a bare-bones executor script. Creates: run_query.py, notebook.ipynb, queries/.dax, pyproject.toml, README. STOP — before calling this tool you MUST:
After scaffolding, explain to the user:
|
| scaffold_streamlit_appA | Generate a Streamlit Python app for visualizing DAX query results. Creates a standalone .py file that uses Streamlit to execute the embedded DAX query, display results, filter columns, build charts/pivots, download artifacts, and drag/drop CSV or JSON exports for offline exploration. Parameters: connection_name: Name of the DAX connection (embedded in the generated app). query: The DAX query to embed in the generated app. title: Page title shown in the Streamlit app. output_path: If provided, write the generated code to this file path. connections_dir: Directory containing named DAX connection YAML files. |
| export_to_csvC | Export DAX query results to a timestamped CSV file. Returns JSON with file_path, row_count, and column_count. |
| scaffold_power_queryC | Generate Power Query M code for importing DAX query results into Excel. Returns JSON with the generated M code, table name, and paste instructions. |
| quick_chartB | Generate a chart (bar, line, or pie) from DAX query results. Returns JSON with file_path, chart_type, and row_count. If output_path is not provided, the chart is saved to a temp file. |
| generate_data_dictionaryA | Generate a data dictionary YAML from live schema inspection. Queries MDSCHEMA_MEASUREGROUPS, MDSCHEMA_MEASURES, MDSCHEMA_DIMENSIONS, and MDSCHEMA_LEVELS to discover tables, columns, and measures, then builds a DataDictionary scaffold. If optional TMSCHEMA rowsets are available, it also includes high-confidence relationship metadata. Required parameters: connection_name. Optional parameters: connections_dir, output_path — when provided the YAML is written to disk. Returns JSON with yaml_content, table_count, measure_count, and file_path (when output_path is given). |
| diff_data_dictionaryB | Compare two data dictionary YAML files and return added/removed metadata. |
| merge_data_dictionaryC | Merge regenerated metadata with curated descriptions and optionally write YAML. |
| review_data_dictionary_updateA | Preview diff and merged output before replacing a curated data dictionary. |
| save_validated_queryB | Save a known-good DAX pattern to a connection-scoped validated query library. This creates two files under |
| list_validated_queriesA | List connection-scoped validated query metadata. Set include_dax=True only when you need the actual DAX examples; context bundles intentionally include metadata only. |
| search_validated_queriesB | Search saved known-good DAX examples for a connection. Search matches id, display name, description, tags, grain, and DAX text. Results include DAX by default because this is an explicit retrieval tool. |
| validate_query_libraryB | Execute saved query-library examples and persist validation metadata. max_rows caps returned rows but does not guarantee a cheap server-side DAX plan; keep validation queries intentionally small and well-filtered. |
| save_to_workstationA | Save a DAX query to the session workstation for iterative exploration. The workstation is ephemeral — it resets when the server restarts (i.e. each new chat session starts fresh). Use export_workstation to persist queries permanently as a scaffold project or .dax files. Parameters: connection_name: Name of the connection this query targets. query: The DAX query text. description: Human-readable description of what the query does. query_name: Optional slug name; auto-generated from description if blank. connections_dir: Connections directory (unused for storage, kept for API compat). |
| list_workstationB | List all queries saved in the current session workstation. Returns a JSON array of saved queries with their names, descriptions, connection names, and timestamps. Shows a helpful message if the workstation is empty. |
| remove_from_workstationA | Remove a saved query from the workstation by name. Parameters: query_name: The slug name of the query to remove. connections_dir: Unused (kept for API compat). |
| clear_workstationB | Clear all queries from the workstation. Removes every saved query from the in-memory workstation and returns the count of removed items. |
| create_query_packC | Create an empty durable query pack with a versioned pack.yaml manifest. |
| save_query_to_packB | Save a DAX query into a durable query pack on disk. Unlike the session workstation, durable query packs reject duplicate query IDs unless overwrite=True is explicitly provided. |
| list_query_packB | List query-pack metadata and query entries from pack.yaml. |
| validate_query_packC | Validate a query pack structurally and optionally smoke-test each query. |
| describe_query_packC | Generate a shareable markdown description of a query pack. |
| export_query_packC | Export a query pack as a runnable Python/Streamlit/Power Query workspace. |
| export_workstationA | Export all workstation queries as a scaffold workspace or .dax files. This is the "make it permanent" step — writes the in-memory workstation to disk as a portable project. Parameters: output_dir: Directory to write the exported files. connections_dir: Unused (kept for API compat). format: "scaffold" creates a full project (run_queries.py, pyproject.toml, README, and queries/ dir). "dax" writes only .dax files. |
Prompts
Interactive templates invoked by user choice
| Name | Description |
|---|---|
| explore_connection | Guide an agent through progressive discovery for a new DAX connection. |
| find_measure_for_metric | Guide measure discovery before writing a metric-focused DAX query. |
| write_filtered_dax_query | Guide filtered DAX query authoring with context and execution steps. |
| build_period_comparison_query | Guide a period comparison or time-intelligence DAX workflow. |
| export_query_results | Guide an end-to-end query-to-artifact follow-up workflow. |
Resources
Contextual data attached and managed by the client
| Name | Description |
|---|---|
| followup_menu | Return a structured menu of available follow-up actions after running a query. Each item includes name, description, required_params, and example_usage so an LLM can suggest appropriate next actions to the user. |
| grouped_followup_menu | Return follow-up actions grouped by current-query and query-pack scope. |
| followup_recommendations | Return server-ranked follow-up actions for the latest query result. |
TDQS
Scored across 50 tools
Several clusters overlap heavily: get_connection_context, get_context_bundle, get_schema, get_data_dictionary, and inspect_connection all return model metadata, and save_to_workstation / save_query_to_pack / save_query_builder / save_validated_query differ mainly by storage plane. The descriptions do give explicit routing guidance ("call get_connection_context FIRST", "prefer X over Y"), which rescues most cases, but legacy entries like list_queries and run_ad_hoc_query add real ambiguity.
Most tools follow a clear verb_noun pattern (get_*, list_*, save_*, run_*, search_*, export_*, scaffold_*, check_*, validate_*). Minor deviations exist, notably quick_chart (adjective_noun) and server_info (noun_noun), but overall the convention is predictable and scannable.
Fifty tools for a DAX query server is a severe mismatch; the surface is bloated with parallel execution paths (run_connection_query, run_named_query, run_ad_hoc_query, copy_to_clipboard, export_to_csv, quick_chart) and four separate persistence mechanisms. Several tools are explicitly labeled backward-compatible helpers, meaning they exist only for legacy reasons rather than earning their place.
Individual workflows are covered end to end (discovery, execution, validation, export, scaffolding), but the lifecycle is inconsistent across storage types: query packs and validated-query libraries have create/save/list but no update or delete, while only the ephemeral workstation supports removal. The result is an uneven surface where agents will hit dead ends depending on which persistence path they chose.