Skip to content

Commit 422dce1

Browse files
committed
Added DAX Formatter documentation
1 parent 5d65fd7 commit 422dce1

5 files changed

Lines changed: 498 additions & 0 deletions

File tree

_mydocs/dax-formatter/github.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
layout: page
3+
title: GitHub repository
4+
menu_title: GitHub repository
5+
published: true
6+
order: /3
7+
---
8+
The clients for the DAX Formatter service are open source and developed in the public repository [`sql-bi/DaxFormatter`](https://github.com/sql-bi/DaxFormatter) on GitHub, under the MIT license.
9+
10+
## What the repository contains
11+
12+
The repository hosts the client SDKs and the local MCP server that wrap the DAX Formatter service:
13+
14+
- **.NET client** — the [`Dax.Formatter`](nuget) C# library, published as a NuGet package.
15+
- **TypeScript client**`@sqlbi/daxformatter`, the JavaScript/TypeScript counterpart for browser and Node.js.
16+
- **MCP Server (stdio)**[`@sqlbi/daxformatter-mcp`](mcp-stdio), the local Model Context Protocol server.
17+
18+
> All of these are clients of the same service. The formatting logic runs server-side at `https://api.daxformatter.com`; the repository provides the transport, schemas, and packaging around it.
19+
20+
## Contributing
21+
22+
The project welcomes community contributions:
23+
24+
- Report bugs or request features through the [issues](https://github.com/sql-bi/DaxFormatter/issues) page.
25+
- Submit pull requests for fixes and improvements.
26+
27+
Build and CI/CD are automated with GitHub Actions; see the repository for the .NET SDK version requirements and contribution details.
28+
29+
## Related resources
30+
31+
- Online service: [daxformatter.com](https://www.daxformatter.com)
32+
- Formatting rules: [Rules for DAX code formatting](https://www.sqlbi.com/articles/rules-for-dax-code-formatting/)
33+
- [NuGet package `Dax.Formatter`](nuget) · [MCP Server (HTTP)](mcp-http) · [MCP Server (stdio)](mcp-stdio)

_mydocs/dax-formatter/index.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
layout: page
3+
title: DAX Formatter
4+
published: true
5+
order: /dax-formatter
6+
next_reading: true
7+
next_reading_title: Ways to access DAX Formatter
8+
---
9+
[DAX Formatter](https://www.daxformatter.com) is a free service by SQLBI that formats DAX expressions according to the [rules for DAX code formatting](https://www.sqlbi.com/articles/rules-for-dax-code-formatting/). All the formatting happens server-side at `https://api.daxformatter.com`: the tools described here are clients, transports, and integrations around that single service.
10+
11+
> Formatting a DAX expression also **validates** it. If the expression contains a syntax error, the service reports it with the line and column of the problem instead of returning formatted code.
12+
13+
## Ways to access DAX Formatter
14+
15+
Beyond the [web interface](https://www.daxformatter.com), the DAX Formatter service can be reached programmatically and from AI assistants:
16+
17+
- [**NuGet package `Dax.Formatter`**](nuget): a .NET client library to format and validate DAX from your own applications and scripts.
18+
- [**MCP Server (HTTP)**](mcp-http): a remote, hosted [Model Context Protocol](https://modelcontextprotocol.io) server. Add one URL to your AI client and let it format DAX — no install, no account.
19+
- [**MCP Server (stdio)**](mcp-stdio): a local MCP server run through `npx`, for AI clients and IDE agents that launch tools as a local process.
20+
- [**GitHub repository**](github): the open-source `sql-bi/DaxFormatter` repository that hosts the .NET and TypeScript clients and the stdio MCP server.
21+
22+
## Which one should I use?
23+
24+
| You want to… | Use |
25+
|---|---|
26+
| Format/validate DAX from .NET code | [NuGet package `Dax.Formatter`](nuget) |
27+
| Format DAX from an AI assistant with zero setup | [MCP Server (HTTP)](mcp-http) |
28+
| Run the MCP server locally as a process | [MCP Server (stdio)](mcp-stdio) |
29+
| Read the source, file issues, or contribute | [GitHub repository](github) |
30+
31+
> Both MCP servers expose the same single tool, `format_dax`, and call the same DAX Formatter service. The HTTP server is remote and hosted by SQLBI; the stdio server runs on your machine.

_mydocs/dax-formatter/mcp-http.md

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
---
2+
layout: page
3+
title: MCP Server (HTTP)
4+
menu_title: MCP Server (HTTP)
5+
published: true
6+
order: /1
7+
---
8+
The DAX Formatter **MCP Server (HTTP)** is a remote [Model Context Protocol](https://modelcontextprotocol.io) server hosted by SQLBI. It lets AI clients and agents format and validate DAX through a single tool, `format_dax`, without installing anything locally.
9+
10+
- **Transport**: Streamable HTTP (stateless) at `/mcp`.
11+
- **Tool**: `format_dax` formats (and thereby validates) one or more DAX expressions.
12+
- **Authentication**: none. The server is open and anonymous.
13+
14+
> The server does not format DAX itself. All formatting is done server-side by the DAX Formatter service; this endpoint is just the MCP transport and schema around it.
15+
16+
## Server URL
17+
18+
The only value you ever need to paste into your MCP client is the **Server URL**:
19+
20+
```
21+
https://api.daxformatter.com/mcp
22+
```
23+
24+
No account, API key, or login is required. Once the server is added, just ask your assistant to *"format this DAX"*.
25+
26+
## Visual Studio Code
27+
28+
[![Install in VS Code](https://img.shields.io/badge/VS_Code-Install_DAX_Formatter-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://vscode.dev/redirect/mcp/install?name=DaxFormatter&config=%7B%22type%22%3A%22http%22%2C%22url%22%3A%22https%3A%2F%2Fapi.daxformatter.com%2Fmcp%22%7D)
29+
[![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install_DAX_Formatter-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://insiders.vscode.dev/redirect/mcp/install?name=DaxFormatter&config=%7B%22type%22%3A%22http%22%2C%22url%22%3A%22https%3A%2F%2Fapi.daxformatter.com%2Fmcp%22%7D&quality=insiders)
30+
31+
Click a badge above — VS Code opens and asks you to confirm. Alternatively, add it from the terminal:
32+
33+
```bash
34+
code --add-mcp "{\"name\":\"DaxFormatter\",\"type\":\"http\",\"url\":\"https://api.daxformatter.com/mcp\"}"
35+
```
36+
37+
## Claude (Desktop and Code)
38+
39+
In **Claude Desktop**:
40+
41+
1. Open **Customize → Connectors → Add custom connector**.
42+
2. Give it a name (e.g. `DaxFormatter`) and paste the **Server URL** above.
43+
3. Click **Save**.
44+
45+
The `format_dax` tool is now available in chat. The same connector is automatically shared with **Claude Code**, so you set it up once for both.
46+
47+
You can also add it from the Claude Code terminal:
48+
49+
```bash
50+
# -s user enables it in every project; omit -s for the current project only
51+
claude mcp add -s user -t http DaxFormatter https://api.daxformatter.com/mcp
52+
53+
# check it was added and connected
54+
claude mcp get DaxFormatter
55+
```
56+
57+
## Codex (app and CLI)
58+
59+
In the **Codex app**:
60+
61+
1. Open **Settings → Integrations → MCP servers → Add**.
62+
2. Choose the **streamable HTTP / URL** type, give it a name (e.g. `DaxFormatter`), and paste the **Server URL** above.
63+
3. Leave **Bearer token** and **Headers** empty — DAX Formatter needs no login.
64+
4. Click **Save**.
65+
66+
The app and the CLI share the same settings, so this also covers the **Codex CLI**. From the terminal:
67+
68+
```bash
69+
# add globally; available in every project
70+
codex mcp add DaxFormatter --url https://api.daxformatter.com/mcp
71+
72+
# check it was added and connected
73+
codex mcp get DaxFormatter
74+
codex mcp list
75+
```
76+
77+
Both the app and the CLI write the same entry to `~/.codex/config.toml` (Windows: `%USERPROFILE%\.codex\config.toml`), which you can also edit by hand:
78+
79+
```toml
80+
[mcp_servers.DaxFormatter]
81+
enabled = true
82+
url = "https://api.daxformatter.com/mcp"
83+
approval_mode = "approve" # set to skip the per-call approval prompt
84+
```
85+
86+
## Any other MCP client
87+
88+
Most MCP-aware tools read a standard `.mcp.json` file. Create one where your client expects it (commonly at the root of your project) with:
89+
90+
```json
91+
{
92+
"mcpServers": {
93+
"DaxFormatter": {
94+
"type": "http",
95+
"url": "https://api.daxformatter.com/mcp"
96+
}
97+
}
98+
}
99+
```
100+
101+
If your client uses a different field name for the URL or a settings UI instead of a file, just point it at the **Server URL** with transport type **HTTP (streamable)** and no authentication.
102+
103+
## Related
104+
105+
- [MCP Server (stdio)](mcp-stdio) — the local sibling of this server, run through `npx`.
106+
- [NuGet package `Dax.Formatter`](nuget) — the .NET client for the same service.

_mydocs/dax-formatter/mcp-stdio.md

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
---
2+
layout: page
3+
title: MCP Server (stdio)
4+
menu_title: MCP Server (stdio)
5+
published: true
6+
order: /2
7+
---
8+
The DAX Formatter **MCP Server (stdio)** is a local [Model Context Protocol](https://modelcontextprotocol.io) server, published as the npm package [`@sqlbi/daxformatter-mcp`](https://www.npmjs.com/package/@sqlbi/daxformatter-mcp). Your AI client launches it as a local process (over standard input/output) and uses its single tool, `format_dax`, to format and validate DAX.
9+
10+
- **Package**: [`@sqlbi/daxformatter-mcp`](https://www.npmjs.com/package/@sqlbi/daxformatter-mcp) on npm
11+
- **Transport**: stdio (the client spawns the server as a child process)
12+
- **Tool**: `format_dax` formats and validates DAX expressions, reporting syntax errors with line and column information.
13+
- **Requirements**: Node.js 18 or later
14+
- **License**: MIT
15+
- **Source**: [github.com/sql-bi/DaxFormatter](https://github.com/sql-bi/DaxFormatter) (directory `mcp`)
16+
17+
> Like the HTTP MCP server, this package does not format DAX locally: it forwards expressions to the DAX Formatter service, so an internet connection is required. Choose this stdio server when your client launches MCP tools as local processes; choose the [HTTP server](mcp-http) when you prefer a hosted endpoint with nothing to install.
18+
19+
The server runs **locally on your machine**: no install step, no account, no API key, no login. Find your app below, follow the short steps, and afterwards just ask your assistant to *"format this DAX"*. There is nothing to install ahead of time: the configurations below run the latest version on demand with `npx`.
20+
21+
## Visual Studio Code
22+
23+
[![Install in VS Code](https://img.shields.io/badge/VS_Code-Install_DAX_Formatter-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://vscode.dev/redirect/mcp/install?name=DaxFormatter&config=%7B%22type%22%3A%22stdio%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40sqlbi%2Fdaxformatter-mcp%22%5D%7D)
24+
[![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install_DAX_Formatter-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://insiders.vscode.dev/redirect/mcp/install?name=DaxFormatter&config=%7B%22type%22%3A%22stdio%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40sqlbi%2Fdaxformatter-mcp%22%5D%7D&quality=insiders)
25+
26+
Click a badge above: VS Code opens and asks you to confirm. That's it. Alternatively, add it from the terminal:
27+
28+
```bash
29+
code --add-mcp "{\"name\":\"DaxFormatter\",\"type\":\"stdio\",\"command\":\"npx\",\"args\":[\"-y\",\"@sqlbi/daxformatter-mcp\"]}"
30+
```
31+
32+
## Claude (Desktop and Code)
33+
34+
In **Claude Desktop**, add it through the config file:
35+
36+
1. Open **Settings → Developer → Edit Config** to reveal `claude_desktop_config.json`.
37+
2. Inside `mcpServers`, add the standard `DaxFormatter` entry shown in [Any other MCP client](#any-other-mcp-client) below.
38+
3. Restart Claude Desktop, then confirm the server appears under **Settings → Developer**.
39+
40+
The `format_dax` tool is now available in chat. The same connector is automatically shared with **Claude Code**, so you set it up once for both.
41+
42+
You can also add it from the Claude Code terminal:
43+
44+
```bash
45+
# -s user enables it in every project; omit -s for the current project only
46+
claude mcp add -s user DaxFormatter -- npx -y @sqlbi/daxformatter-mcp
47+
48+
# check it was added
49+
claude mcp get DaxFormatter
50+
```
51+
52+
## Codex (app and CLI)
53+
54+
In the **Codex app**:
55+
56+
1. Open **Settings → Integrations → MCP servers → Add**.
57+
2. Choose the **command (STDIO)** type and give it a name (e.g. `DaxFormatter`).
58+
3. Set the command to `npx`, then use **Add argument** to add the two arguments separately: first `-y`, then `@sqlbi/daxformatter-mcp`.
59+
4. Click **Save**.
60+
61+
The `format_dax` tool is now available in your threads. The app and the CLI share the same settings, so this also covers the **Codex CLI** and IDE extension.
62+
63+
You can also add it from the terminal:
64+
65+
```bash
66+
# add it to the user-level Codex configuration (available in every project)
67+
codex mcp add DaxFormatter -- npx -y @sqlbi/daxformatter-mcp
68+
69+
# check it was added
70+
codex mcp get DaxFormatter
71+
codex mcp list
72+
```
73+
74+
Both the app and the CLI write the same entry to `~/.codex/config.toml` (Windows: `%USERPROFILE%\.codex\config.toml`), which you can also edit by hand:
75+
76+
```toml
77+
[mcp_servers.DaxFormatter]
78+
command = "npx"
79+
args = ["-y", "@sqlbi/daxformatter-mcp"]
80+
```
81+
82+
> To scope the server to one repository, put the same table in a project-scoped `.codex/config.toml` at the repo root instead. Codex loads it only for **trusted** projects and prompts for trust on first use.
83+
84+
## Any other MCP client
85+
86+
Don't see your app above? Most MCP-aware tools read a standard JSON config. Add this entry to your client's configuration file, or to a `.mcp.json` at the root of a project to share it with everyone working on that repo:
87+
88+
```json
89+
{
90+
"mcpServers": {
91+
"DaxFormatter": {
92+
"command": "npx",
93+
"args": ["-y", "@sqlbi/daxformatter-mcp"]
94+
}
95+
}
96+
}
97+
```
98+
99+
If your client uses a settings UI instead of a file, configure a **stdio** server with command `npx` and arguments `-y @sqlbi/daxformatter-mcp`.
100+
101+
## What it does
102+
103+
The server exposes a single tool, **`format_dax`**. Just ask your assistant to format or check some DAX and it will use it:
104+
105+
- Formats one or more DAX expressions in a single call.
106+
- Reports syntax errors with their line and column, so the same call both **formats** and **validates** (an expression that can't be parsed comes back unformatted, with the errors).
107+
- Optional formatting controls: line style, spacing, and the list/decimal separators.
108+
109+
You may want to specify the use of format_dax to avoid the agent trying to format DAX itself.
110+
111+
## Privacy
112+
113+
Your DAX is sent to the DAX Formatter web service (`daxformatter.com`), where the formatting happens. If you provide server or database names, they are **SHA-256 hashed** before being sent: they never leave your machine in clear text.
114+
115+
## Related
116+
117+
- [MCP Server (HTTP)](mcp-http) — the hosted, remote sibling of this server.
118+
- [NuGet package `Dax.Formatter`](nuget) — the .NET client for the same service.

0 commit comments

Comments
 (0)