
DAX Formatter
STDIOMCP server that formats DAX expressions using professional standards and options.
MCP server that formats DAX expressions using professional standards and options.
A Model Context Protocol (MCP) server that provides DAX (Data Analysis Expressions) formatting capabilities to AI assistants and other MCP clients. This server integrates with the official DAX Formatter service by SQLBI to deliver professional-grade DAX code formatting.
# Clone the repository git clone https://github.com/EmanueleMeazzo/dax-formatter-mcp.git cd dax-formatter-mcp # Build the project dotnet build --configuration Release # The executable will be in bin/Release/net8.0/
Add the following to your Claude Desktop configuration file:
Windows: %APPDATA%\Claude\claude_desktop_config.json
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Linux: ~/.config/claude/claude_desktop_config.json
{ "mcpServers": { "dax-formatter": { "command": "path/to/dax-formatter-mcp.exe", "args": [] } } }
Add to your Continue configuration:
{ "mcpServers": [ { "name": "dax-formatter", "command": "path/to/dax-formatter-mcp.exe", "args": [] } ] }
For any MCP client supporting the MCP 2024-11-05 protocol:
{ "servers": [ { "name": "dax-formatter", "transport": { "type": "stdio", "command": "path/to/dax-formatter-mcp.exe", "args": [] } } ] }
If you prefer to use the DLL with the .NET runtime:
{ "mcpServers": { "dax-formatter": { "command": "dotnet", "args": ["path/to/dax-formatter-mcp.dll"] } } }
Once configured, you can use the DAX formatter through your MCP client:
Format this DAX expression:
CALCULATE(SUM(Sales[Amount]),FILTER(Products,Products[Category]="Electronics"))
Format these DAX measures:
1. [Total Sales] := SUM(Sales[Amount])
2. [Electronics Sales] := CALCULATE(SUM(Sales[Amount]),Products[Category]="Electronics")
3. [Sales YTD] := TOTALYTD(SUM(Sales[Amount]),'Calendar'[Date])
Format this DAX with short lines and specific separators:
CALCULATE(SUM(Sales[Amount]),FILTER(Products,Products[Category]="Electronics"))
Options:
- Line length: ShortLine
- List separator: ;
- Decimal separator: ,
format_dax
Formats a single DAX expression.
Parameters:
dax
(required): The DAX expression to formatoptions
(optional): Formatting options objectExample:
{ "dax": "CALCULATE(SUM(Sales[Amount]),FILTER(Products,Products[Category]=\"Electronics\"))", "options": { "maxLineLength": "LongLine", "skipSpaceAfterFunctionName": "BestPractice" } }
format_dax_multiple
Formats multiple DAX expressions in a single request.
Parameters:
expressions
(required): Array of DAX expressions to formatoptions
(optional): Formatting options objectExample:
{ "expressions": [ "CALCULATE(SUM(Sales[Amount]),FILTER(Products,Products[Category]=\"Electronics\"))", "[Total Sales] := SUM(Sales[Amount])" ], "options": { "maxLineLength": "LongLine", "databaseName": "SalesDB", "serverName": "ProductionServer" } }
All formatting options are optional and have sensible defaults:
Option | Values | Default | Description |
---|---|---|---|
maxLineLength | ShortLine , LongLine , VeryLongLine | LongLine | Maximum line length for formatted code |
skipSpaceAfterFunctionName | BestPractice , False | BestPractice | Spacing after function names |
listSeparator | Any character | , | Character used as list separator |
decimalSeparator | Any character | . | Character used as decimal separator |
databaseName | String | - | Database name for context (anonymized) |
serverName | String | - | Server name for context (anonymized) |
Here are some example DAX expressions you can test with:
[Total Sales] := SUM(Sales[Amount])
CALCULATE(SUM(Sales[Amount]),FILTER(ALL(Products),Products[Category]="Electronics"),USERELATIONSHIP(Sales[OrderDate],'Calendar'[Date]))
[Sales YTD] := TOTALYTD(SUM(Sales[Amount]),'Calendar'[Date])
EVALUATE FILTER(Customer, Customer[Country] = "USA")
Server fails to start:
Formatting requests fail:
MCP client doesn't recognize the server:
To enable debug logging, you can run the server manually to see detailed logs:
# Run the server directly to see debug output ./dax-formatter-mcp.exe
Then send JSON-RPC messages manually to test functionality.
The MCP server is built with:
MCP Client → JSON-RPC → DAX Formatter MCP Server → DAX Formatter API → Formatted DAX
Contributions are welcome! Please follow these steps:
git checkout -b feature/amazing-feature
)git commit -m 'Add amazing feature'
)git push origin feature/amazing-feature
)# Clone the repository git clone https://github.com/EmanueleMeazzo/dax-formatter-mcp.git cd dax-formatter-mcp # Restore dependencies dotnet restore # Build the project dotnet build # Run tests dotnet test
This project is licensed under the MIT License - see the LICENSE file for details.