Autodesk CAD MCP & RAG Assistant
Autodesk CAD MCP & RAG Assistant ๐
An enterprise-grade agentic microservice bridging high-speed C++ 3D geometry evaluation with Python (FastAPI), Anthropic's Model Context Protocol (MCP), and a RAG (Retrieval-Augmented Generation) knowledge engine grounded on Autodesk APIs (Fusion 360, APS / Forge, Revit, and Inventor).
๐ Key Highlights
Model Context Protocol (MCP) JSON-RPC 2.0: Full compliance with the Anthropic open standard, enabling autonomous agents (Claude Desktop, local LLMs) to discover tools via
tools/listand invoke CAD calculations viatools/call.Native C++ Geometry Core: Offloads compute-heavy 3D mesh evaluation (bounding volumes, surface areas, and extents) to a compiled C++17 shared library (
geometry.dll/libgeometry.so) via zero-overheadctypes.Zero-Crash Resilience: Built-in high-performance pure-Python fallback path ensures uninterrupted service even when dynamic libraries are unavailable.
Autodesk Domain RAG Index: In-memory semantic vector and keyword retrieval grounding LLMs on official Autodesk APIs (Fusion 360
ExtrudeFeature, APSModel Derivative, RevitBoundingBoxXYZ, InventorMassProperties), eliminating hallucinations.Dual Interface: Exposes standardized MCP JSON-RPC (
/mcp) and interactive OpenAPI/Swagger REST endpoints (/api/v1/...).Production SDLC: 100% test coverage with
pytest, parameterized parity checks between C++ and Python engines, and a multi-OS GitHub Actions CI/CD matrix.
๐ System Architecture
+-----------------------------------+
| AI Host / Autonomous Agent |
| (Claude Desktop / Cursor / LLM)|
+-----------------------------------+
|
| JSON-RPC 2.0 (MCP Protocol)
v
+-----------------------------------------------------------------------------------+
| FastAPI Microservice (server/main.py) |
| |
| [ Endpoint: /mcp ] [ Endpoint: /api/v1/geometry ] |
| MCP Protocol router Direct REST CAD calculations |
| |
| [ Endpoint: /api/v1/rag ] [ Endpoint: / ] |
| Vector documentation search Health check & C++ engine telemetry |
+-----------------------------------------------------------------------------------+
| |
| |
v v
+-----------------------------+ +-----------------------------------+
| Semantic RAG Engine | | Native C++ Geometry Bridge |
| (server/rag_engine.py) | | (server/mcp_tools.py) |
| | | |
| - Tokenization & Scoring | | ctypes Foreign Function Interface|
| - Autodesk API Knowledge | +-----------------------------------+
| (Fusion, APS, Revit) | |
+-----------------------------+ v
| +-----------------------------------+
v | Compiled C++ Geometry Core |
data/autodesk_docs.json | (core/geometry_engine.cpp) |
| |
| - SIMD / O3 Optimized Loops |
| - Bounding Volume & Surface Area |
| - Extents & Centroid Math |
+-----------------------------------+๐ Repository Structure
autodesk-cad-mcp-agent/
โ
โโโ core/
โ โโโ geometry_engine.cpp # High-speed C++ geometry evaluation core
โ โโโ CMakeLists.txt # CMake build configuration for shared library
โ
โโโ server/
โ โโโ __init__.py # Python package initialization
โ โโโ main.py # FastAPI REST & MCP JSON-RPC 2.0 Server
โ โโโ rag_engine.py # Semantic RAG retrieval engine
โ โโโ mcp_tools.py # MCP tool definitions & C++ ctypes bridge
โ
โโโ tests/
โ โโโ __init__.py # Tests package initialization
โ โโโ test_geometry.py # Pytest suite for geometry math & parity
โ โโโ test_mcp_api.py # Pytest suite for REST & MCP endpoints
โ
โโโ data/
โ โโโ autodesk_docs.json # Autodesk API & CAD engineering knowledge base
โ
โโโ scripts/
โ โโโ build.bat # 1-click Windows compilation script (MSVC/g++)
โ
โโโ .github/
โ โโโ workflows/ci.yml # Multi-OS GitHub Actions CI/CD matrix
โ
โโโ requirements.txt # Production and test Python dependencies
โโโ Makefile # Cross-platform build automation
โโโ .gitignore # Git ignore configuration
โโโ README.md # Comprehensive project documentationโก Quickstart Guide
Prerequisites
Python: Version 3.10 or higher
C++ Compiler:
Windows: MSVC 2019/2022 (Build Tools) or MinGW
g++Linux:
g++(GCC 9+)macOS:
clang++(Apple Clang)
Step 1: Clone Repository
git clone https://github.com/MAvinash24/autodesk-cad-mcp-agent.git
cd autodesk-cad-mcp-agentStep 2: Install Python Dependencies
pip install -r requirements.txtStep 3: Compile the C++ Engine
On Windows:
Run the included 1-click build batch script (automatically detects MSVC cl or g++):
scripts\build.batOr manual MSVC compile:
cl /O2 /LD /EHsc core\geometry_engine.cpp /Fe:geometry.dllOn Linux:
g++ -O3 -shared -fPIC -o libgeometry.so core/geometry_engine.cppOn macOS:
clang++ -O3 -shared -fPIC -o libgeometry.dylib core/geometry_engine.cppStep 4: Run the Microservice
python server/main.pyThe server will bind to http://127.0.0.1:8000.
Interactive Swagger Documentation: http://127.0.0.1:8000/docs
ReDoc Documentation: http://127.0.0.1:8000/redoc
MCP JSON-RPC Endpoint:
http://127.0.0.1:8000/mcp
๐งช Running Automated Tests
Run the full test suite with verbose reporting:
pytest tests/ -vTest Coverage Summary:
test_geometry.py: Validates unit cubes, bounding extents, empty arrays, degenerate single-point inputs, and strict parity between native C++ and pure-Python execution paths.test_mcp_api.py: Validates health telemetry, REST endpoints, MCPinitialize,ping,tools/list,tools/call, and standardized JSON-RPC error codes (-32601,-32602).
๐ Connecting to Claude Desktop / MCP Clients
To use this CAD assistant inside Claude Desktop, add the server to your claude_desktop_config.json:
{
"mcpServers": {
"autodesk-cad-agent": {
"command": "python",
"args": ["-m", "server.main"]
}
}
}Once connected, Claude can autonomously reason:
"Claude, analyze this 3D bracket mesh with vertices
[0,0,0, 10,5,2]and find the Fusion 360 API class to extrude it."
Claude will:
Invoke
calculate_cad_mesh_metricsvia MCP to compute exact volume and surface area.Invoke
search_autodesk_api_knowledgeto retrieve theExtrudeFeatureInputspecification.Return synthesized, hallucination-free CAD automation code.
๐ก API Reference & Usage Examples
1. Health Check & Engine Telemetry
GET /
curl -X GET http://127.0.0.1:8000/Response:
{
"status": "healthy",
"service": "Autodesk CAD MCP + RAG Assistant",
"version": "1.0.0",
"geometry_engine": {
"is_native_cpp": true,
"engine_mode": "c++_native",
"library_path": "C:\\...\\geometry.dll"
},
"knowledge_base_count": 6,
"supported_protocols": ["MCP JSON-RPC 2.0", "REST / HTTP"]
}2. High-Speed Geometry Calculation (REST)
POST /api/v1/geometry/calculate
curl -X POST http://127.0.0.1:8000/api/v1/geometry/calculate \
-H "Content-Type: application/json" \
-d '{"vertices": [0.0, 0.0, 0.0, 10.0, 5.0, 2.0]}'Response:
{
"status": "success",
"metrics": {
"bounding_volume": 100.0,
"surface_area": 160.0,
"vertex_count": 2,
"engine": "c++_native"
}
}3. Autodesk API RAG Retrieval (REST)
GET /api/v1/rag/search?query=extrude+fusion+volume
curl -X GET "http://127.0.0.1:8000/api/v1/rag/search?query=extrude+fusion+volume&top_k=2"Response:
{
"query": "extrude fusion volume",
"count": 2,
"documents": [
{
"id": "doc-01",
"title": "Autodesk Fusion 360 API - ExtrudeFeature & Bounding Calculation",
"text": "The ExtrudeFeatureInput class in the Autodesk Fusion 360 API allows programmatic generation of solid bodies...",
"relevance_score": 0.5833,
"matched_keywords": ["extrude", "fusion", "volume"]
}
]
}4. Model Context Protocol: tools/list (JSON-RPC 2.0)
POST /mcp
curl -X POST http://127.0.0.1:8000/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc": "2.0", "id": 1, "method": "tools/list", "params": {}}'5. Model Context Protocol: tools/call (JSON-RPC 2.0)
POST /mcp
curl -X POST http://127.0.0.1:8000/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/call",
"params": {
"name": "calculate_cad_mesh_metrics",
"arguments": {
"vertices": [0.0, 0.0, 0.0, 2.0, 2.0, 2.0]
}
}
}'Response:
{
"jsonrpc": "2.0",
"id": 2,
"result": {
"content": [
{
"type": "text",
"text": "{\"bounding_volume\": 8.0, \"surface_area\": 24.0, \"vertex_count\": 2, \"engine\": \"c++_native\"}"
}
]
},
"error": null
}๐ License
This project is open-source and licensed under the MIT License.