Adapter Architecture
Learn how Conjure adapters work and how to build custom adapters for other CAD platforms.
Overview
Conjure uses a modular adapter architecture that allows it to integrate with different CAD platforms. Each adapter acts as a bridge between the Conjure server and the CAD application's API, translating high-level commands into platform-specific operations.
This guide explains how adapters work and provides instructions for building custom adapters for unsupported CAD platforms.
Adapter Architecture
High-Level Design
The Conjure system consists of three main components:
Interprets user requests and decides which CAD operations to perform
Provides REST API and WebSocket endpoints for operation execution, handles authentication and billing
Runs inside the CAD application, communicates with the server, executes operations using the CAD platform's API
Communication Flow
User → AI Assistant → Conjure Server → CAD Adapter → CAD Application
↓
MCP Protocol
↓
REST/WebSocket API
↓
Operation Commands
↓
Platform-Specific API Calls
Adapter Components
Each adapter consists of several key components:
1. API Client
Handles communication with the Conjure server:
- Authenticates using API key
- Sends operation requests to the server
- Receives and parses responses
- Handles errors and retries
- Manages WebSocket connections for real-time updates
2. Operation Engine
Executes CAD operations using the platform's API:
- Translates generic operations to platform-specific calls
- Manages document/design state
- Handles object selection and manipulation
- Validates inputs and constraints
- Provides operation history and undo support
3. User Interface
Provides visual feedback and controls:
- Connection status indicator
- Settings and configuration panel
- Operation log and history
- Usage statistics
- Error messages and notifications
4. Configuration Manager
Stores and manages adapter settings:
- API key storage (secure)
- Server URL and connection settings
- User preferences
- Platform-specific options
API Protocol
REST API Endpoints
Adapters communicate with the server using these endpoints:
POST /api/v1/operations/execute
Execute a single CAD operation
POST /api/v1/operations/batch
Execute multiple operations atomically
GET /api/v1/operations/history
Retrieve operation history
POST /api/v1/validate
Validate operation parameters before execution
GET /api/v1/account/usage
Get current usage statistics
Operation Request Format
{
"operation": "create_box",
"parameters": {
"width": 50.0,
"height": 30.0,
"depth": 20.0,
"position": [0, 0, 0]
},
"options": {
"units": "mm",
"auto_recompute": true
},
"context": {
"adapter_version": "1.0.0",
"platform": "freecad",
"platform_version": "0.21"
}
}
Building a Custom Adapter
Want to add Conjure support for a CAD platform that isn't currently supported? Here's how:
Step 1: Assess Platform Compatibility
Your target CAD platform should support:
- Scripting/API Access: Python, JavaScript, or another language
- Geometric Operations: Ability to create and modify 3D geometry
- Network Access: HTTP/HTTPS communication with external services
- Extension System: Add-ins, plugins, workbenches, or scripts
Step 2: Set Up Development Environment
- Clone the Conjure adapter template repository
- Install the CAD platform's SDK/API
- Set up a test environment with sample models
- Configure API access to the Conjure development server
Step 3: Implement Core Components
# Example Python implementation
import requests
class ConjureClient:
def __init__(self, api_key, server_url):
self.api_key = api_key
self.server_url = server_url
self.headers = {
'Authorization': f'Bearer {api_key}',
'Content-Type': 'application/json'
}
def execute_operation(self, operation, parameters):
response = requests.post(
f'{self.server_url}/api/v1/operations/execute',
headers=self.headers,
json={'operation': operation, 'parameters': parameters}
)
return response.json()
# Example operation handler
class OperationEngine:
def __init__(self, cad_api):
self.cad = cad_api
def create_box(self, width, height, depth, position):
# Translate to platform-specific API
box = self.cad.create_primitive('box')
box.width = width
box.height = height
box.depth = depth
box.position = position
return box
Operation Mapping
Map Conjure's generic operations to your platform's API:
Example Operation Mappings
| Conjure Operation | FreeCAD API | Fusion 360 API |
|---|---|---|
create_box |
Part.makeBox() |
features.extrudeFeatures.add() |
create_cylinder |
Part.makeCylinder() |
features.extrudeFeatures.add() |
boolean_union |
Part.fuse() |
features.combineFeatures.add() |
fillet |
Part.makeFillet() |
features.filletFeatures.add() |
Testing and Validation
Required Tests
- Unit Tests: Test individual operations in isolation
- Integration Tests: Test operation sequences and workflows
- API Tests: Verify correct server communication
- Error Handling: Test invalid inputs and edge cases
- Performance: Measure operation execution time
Test Suite Example
import pytest
def test_create_box(adapter):
"""Test box creation with valid parameters."""
result = adapter.create_box(
width=50.0,
height=30.0,
depth=20.0,
position=[0, 0, 0]
)
assert result.success == True
assert result.object_id is not None
def test_create_box_invalid_dimensions(adapter):
"""Test box creation with invalid dimensions."""
with pytest.raises(ValueError):
adapter.create_box(
width=-10.0, # Invalid negative dimension
height=30.0,
depth=20.0
)
Publishing Your Adapter
Once your adapter is complete and tested:
- Submit for review: Contact the Conjure team to review your adapter
- Documentation: Write user documentation for installation and usage
- Package: Create installation packages for each platform
- Publish: List on the Conjure adapter marketplace
- Support: Provide ongoing maintenance and bug fixes
Resources for Adapter Developers
Adapter Template Repository
Boilerplate code and examples to get started quickly
github.com/lautrek/conjure-adapter-templateExample Adapters
Study the FreeCAD and Fusion 360 reference implementations
github.com/lautrek/conjure/clientsSupported Platforms Roadmap
The Conjure team is actively working on adapters for these platforms:
Want to help? Join the discussion about which platforms to prioritize next.