Skip to content

Faserdka/tflex-codex-mcp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

T-FLEX Codex MCP

Local MCP tooling for controlling T-FLEX CAD from Codex or any MCP-compatible client.

Platform MCP License

T-FLEX Codex MCP connects an AI coding assistant to a running T-FLEX CAD session. It contains:

  • a dependency-free Node.js MCP server;
  • a managed T-FLEX plugin that exposes a localhost bridge;
  • Windows GUI fallback tools for focusing windows, screenshots, clicks, hotkeys, and typing;
  • install and configuration examples that keep local paths outside the repository.

What It Can Do

  • Open and inspect the active T-FLEX document.
  • List, create, and update document variables.
  • Rebuild, save, save as, and export documents.
  • Execute short C# automation snippets inside the active T-FLEX document.
  • Launch T-FLEX CAD and fall back to GUI control when API automation is not enough.

How It Works

flowchart LR
    A["Codex or MCP client"] --> B["Node MCP server"]
    B --> C["localhost bridge<br/>http://127.0.0.1:38517/command"]
    C --> D["T-FLEX managed plugin"]
    D --> E["Active T-FLEX CAD document"]
    B --> F["Windows GUI fallback"]
Loading

Requirements

  • Windows.
  • T-FLEX CAD 17 or compatible installation.
  • Node.js 18 or newer.
  • Visual Studio or Build Tools capable of building .NET Framework 4.7.2 projects.
  • Permission to copy the bridge plugin into the T-FLEX installation directory.

Repository Layout

bridge/
  BridgePlugin.cs          T-FLEX plugin entry point
  BridgeServer.cs          localhost HTTP bridge
  TflexOperations.cs       T-FLEX automation commands
  TflexCodexBridge.csproj  .NET Framework plugin project
  TflexCodexBridge.tfa     T-FLEX plugin descriptor
mcp/
  server.js                MCP server
  package.json             Node package metadata
  run-tflex-codex-mcp.cmd  Windows launcher
examples/
  codex-mcp.example.json   MCP client configuration example
install-tflex-plugin.ps1   Plugin installer

Quick Start

You can either use a pre-compiled release or build from source.

Option A: Using a pre-compiled release

  1. Download the latest tflex-codex-mcp-release.zip from the GitHub Releases page and extract it.
  2. Open PowerShell as Administrator (if T-FLEX is in Program Files), navigate to the extracted folder, and run:
.\install-tflex-plugin.ps1
  1. Skip to step 4 below (Start T-FLEX CAD).

Option B: Building from source

1. Clone the repository

git clone https://github.com/Faserdka/tflex-codex-mcp.git
cd tflex-codex-mcp

2. Build the T-FLEX bridge

Open bridge/TflexCodexBridge.csproj in Visual Studio or build it with MSBuild.

If T-FLEX is installed somewhere other than the default location, pass TflexCadDir:

msbuild bridge\TflexCodexBridge.csproj /p:Configuration=Release /p:TflexCadDir="D:\Apps\T-FLEX CAD 17\Program"

The default path is:

C:\Program Files\T-FLEX CAD 17\Program

3. Install the bridge plugin

Run PowerShell as Administrator if your T-FLEX installation is under Program Files.

.\install-tflex-plugin.ps1

For a custom T-FLEX installation path:

.\install-tflex-plugin.ps1 -TflexRoot "D:\Apps\T-FLEX CAD 17"

4. Start T-FLEX CAD

Launch T-FLEX CAD. The bridge plugin should auto-start and listen on:

http://127.0.0.1:38517/command

5. Run the MCP server

cd mcp
npm start

or:

node .\server.js

6. Configure your MCP client

Copy examples/codex-mcp.example.json into your MCP client's configuration and replace:

C:\Path\To\tflex-codex-mcp\mcp\server.js

with the absolute path on your machine.

MCP Tools

T-FLEX bridge tools

  • tflex_bridge_ping
  • tflex_bridge_call
  • tflex_active_document
  • tflex_open_document
  • tflex_list_variables
  • tflex_set_variable
  • tflex_create_variable
  • tflex_rebuild
  • tflex_save
  • tflex_save_as
  • tflex_export
  • tflex_execute_csharp
  • tflex_launch

GUI fallback tools

  • gui_list_windows
  • gui_focus_window
  • gui_screenshot_window
  • gui_click
  • gui_hotkey
  • gui_type_text

Environment Variables

Variable Default Description
TFLEX_BRIDGE_URL http://127.0.0.1:38517/command Local bridge endpoint exposed by the T-FLEX plugin.
TFLEX_MCP_TMP OS temp directory Temporary folder for screenshots and helper scripts.
TFLEX_EXE_PATH C:\Program Files\T-FLEX CAD 17\Program\TFlexCad.exe Optional T-FLEX executable path used by tflex_launch.

Example Requests

Ask your MCP client:

Check whether the T-FLEX bridge is running.
List variables in the active T-FLEX document.
Create a variable named Width with value 120 and rebuild the model.
Export the active document as STEP to C:\Temp\part.stp.

Troubleshooting

The MCP server starts, but T-FLEX commands fail

Make sure T-FLEX CAD is running and the bridge plugin is installed. Then check:

Invoke-RestMethod -Method Post `
  -Uri http://127.0.0.1:38517/command `
  -ContentType application/json `
  -Body '{"command":"ping","args":{}}'

Visual Studio cannot find T-FLEX assemblies

Build with a custom TflexCadDir:

msbuild bridge\TflexCodexBridge.csproj /p:TflexCadDir="C:\Your\T-FLEX\Program"

The installer cannot write into Program Files

Run PowerShell as Administrator or install to a T-FLEX location where your user account has write permission.

Safety Notes

The bridge listens only on 127.0.0.1. It is intended for local automation on a trusted machine. The tflex_execute_csharp tool compiles and runs C# code inside the T-FLEX process, so expose this MCP server only to clients you trust.

License

MIT. See LICENSE.

About

Local MCP server and T-FLEX CAD bridge for AI-assisted CAD automation

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors