|
| 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 | +[](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 | +[](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