Skip to main content
Glama
luiscarone

Fusion 360 API MCP Server

by luiscarone
README.md
# Fusion 360 API MCP Server

A comprehensive Model Context Protocol (MCP) server that provides full access to the Autodesk Fusion 360 Python API documentation, code generation, and API querying capabilities with **automatic index updates**.

## Features

This MCP server provides **9 powerful tools** for working with the Fusion 360 API:

### Documentation Tools
- **search_fusion_docs** - Search official Fusion 360 documentation on help.autodesk.com
- **fetch_fusion_doc** - Fetch complete documentation page content

### API Reference Tools
- **query_api** - Search local API index for classes, methods, and properties
- **get_class_info** - Get detailed information about specific API classes
- **list_api_namespaces** - Browse available API namespaces (adsk.core, adsk.fusion, adsk.cam)

### Code Generation Tools
- **generate_addin** - Generate complete Fusion 360 add-in templates with event handlers
- **generate_script** - Generate standalone script templates

### Auto-Update Tools (NEW!)
- **update_api_index** - Automatically scrape and index API documentation from help.autodesk.com
- **get_index_status** - Check index status, last update time, and statistics

## Installation

### 1. Clone or Download This Repository

```bash
cd /path/to/your/projects
git clone <your-repo-url> fusion-mcp-docs
cd fusion-mcp-docs
```

### 2. Install Python Dependencies

```bash
# Create and activate virtual environment (recommended)
python3 -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt
```

### 3. Build API Index (Two Options)

#### Option A: Auto-Update (Recommended - NEW!)

Simply use the MCP tool after configuring your client:

```
Use update_api_index with max_classes: 20  (test first)
Use update_api_index                       (full update, 15-20 mins)
```

This will automatically:
- Discover all API classes from help.autodesk.com
- Download and parse documentation
- Cache results for 7 days
- Build the complete API index

**See AUTO_UPDATE_GUIDE.md for details!**

#### Option B: Manual Build (Legacy)

Download offline docs and run build_index.py:

```bash
# 1. Download Fusion 360 API offline documentation from Autodesk
# 2. Extract it to a directory (e.g., /path/to/fusion-api-offline)
# 3. Update BASE_DIR in build_index.py to point to your extracted docs
# 4. Run the index builder:
python build_index.py
```

**Note:** Documentation search and code generation work without any index!

### 4. Configure MCP Client

#### For Claude Desktop (Mac/Linux)

Edit `~/Library/Application Support/Claude/claude_desktop_config.json` (Mac) or `~/.config/Claude/claude_desktop_config.json` (Linux):

```json
{
  "mcpServers": {
    "fusion360-api": {
      "command": "python3",
      "args": ["/absolute/path/to/fusion-mcp-docs/server.py"],
      "env": {}
    }
  }
}
```

#### For Cline (VS Code Extension)

The MCP server configuration is typically stored at:
- Windows: `%appdata%\Code\User\globalStorage\saoudrizwan.claude-dev\settings\cline_mcp_settings.json`
- Mac: `~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json`
- Linux: `~/.config/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json`

Add this configuration:

```json
{
  "mcpServers": {
    "fusion360-api": {
      "command": "python3",
      "args": ["/absolute/path/to/fusion-mcp-docs/server.py"],
      "disabled": false,
      "autoApprove": []
    }
  }
}
```

**Important:** Replace `/absolute/path/to/fusion-mcp-docs/` with the actual absolute path to this directory!

### 5. Restart Your MCP Client

- Claude Desktop: Quit and restart the application
- Cline: Reload VS Code window

## Usage Examples

Once configured, you can use these tools through your MCP client:

### Search for API Documentation

```
Use search_fusion_docs to find information about "BRepBody class"
```

### Generate an Add-in

```
Use generate_addin to create a new add-in called "Part Exporter" that exports selected parts to STEP format
```

### Query API Structure

```
Use query_api to find all classes related to "sketch"
```

### Get Class Details

```
Use get_class_info for "adsk.fusion.ExtrudeFeature"
```

## Architecture

### MCP Tools Overview

| Tool | Purpose | Requires Index |
|------|---------|----------------|
| search_fusion_docs | Search online docs | No |
| fetch_fusion_doc | Fetch doc pages | No |
| query_api | Search API index | Yes |
| get_class_info | Get class details | Yes |
| list_api_namespaces | List API structure | Yes |
| generate_addin | Create add-in template | No |
| generate_script | Create script template | No |

### Files

- **server.py** - Main MCP server implementation
- **build_index.py** - Builds searchable API index from offline docs
- **fusion_api_index.json** - Generated API index (created by build_index.py)
- **requirements.txt** - Python dependencies
- **setup_mcp.py** - Helper script for automatic configuration (legacy)

## Building the API Index

The API index enables powerful local querying of the Fusion 360 API without needing internet access. Here's how to set it up:

### 1. Get Offline Documentation

1. Open Fusion 360
2. Go to Help → API Documentation
3. Download the offline documentation package
4. Extract it to a directory on your computer

### 2. Configure build_index.py

Edit `build_index.py` and update the `BASE_DIR` variable (line 12):

```python
BASE_DIR = Path("/path/to/your/extracted/fusion-api-docs")
```

You may also need to adjust `FILES_ROOT_GLOB` (line 15) depending on your documentation structure:

```python
FILES_ROOT_GLOB = "**/Fusion-360-API/files/*.htm"
```

### 3. Run the Index Builder

```bash
python build_index.py
```

This will:
- Scan all HTML files in the documentation
- Extract class names, methods, properties, events
- Build a searchable JSON index
- Save it as `fusion_api_index.json`

The process may take a few minutes depending on the documentation size.

## Troubleshooting

### Server Won't Start

1. Check Python version: `python3 --version` (requires 3.10+)
2. Verify dependencies: `pip install -r requirements.txt`
3. Check file permissions: `chmod +x server.py`
4. Test manually: `python3 server.py` (should wait for input)

### Tools Not Appearing

1. Verify absolute path in MCP configuration
2. Check MCP client logs for errors
3. Restart your MCP client completely
4. Try manually testing: `echo '{"jsonrpc":"2.0","method":"tools/list","id":1}' | python3 server.py`

### API Index Tools Not Working

1. Make sure `fusion_api_index.json` exists
2. Check it's not empty: `cat fusion_api_index.json`
3. Rebuild the index: `python build_index.py`
4. Verify BASE_DIR points to correct documentation location

### Documentation Search Returns No Results

- DuckDuckGo may be rate-limiting requests
- Try again after a few minutes
- Check internet connection
- Verify help.autodesk.com is accessible

## Development

### Project Structure

```
fusion-mcp-docs/
├── server.py              # Main MCP server
├── build_index.py         # API index builder
├── fusion_api_index.json  # Generated API index
├── requirements.txt       # Python dependencies
├── setup_mcp.py          # Legacy setup helper
└── README.md             # This file
```

### Adding New Tools

To add a new tool to the MCP server:

1. Add tool definition in `list_tools()` function
2. Implement handler logic in `call_tool()` function
3. Add helper functions as needed
4. Update this README

### Testing

Test the server manually:

```bash
# Start server in debug mode
python3 server.py

# Send a test request (in another terminal)
echo '{"jsonrpc":"2.0","method":"tools/list","id":1}' | python3 server.py
```

## Resources

- [Model Context Protocol Documentation](https://modelcontextprotocol.io/)
- [Fusion 360 API Reference](https://help.autodesk.com/cloudhelp/ENU/Fusion-360-API/)
- [MCP Python SDK](https://github.com/modelcontextprotocol/python-sdk)
- [Fusion 360 API Samples](https://github.com/AutodeskFusion360/Fusion360-API-Samples)

## License

This is an unofficial community project and is not affiliated with or endorsed by Autodesk.

## Contributing

Contributions welcome! Please:
1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Submit a pull request

## Support

For issues or questions:
- Check the Troubleshooting section above
- Review MCP server logs in your client
- Open an issue on GitHub

---

**Made for Fusion 360 developers who want AI-assisted API access**