MCP Server#

The Dlubal MCP server lets AI clients such as Claude Code or Codex work with Dlubal applications (RFEM, RSTAB, RSECTION) using human-readable text. It translates the AI client’s requests into Dlubal API calls. On startup it detects which of the applications are installed and offers the matching tools.

You install it once, and your AI client starts it automatically whenever it needs it. No port, password or access token is involved.

Note

This installation guide is for Dlubal MCP version 1.0.17 and newer.

Warning

API requests made through AI tools count toward your monthly usage and may contribute to reaching your subscription limit (see Subscriptions & Pricing). These requests are monetized, even when using the local run of MCP server for Dlubal API.

What You Need First#

  • RFEM (or RSTAB / RSECTION) installed, with its API server switched on (see Starting Server).

  • Your Dlubal API key already saved on your PC. It is if you’ve used the Dlubal API before (see Authentication).

  • Python 3.11, 3.12 or 3.13 installed on your PC. It’s free from python.org. Python 3.14 is not supported yet.

  • VS Code with an AI assistant installed, such as Claude Code or Codex.

Install Dlubal MCP Package#

The setup is done once and takes about five minutes. No administrator rights are needed.

Open a Command Prompt: press the Windows key, type cmd and press Enter. Do not use PowerShell (the VS Code terminal, for example), because the commands below are written for the Command Prompt.

  1. Create a separate folder for the MCP server.

    This command creates a small, self-contained Python environment in your user folder. It is separate from the Dlubal application, so the application’s own Python cannot be affected:

    py -3.12 -m venv %USERPROFILE%\dlubal-mcp
    

    py is the Python launcher that is installed together with Python from python.org, and -3.12 selects the Python version. Run py -0 to list the versions installed on your PC, and use 3.11, 3.12 or 3.13 in the command.

  2. Install the MCP server and the Dlubal API client into that folder.

    • dlubal-mcp is the MCP server, which lets the AI client talk to the Dlubal application.

    • dlubal.api is the Dlubal API client, which sends the commands to the application. Its version must match your application version: the second number is the same. Use 2.15 for RFEM 6.15, RSTAB 9.15 and RSECTION 1.15, 2.16 for 6.16 / 9.16 / 1.16, and so on.

    %USERPROFILE%\dlubal-mcp\Scripts\python.exe -m pip install dlubal-mcp "dlubal.api==2.15.*"
    

    The Dlubal application comes with its own copy of the API client, but it is kept inside the application’s Python and cannot be shared, so the MCP server gets its own copy.

  3. Note the path of the MCP server’s Python.

    The AI client needs to know which program to start whenever it needs Dlubal. That program is the python.exe in the new folder. This command prints its exact path. Copy it for the next section:

    echo %USERPROFILE%\dlubal-mcp\Scripts\python.exe
    

    The examples below show this path as C:\Users\<username>\dlubal-mcp\Scripts\python.exe.

After a Dlubal application update, for example to RFEM 6.16, run the command from step 2 again with the new version ("dlubal.api==2.16.*") and add --upgrade. Nothing else changes.

Connect to MCP Server#

Choose your AI client and add the configuration. From then on, you do not start the MCP server yourself: the AI client starts it in the background whenever you ask it to work with a Dlubal application.

Claude Code#

  1. Open the folder you want to work in with VS Code (File → Open Folder). In that folder, create a file named .mcp.json and paste the path from step 3 of the installation:

    {
      "mcpServers": {
        "dlubal-mcp": {
          "command": "C:\\Users\\<username>\\dlubal-mcp\\Scripts\\python.exe",
          "args": ["-m", "dlubal_mcp", "--transport", "stdio"]
        }
      }
    }
    

    When you paste the path, double every backslash (\ becomes \\), because JSON requires it.

  2. Create a second file, .claude/settings.local.json, to enable the server and allow its tools. Use the New File button in the VS Code Explorer and type the name including .claude/. VS Code then also creates the .claude folder:

    {
      "enabledMcpjsonServers": ["dlubal-mcp"],
      "permissions": {
        "allow": ["mcp__dlubal-mcp"]
      }
    }
    

    mcp__dlubal-mcp allows all tools of the server to run without asking. To allow only some tools, list them individually instead, for example mcp__dlubal-mcp__read_rfem_results.

  3. Restart VS Code, or press Ctrl+Shift+P and run Developer: Reload Window, so that Claude Code reads the new files.

  4. Check the connection: type /mcp in the Claude Code chat. dlubal-mcp should be listed as connected. The first start can take a few seconds. If it shows Failed, check the python.exe path in .mcp.json.

  5. Ask Claude Code to use the Dlubal MCP, for example “Do you have access to Dlubal MCP?”

    Dlubal MCP server configured in Claude Code and tested in chat

    Example setup. The path of python.exe depends on where you created the virtual environment. In this example, the RFEM API server port was changed from the default 9000 to 9100, so RFEM_API_PORT is set to match. With the default port, leave out the env line.#

Codex#

  1. Open Codex Settings → MCP servers and add a new server of the STDIO type.

  2. Fill in:

    • Command to launch: the path from step 3 of the installation, for example C:\Users\<username>\dlubal-mcp\Scripts\python.exe

    • Arguments: -m, dlubal_mcp, --transport, stdio, each as a separate argument

    • Environment variables: leave empty, unless your application’s API server does not use the default port (see Configuration)

  3. Save, then ask Codex to use the Dlubal MCP.

    Dlubal MCP server configured in Codex settings and tested in chat

    Example setup. The path of python.exe depends on where you created the virtual environment. In this example, the RFEM API server port was changed from the default 9000 to 9100, so RFEM_API_PORT is set to match. With the default port, leave the environment variables empty.#

Alternatively, add the server to the Codex configuration file %USERPROFILE%\.codex\config.toml:

[mcp_servers.dlubal-mcp]
command = 'C:\Users\<username>\dlubal-mcp\Scripts\python.exe'
args = ["-m", "dlubal_mcp", "--transport", "stdio"]
startup_timeout_sec = 30

If Codex reports a timeout when it starts the server, startup_timeout_sec gives it more time than the default of 10 seconds.

Configuration#

The MCP server connects to the gRPC API servers at these default addresses:

Application

Environment variables

Default

RFEM

RFEM_URL / RFEM_API_PORT

127.0.0.1 / 9000

RSTAB

RSTAB_URL / RSTAB_API_PORT

127.0.0.1 / 9001

RSECTION

RSECTION_URL / RSECTION_API_PORT

127.0.0.1 / 9002

If your application uses a different port, add the variable to the server configuration, for example in .mcp.json:

{
  "mcpServers": {
    "dlubal-mcp": {
      "command": "C:\\Users\\<username>\\dlubal-mcp\\Scripts\\python.exe",
      "args": ["-m", "dlubal_mcp", "--transport", "stdio"],
      "env": { "RFEM_API_PORT": "9100" }
    }
  }
}

In Codex, add env = { RFEM_API_PORT = "9100" } to the server section.

To offer only the typed tools and withhold the tools that run free-form Python scripts (run_rfem_script and others), set DLUBAL_MCP_ALLOW_SCRIPTS to false in the same way.