mcp3d

mcp3d

A local MCP server for parametric, manufacturing-focused CAD workflows using Build123d as the modeling engine and FastMCP for the protocol.

Category
访问服务器

README

mcp3d

A local MCP server for parametric, manufacturing-focused CAD workflows.

The server uses FastMCP for the Model Context Protocol and Build123d as its modeling engine.

Run

uv run mcp3d

It communicates through standard input/output, so diagnostic logging must always go to standard error.

Model-facing MCP documentation

The runtime documentation is deliberately more complete than this README:

  • Server instructions explain the create → inspect → revise → export loop.
  • Each MCP tool has a field-level description with valid operation shapes, ordering rules, revision semantics, diagnostics, and repair guidance.
  • The mcp3d://guide MCP resource supplies the complete model guide, including constrained-sketch and feature-graph examples. An agent should read it before it uses an unfamiliar feature type.

The authoritative source for the runtime documentation is tool_docs.py. This keeps the model-facing guidance versioned with the actual server implementation.

For new work, prefer the v1 feature graph below. The v0 box/through-hole form remains only for backwards compatibility.

v0 interface

  • part.apply creates or revises an immutable single-part revision.
  • part.analyze returns structured checks and PNG orthographic/isometric views.
  • part.export writes STEP and/or STL artifacts.

Views use shaded PyVista/VTK rendering with feature edges. If a local machine cannot create an off-screen OpenGL context, the server automatically falls back to its technical SVG projection rasterized as PNG and reports the selected renderer in the tool result.

For known headless environments where VTK may abort before it can raise an exception, run with MCP3D_RENDERER=technical to force the portable technical renderer. Normal local use remains PyVista-first.

part.apply returns one isometric image by default. Use render: {"views":["top","front"]} to request exactly those canonical views, or render: {"views":[]} when structured checks are sufficient. Use part.analyze for additional views after the initial revision.

The legacy v0 form supports a box base plus named through_holes features. All dimensions are millimetres.

Implementation architecture

The MCP adapter is deliberately thin. The internal dependency direction is:

server (FastMCP) → application (revisions) → cad / rendering / artifacts
  • application/ owns immutable revision creation, transactional updates, and in-memory local state.
  • cad/ owns Build123d compilation, its private build context, sketches, selectors, datum planes, and feature operations.
  • rendering/ owns PyVista, technical SVG fallback, and labelled sketch evidence; it returns neutral in-memory image bytes rather than FastMCP objects or filesystem paths.
  • server.py is the only production module that creates FastMCP ToolResult and image content blocks.

Rendering and sketch evidence are ephemeral: they are encoded directly into the MCP response and do not create files in .mcp3d. The server creates .mcp3d/artifacts/<part>/r<revision>/ only when part.export is explicitly called, and that directory contains the requested STEP and/or STL deliverables.

workspace.py remains as a small backwards-compatible shim for early callers; new internal code should use PartService and FeatureGraphCompiler directly.

v1.1 feature graph

part.apply also accepts a recipe with named operations. The implemented workflow is:

box → datum planes → sketches / constraint graphs → solid features
    → finishing, shell/draft, and replicated feature tools

Sketch geometry is authored in its support plane's local 2D coordinates. A tangent_arc requires two named line guides, a radius, and a deterministic solution.span ("short" or "long"). Profiles can be polygons or paths that incorporate named sketch entities. Request a sketch diagnostic with:

{"kind": "render_sketch", "sketch": "relief_sketch"}

Constraint graphs

Alongside direct line and deterministic tangent_arc geometry, a sketch can contain a constraint_graph. It owns named point, line, and circle entities; the solver materializes its lines/circles before ordinary sketch geometry is built. Coordinates are in the sketch plane's local millimetres.

{
  "geometry": [
    {"id": "p0", "kind": "point", "position": [0, 0]},
    {"id": "p1", "kind": "point", "position": [40, 3]},
    {"id": "bottom", "kind": "line", "start": "p0", "end": "p1"}
  ],
  "constraints": [
    {"id": "origin", "kind": "fixed", "target": "p0"},
    {"id": "horizontal", "kind": "horizontal", "target": "bottom"},
    {"id": "width", "kind": "distance", "a": "p0", "b": "p1", "value": 40}
  ]
}

Supported relations are fixed, coincident, horizontal, vertical, parallel, perpendicular, angle, distance, equal_length, radius, diameter, equal_radius, midpoint, and branch-explicit tangent_line_circle. A relation can refer to a point directly, a line's line.start/line.end, a circle's circle.center, or a projected external line where appropriate. The initial positions select the local solution branch. require_fully_constrained: true rejects a profile with remaining local degrees of freedom.

The revision report exposes solver status, local DOF/Jacobian rank, residuals per constraint, locally redundant constraints, and suspected conflict IDs. render_sketch returns a labelled image with entity/point names, dimensions, and solver status; it is the intended visual review loop before export.

Solid operations

The feature graph supports:

  • Base and reference: box, datum_plane (explicit, offset_from_face, rotate_about), sketch
  • Profile features: extrude, revolve, loft, sweep
  • Finishing: fillet, chamfer, shell, draft
  • Feature-tool replication: linear_pattern, polar_pattern

extrude, revolve, loft, and sweep generate named feature tools with an operation of "add" or "cut". Patterns copy that tool—not the whole current part—and their count includes the original source. sweep.path is "sketch_id.entity_id"; loft.sections is a list of closed-profile sketch ids.

Finishing operations use geometric queries evaluated at the exact operation, never B-rep edge indexes. A selector requires an expected cardinality, for example the four outer top edges of a box:

{
  "geom_type": "line",
  "at_extreme": {"axis": "z", "which": "max"},
  "expect": 4
}

Selectors also support parallel_to for edges, normal_to for faces, and at_extreme with mode: "touches" when containment in the extreme plane is not required. A mismatch fails explicitly as SELECTOR_EMPTY or SELECTOR_AMBIGUOUS rather than silently choosing a different edge.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选