Forum Discussion

mustaphaben's avatar
mustaphaben
Advocate I
3 months ago
Solved

Power BI Modeling MCP with OpenAI Codex Desktop: connection to Power BI Desktop and Service

Hello everyone,   Has anyone successfully connected OpenAI Codex Desktop to Power BI using the Power BI Modeling MCP Server?   I would like to understand the required configuration and the curren...
  • Ritaf1983's avatar
    3 months ago

    Hi mustaphaben 

    There are currently two different Power BI MCP scenarios, and it is important not to mix them.

    The remote Power BI MCP server is mainly for querying existing semantic models in Power BI/Fabric. It can retrieve model schema, generate DAX queries and execute DAX queries against a published semantic model, but it is not the right tool for modifying the model. Microsoft documents the remote endpoint as `https://api.fabric.microsoft.com/v1/mcp/powerbi`, with Microsoft Entra OAuth authentication, Build permission on the semantic model, and the tenant setting “Users can use the Power BI Model Context Protocol server endpoint (preview)” enabled. It is currently a preview feature. The documented remote tools are query/metadata oriented, not model write operations.

    For model authoring and changes, you need the local Power BI Modeling MCP Server. This is the one that can connect to Power BI Desktop, Fabric semantic models, or PBIP/TMDL folders and perform modeling operations such as reading and modifying tables, columns, measures, relationships, calculation groups, roles, perspectives, translations, etc. It can also work with PBIP/TMDL projects, which is probably the better approach if you want source control and reviewable changes.

    For Codex Desktop specifically, I would not assume that the VS Code `mcp.json` configuration applies directly. Codex uses its own MCP configuration, typically in `~/.codex/config.toml` / `%USERPROFILE%\.codex\config.toml`, or through the Codex app MCP settings if exposed in the UI. Codex supports both stdio MCP servers and streamable HTTP MCP servers, including OAuth for HTTP servers.

    For the local Power BI Modeling MCP server, a Codex-style config would be closer to this:

    ```toml
    [mcp_servers.powerbi-modeling-mcp]
    command = "npx"
    args = ["-y", "@microsoft/powerbi-modeling-mcp@latest", "--start", "--readonly"]
    enabled = true
    startup_timeout_sec = 20
    tool_timeout_sec = 120
    default_tools_approval_mode = "prompt"
    ```

    I would start with `--readonly` to validate that Codex can see the server and read the model safely. After that, if you want to allow changes, remove `--readonly` or use the default read/write mode. The server supports confirmations before the first modification, and there is also a `--skipconfirmation` option, but I would avoid that unless you are working on a backed-up PBIP/project branch.

    Typical prompts after connecting would be something like:

    ```text
    Connect to '[PBIX file name]' in Power BI Desktop and list all tables, relationships and measures.
    ```

    or for PBIP/TMDL:

    ```text
    Open semantic model from PBIP folder 'C:\path\to\definition' and list the measures.
    ```

    For the remote Power BI MCP server, the Codex configuration would conceptually be:

    ```toml
    [mcp_servers.powerbi-remote]
    url = "https://api.fabric.microsoft.com/v1/mcp/powerbi"
    enabled = true
    default_tools_approval_mode = "prompt"
    ```

    Then authenticate through Codex’s MCP OAuth flow, for example with `codex mcp login powerbi-remote`, if the server and client complete the OAuth flow correctly. However, Microsoft’s current setup guide is written for VS Code/GitHub Copilot, so I would treat Codex Desktop compatibility as something to validate rather than assume as officially documented end-to-end.

    Known limitations/recommendations:

    The remote Power BI MCP server is for querying and insights, not direct model editing.

    The local Power BI Modeling MCP server is the relevant option for creating or modifying measures, relationships and model metadata.

    The local server can work with Power BI Desktop, Fabric semantic models and PBIP/TMDL folders.

    It cannot modify report pages, visuals, report layout, or diagram layout; it is focused on semantic model operations.

    For PBIP/TMDL, the safest workflow is: work locally in a Git branch, let Codex/MCP modify the TMDL, review the diff, validate in Power BI Desktop / Tabular Editor / deployment pipeline, and then deploy.

    For published Fabric/Power BI semantic models, write operations depend on the same permissions and constraints as external modeling tools/XMLA/modeling operations. I would not let an AI client make direct production changes without source control, backup and review.

    Also, because metadata, schema and possibly query results can be sent through the MCP client to the LLM provider, this needs a security/governance review before using it with sensitive models.

    So the practical answer is: yes, this should be feasible for local modeling with Codex if Codex can launch the stdio MCP server, but the most mature/documented path is still VS Code + GitHub Copilot. For Fabric/Service, use the remote MCP server only for querying, or use the local Modeling MCP server / PBIP/TMDL / deployment workflow for actual model changes.

    If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly