Mastercam MCP Server
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Mastercam MCP Server Open bracket.mcam, regenerate all toolpaths, and post the G-code with a setup sheet"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Mastercam MCP Server
A Model Context Protocol server that lets AI agents drive Mastercam 2027: open parts, inspect geometry, build tools and toolpaths, regenerate, post G-code and produce setup sheets — in the Mastercam window in front of the user.
It is a standard MCP server, not tied to one AI vendor: it works with any MCP client (Claude Desktop, Claude Code,
Cursor, VS Code, Windsurf, OpenAI Codex CLI, Gemini CLI, LM Studio, ...) and any model that can call tools, including
local models (see examples/ollama_agent.py). Tested: Claude, and a 4B local Gemma model through Ollama.
Status: 1.0.2. Verified live on Mastercam 2027 Update 1 (29.1.193.0). See docs/FEATURES.md for the full feature map and roadmap (machine/control definitions, simulation, post editing, ...).
Architecture
MCP client ──stdio──> mastercam_mcp (Python, FastMCP)
│ JSON lines over a Windows named pipe
▼
Mastercam.exe ── McamMcp.dll (NET-Hook add-in, .NET 10)
runs each command on Mastercam's UI threadplugin/McamMcp— C# NET-Hook loaded by Mastercam. It serves two pipes:\\.\pipe\mastercam_mcp_<pid>(always, one per Mastercam process) and the shared\\.\pipe\mastercam_mcp(owned by the first Mastercam to start; the others take it over when it exits). A dialog watcher answers Mastercam message boxes that appear during a command (so a "Toolpath regeneration failed" box never hangs the agent) and returns their text to the client.mastercam_mcp— the Python MCP server: tool definitions, path policy, launcher, setup-sheet generator and therun_jobworkflow.
Related MCP server: solidworks-mcp
Install
From the release package (testers)
Requirements: Windows, Mastercam 2027, Python 3.10+ (no .NET SDK). Unzip mastercam-mcp-<version>.zip, close
Mastercam, then from that folder:
powershell -ExecutionPolicy Bypass -File .\install.ps1 -Startup -Client cursor,vscodeIt installs the server, copies the prebuilt add-in (approve the UAC prompt, or run from an elevated PowerShell), sets the
add-in to load with Mastercam and registers the server with the clients you name (claude-desktop, claude-code,
cursor, vscode, windsurf, codex, gemini, lmstudio; each file is backed up first). install.ps1 -Uninstall removes it.
See docs/TESTING.md for a first session and what to report.
From source
Requirements: Windows, Mastercam 2027, .NET 10 SDK, Python 3.10+. .\scripts\make-release.ps1 builds the release zip.
# 1. Python package
pip install -e .[test]
# 2. Build and install the add-in. Close Mastercam first (the DLL is locked while it runs).
# Copying into C:\Program Files\mcam needs administrator rights: run from an elevated PowerShell,
# or approve the UAC prompt. The script checks the installed DLL's hash and fails loudly if the copy did not happen.
.\scripts\install-plugin.ps1 # add -Startup to load the bridge every time Mastercam starts
.\scripts\install-plugin.ps1 -Uninstall
# 3. Check (with Mastercam running and the add-in loaded: Add-Ins > MCP Bridge)
python -m mastercam_mcp --checkWithout -Startup, load the bridge per session from Add-Ins > MCP Bridge; launch_mastercam starts
Mastercam and waits for the bridge.
MCP client configuration
The server is started by the client: command python, arguments -m mastercam_mcp. To register it:
python -m mastercam_mcp --configure cursor,vscode # any of: claude-desktop, claude-code, cursor, vscode,
# windsurf, codex, gemini, lmstudio (backs up each file)
python -m mastercam_mcp --print-config # the common "mcpServers" JSON block, for any other client
python -m mastercam_mcp --print-config codex # the block in that client's formatThe common block (Claude Desktop, Cursor, Windsurf, Gemini CLI, LM Studio and most others):
{
"mcpServers": {
"mastercam": {
"command": "python",
"args": ["-m", "mastercam_mcp"],
"env": { "MCAM_MCP_ALLOWED_DIRS": "C:\\CAM\\jobs" }
}
}
}VS Code (mcp.json) uses "servers" with "type": "stdio"; Codex uses [mcp_servers.mastercam] in config.toml.
Fewer tools. Some clients cap the number of tools, and small models choose better from a short list. Set
MCAM_MCP_TOOLS (or --tools) to core (about 25 tools, enough for a 2D part end to end), or to groups and tool names:
core,planes,wireframe. Groups: session, files, part, wireframe, planes, setup, tools, toolpaths, edit, check, output,
scripting. --configure ... --tools core writes it into the client config.
HTTP clients. For a client that connects to a URL instead of starting a program:
python -m mastercam_mcp --http serves http://127.0.0.1:8765/mcp (--port to change). It listens on this PC only;
there is no authentication, so do not expose it with --host unless a firewall or tunnel you control is in front of it.
Any model. examples/ollama_agent.py is a 90-line agent loop that connects a local Ollama model to the server, as a
reference for other harnesses.
Environment variables
Variable | Default | Meaning |
|
| Base pipe name (must match the add-in). |
| — | Pin the server to one Mastercam process ( |
|
| Default seconds per bridge call (long tools such as post/regenerate use more). |
| — |
|
| off |
|
| — | Extra file extensions |
|
| Tools to expose: |
| auto | Full path to |
Tools
Area | Tools |
Session |
|
Guidance |
|
Files |
|
Part |
|
Wireframe |
|
Planes |
|
Setup |
|
Tools |
|
Toolpaths |
|
Edit |
|
Output |
|
Workflow |
|
Scripting |
|
Notes for agents and integrators (the knowledge tool serves these and more to the agent):
Heights in
linkingare absolute unless the matching*_incrementalflag is set (Mastercam's own default for new operations is incremental). For drilling,feed_planeis the R plane.chainpicks curves that lie flat in the operation's tool plane (plane, else the active one), at any depth. If they are at several depths the call is refused until you givechain.depth(a Z in that plane, or"all") orentity_ids. Closed chains run clockwise seen from the plane, socomp_side: leftis outside andrightis inside.planeis the tool plane (top,front, ... or a plane name; on a horizontal machinefrontis usually B0). For holes,positionsandbolt_circleare in that plane's coordinates.bolt_circleis{diameter, count, start_angle, center, z}or a list of them.coolantisflood,mist,thruoroff.create_circle_millplunges at the hole center: use it on pre-drilled holes.create_helix_borecuts from solid.Taps need
threadsincreate_tool(threads per inch, or pitch in mm), otherwise they post a zero feed.New operations take the tool's H/D numbers unless
length_offset/diameter_offsetare given.Every create_* starts from the machine's default settings: Mastercam itself would copy the last operation of the same type (a plain drill after a tap came out as a tap). Only what you pass changes them.
Stock to leave is 0 unless given, and stepovers follow the tool (pocket 50%, facing 75%), so the depth asked for is the depth cut. Contour lead in/out lines and arcs are 100% of the tool diameter (
leadto change them,lead: falsefor none).post_errors: truefrompost_process/run_job: the post reported errors; do not run that NC file until they are explained.check_nc_filereviews posted G-code (F0, spindle off while cutting, H/D vs tool, rapids into the stock zone, travel, program end) and lists each tool's Z range, feeds and speeds.run_jobruns it on every NC file. It is not a simulation.Mastercam cannot move an operation into another group, so
move_operationswithgroup_idcopies and deletes: the operation gets a new id (new_idsin the result).Facing
across_overlap(default 50) /along_overlap(default 110) are percent of the tool diameter (Mastercam needs ≥ 50 to face a boundary). Inset_operation_parameters,CutParams.AcrossOverlap/AlongOverlapare raw distances in part units.get_operation_parametersdumps every parameter group of an operation;set_operation_parameterswrites any of them by path ({"EntryHelix.MaxRadius": 0.05}), so the structured tools are never a ceiling.Results may carry
mastercam_messages— dialogs Mastercam showed and how the bridge answered them. Aregenerated: false/warningresult means the operation exists but has no toolpath;post_processreports such operations asdirty_operations.
Safety
Every toolpath produced by automation must be verified (simulation, backplot, review) before it runs on a machine.
Save As and
run_jobkeep an existing.mcamunlessoverwriteis true. Posted NC files in the output folder are replaced.With several Mastercam windows open,
mastercam_statuslists them and the agent mustselect_mastercamthe right one.execute_csharpis off by default, in both the MCP server and the Mastercam add-in. It is on only whenMCAM_MCP_ALLOW_SCRIPTS=1is set for both (as a user environment variable:setx MCAM_MCP_ALLOW_SCRIPTS 1, then restart Mastercam and the MCP client). Enable it only for trusted clients: it runs arbitrary code inside Mastercam.Use
MCAM_MCP_ALLOWED_DIRSto fence file access to job folders.File tools only touch their own file types (Save As
.mcam, exports,.png,.html; NC readers only NC extensions, extendable withMCAM_MCP_NC_EXTENSIONS). The add-in's pipe accepts only the same Windows user.--httplistens on this PC only and rejects foreign Host headers and browser origins. See SECURITY.md.
Troubleshooting
Symptom | Fix |
| Start Mastercam and load Add-Ins > MCP Bridge (or install with |
Install says "Elevated copy failed" | The UAC prompt was declined or hidden. Run the script from an elevated PowerShell. |
Install says "Mastercam is running" | Close every Mastercam window; the add-in DLL is locked while it runs. |
A call timed out | Mastercam may be busy or showing a non-standard dialog. Look at its window; the command still runs and later calls continue normally. |
Commands go to the wrong Mastercam |
|
| The add-in and the server are different releases: close Mastercam and rerun |
| Curves exist at several depths; pass |
Anything else | Bridge log: |
Development
python -m pytest # protocol, server and workflow tests against a fake bridge (no Mastercam needed)
dotnet build plugin\McamMcp -c ReleaseLicense and trademarks
MIT (see LICENSE). Mastercam is a trademark of CNC Software, LLC. This project is independent and is not affiliated with or endorsed by CNC Software. It needs a licensed copy of Mastercam to do anything.
Available Tools
54 toolscheck_nc_fileARead-only
Review posted G-code before it runs: F0 feeds, cutting with the spindle off, H/D numbers that do not match the tool, rapids into the stock zone, moves outside the machine travel, missing program end; plus each tool's Z range, feeds and speeds and the program extents. A review aid, not a simulation.
Inputs: path (required), stock_top_z, travel_limits.
copy_operationsA
Duplicate operations with their geometry; the copies are regenerated. Returns new_ids.
Inputs: ids (required), group_id, name_suffix.
create_circle_millA
Circle mill round holes at the given centers (best for pre-drilled holes; it plunges at the center). For counterbores or holes cut from solid use create_helix_bore.
Inputs: depth (required), tool_number (required), circle_diameter (required), name, +23 more.
create_contourB
Create and regenerate a 2D contour toolpath in the active machine group. Closed chains run clockwise, so comp_side left cuts outside and right cuts inside. Lead in/out arcs and lines are sized to the tool.
Inputs: depth (required), tool_number (required), lead, name, +17 more.
create_drillB
Create and regenerate a drill/peck/tap/bore toolpath. Give entity_ids, arc_diameter, positions and/or bolt_circle.
Inputs: depth (required), tool_number (required), name, peck, +19 more.
create_facingB
Create and regenerate a facing toolpath over the chained boundary (usually the part outline).
Inputs: depth (required), tool_number (required), name, chain, +16 more.
create_geometryA
Create wireframe (all or nothing). Returns the new entity ids per shape, ready for chain={"entity_ids": [...]} or drilling by entity_ids. Rectangles are lines (and corner arcs) in a closed loop.
Inputs: entities (required), z, color, level, +1 more.
create_helix_boreB
Helix bore counterbores / round holes from solid with an end mill (helix down, then a finish circle).
Inputs: depth (required), tool_number (required), circle_diameter (required), name, +21 more.
create_machine_groupB
Create a machine group (this selects the machine, control definition and post processor).
Inputs: product, machine_definition.
create_planeA
Create a work/tool plane, e.g. a fixture face with its own work offset. On a horizontal machine B0 is usually base front, B90 right, B180 back, B270 left: check against the machine before posting.
Inputs: name (required), set, base, origin, +2 more.
create_pocketB
Create and regenerate a 2D pocket (closed chains; chains inside others are islands).
Inputs: depth (required), tool_number (required), name, chain, +16 more.
create_toolA
Create a tool in the open part (units follow the part). Its rpm/feeds become the default for toolpaths that use it.
Inputs: type (required), diameter (required), rpm, feed, +13 more.
create_toolpath_groupA
Create a toolpath group (e.g. one per setup or fixture side) and make it active: new operations go there.
Inputs: name (required), machine_group_id.
delete_geometryADestructive
Delete entities from the open part (never files). Operations chained to them keep their old toolpath until regenerated: regenerate_operations and check them afterwards.
Inputs: ids, level.
delete_operationsCDestructive
Delete operations by id.
Inputs: ids (required).
export_fileA
Export the part's geometry to a CAD file (e.g. STEP for a customer or a fixture designer). The open .mcam stays the current file.
Inputs: path (required), overwrite.
generate_setup_sheetB
Write a printable HTML setup sheet + operator run sheet (operations, tools, offsets, times, part image).
Inputs: output_path (required), notes, title, nc_files, +2 more.
get_cycle_timeBRead-only
Estimated machining time per operation and in total (seconds).
Inputs: ids.
get_extentsBRead-only
Bounding box of all geometry: min, max and size as [x, y, z].
Inputs: no named parameters.
get_operation_parametersBRead-only
All parameter groups of an operation with current values (names usable in set_operation_parameters).
Inputs: id (required), path.
get_part_infoBRead-only
Open file, units, geometry counts by type, bounding box, levels, machine groups and operation counts.
Inputs: no named parameters.
get_stateARead-only
What Mastercam is set to now: file, units, active machine/toolpath group, WCS / tool / construction planes (with work offsets), active level, selection count, operation and dirty-operation counts. Check it before creating geometry or operations: new operations go into the active group and take the current tool plane. The knowledge tool explains planes, chaining, linking and posting with measured facts.
Inputs: no named parameters.
import_operationsB
Import toolpath operations (with their tools and parameters) into the active machine group.
Inputs: path (required), ids, names, regenerate, +2 more.
knowledgeARead-onlyIdempotent
How to program Mastercam well with these tools: the master guide (default), one topic, or a search across all guides. Built from behaviour measured on Mastercam 2027.
Inputs: topic, search.
launch_mastercamA
Start Mastercam (if it is not running) and wait for the MCP Bridge add-in to answer.
Inputs: wait_seconds.
list_geometryBRead-only
List geometry entities (ids, type, level; arc centers/radii, line endpoints, point positions).
Inputs: level, limit, types, selected_only.
list_levelsBRead-only
Levels (layers) with names, entity counts and visibility.
Inputs: include_empty.
list_library_operationsBRead-only
List the operations and toolpath groups stored in an operation library / other Mastercam file.
Inputs: path (required).
list_library_toolsBRead-only
List the tools in a tool library or another Mastercam file.
Inputs: path (required).
list_machine_groupsBRead-only
Machine groups with machine definition, NC output folder, and toolpath groups.
Inputs: no named parameters.
list_operationsCRead-only
Operations in the Toolpaths Manager: id, name, type, tool, spindle/feeds, dirty/locked status.
Inputs: group_id.
list_planesBRead-only
Planes in the part (origin, X/Y/Z axes in world, work offset) and which is the current WCS / tool / construction plane.
Inputs: no named parameters.
list_toolsBRead-only
Tools defined in the current part (number, name, type, diameter, corner radius, lengths, offsets).
Inputs: group_id.
mastercam_statusARead-only
Start here. Is Mastercam running and is the MCP Bridge add-in answering? Returns versions, open file, units and, when several Mastercam windows are open, each instance so you can select_mastercam the right one. Before programming a part, read the knowledge tool's master guide (call knowledge with no arguments).
Inputs: no named parameters.
move_operationsB
Reorder operations (they keep their order among themselves). Returns the new order.
Inputs: ids (required), after, before, group_id.
new_fileADestructive
Start a new empty part. Unsaved changes in the current file are discarded.
Inputs: no named parameters.
open_fileADestructive
Open a part in Mastercam (unsaved changes in the current file are discarded unless merge=true).
Inputs: path (required), merge.
operation_statsBRead-only
Per operation: toolpath extents (min/max in WCS and world, so deepest Z and XY reach) and cycle time.
Inputs: ids.
post_processB
Post-process toolpaths to G-code with the machine group's post. Regenerates dirty operations first.
Inputs: ids, also_nci, output_dir.
read_nc_fileARead-only
Read (part of) a posted NC program or other text output to verify it.
Inputs: path (required), max_lines, start_line.
regenerate_operationsAIdempotent
Recalculate toolpaths. Returns regenerated ids, per-operation errors, and anything still dirty.
Inputs: ids, only_dirty.
run_jobA
One-shot CAD-to-CAM: open part (optionally into a template), machine group, stock, import operations, regenerate, save .mcam, post .nc and write the setup/run sheet. Returns every artifact path and a step log.
Inputs: part_path (required), output_dir (required), post, notes, +9 more.
run_native_setup_sheetC
Run Mastercam's own setup-sheet report (configured template) without its dialog.
Inputs: pdf, images.
save_fileA
Save the current file (Save As when path is given; existing files are kept unless overwrite=true).
Inputs: path, overwrite.
screenshotARead-only
Capture Mastercam's graphics window as an image.
Inputs: fit, view, save_to.
select_mastercamAIdempotent
Send all following commands to one specific Mastercam window (when several are open).
Inputs: pid.
set_active_groupAIdempotent
Make a toolpath group active (ids from list_machine_groups): new operations are added to it.
Inputs: group_id (required).
set_levelAIdempotent
Create, name, activate or show/hide a level.
Inputs: number (required), name, active, visible.
set_operation_parametersA
Change any operation parameters by path, then regenerate the operation.
Inputs: id (required), parameters (required).
set_output_folderC
Set where a machine group's NC files are written.
Inputs: folder (required), group_id.
set_planesBIdempotent
Set the current WCS / tool plane / construction plane. New operations take the tool plane; the WCS decides which coordinates are posted.
Inputs: all, wcs, tool_plane, construction_plane.
set_stockA
Define the mill stock of a machine group (bounding box of all solids / all entities, or an explicit box).
Inputs: max, min, mode, group_id.
update_operationB
Change an operation's name, spindle speed, feeds or H/D offset numbers (then it is regenerated).
Inputs: id (required), name, locked, feed_rate, +5 more.
update_planeAIdempotent
Move, renumber or rename a plane you created (system planes can only get a work offset).
Inputs: name (required), set, origin, new_name, +1 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 54 tools
Despite 54 tools, most have a clearly distinct resource+action target, and the descriptions actively disambiguate the risky pairs (create_circle_mill vs create_helix_bore, generate_setup_sheet vs run_native_setup_sheet, list_tools vs list_library_tools). There is residual overlap among the several 'what is the current state' tools (mastercam_status, get_state, get_part_info, list_operations) and between run_job and the individual step tools, but an agent can still choose correctly from the text.
The dominant convention is snake_case verb_noun (create_contour, set_planes, list_geometry, delete_operations), applied across nearly the whole surface. Minor deviations exist: bare nouns (knowledge, screenshot, operation_stats), noun-first names (mastercam_status), and 'new_file' where create_* would be expected, plus launch_mastercam/select_mastercam placing the server name in different positions.
54 tools is well past the point where an agent can reason about the surface at once, even though the CAD-to-CAM domain is genuinely broad and most tools are non-redundant. The set is sensibly grouped into lifecycle areas, but it would benefit from consolidation (e.g. run_job-style wrappers for common sequences).
Coverage is strong across the domain: session/file management, geometry, levels, planes, tools, toolpath operations, machine groups, stock, posting, NC verification, setup sheets and a one-shot job runner. Gaps remain around geometry modification/transforms (only create and delete), tool editing/library import, and machine-group removal, but these are workaroundable.
Maintenance
Related MCP Connectors
MCP server for your apps' tools and custom tools, plus hosted AI agents and approval-gated workflows
Build and run AI workflows, agents, data tables and 1000+ API integrations from any MCP client.
Your company's tools, memory and Automations for ChatGPT, Claude or any MCP agent. Open source.
Remote desktop MCP: let AI see, click, type and run terminal commands on your own Windows or Mac.
Related MCP Servers
- AlicenseBqualityCmaintenanceConnects AI coding agents to Autodesk Fusion 360 for CAD/CAM automation, exposing 84 tools for sketching, modeling, assembly, inspection, export, and G-code post-processing through any MCP-compatible client.85MIT
- AlicenseBqualityDmaintenanceEnables MCP clients like Claude to automate SOLIDWORKS 2025 and SOLIDWORKS CAM via COM, covering parts, assemblies, drawings, and CAM toolpaths. It generates real geometry, mass properties, and posted G-code files directly on disk.402MIT
- FlicenseNot gradedqualityAmaintenanceEnables AI assistants like Claude for Desktop or Cursor to control supported CAD applications through MCP, supporting drawing, layer and entity management, block operations, data export, and file/session control via natural language or unified tool calls.-
- FlicenseNot gradedqualityAmaintenanceEnables AI assistants like Claude Desktop or Cursor to control supported CAD applications through MCP, supporting drawing, layers, entities, blocks, files, exports, and complex multi-step CAD tasks via direct tool calls or natural language.-