Fusion 360 API文档服务器

一个全面的Fusion 360 Python API文档服务器,提供文档搜索、代码生成和API查询功能,支持自动索引更新。

  • by luiscarone
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 luiscarone/fusion-360-mcp-server

使用说明

Fusion 360 API MCP服务器

一个全面的模型上下文协议(MCP)服务器,提供对Autodesk Fusion 360 Python API文档、代码生成和API查询功能的完全访问 自动索引更新.

特性

此MCP服务器提供 9个强大的工具 用于使用Fusion 360 API:

文档工具

  • search_fusion.docs -在help.autodesk.com上搜索Fusion 360官方文档
  • fetch_fusion.doc -获取完整的文档页面内容

API参考工具

  • query_api -在本地API索引中搜索类、方法和属性
  • 获取密码信息 -获取有关特定API类的详细信息
  • list_api_namespaces -浏览可用的API名称空间(adsk.core、adsk.fusion、adsk.cam)

代码生成工具

  • generate_addin -使用事件处理程序生成完整的Fusion 360插件模板
  • generate_script -生成独立脚本模板

自动更新工具(新增!)

  • update_api_index -从help.autodesk.com自动抓取和索引API文档
  • get_index_status -检查索引状态、上次更新时间和统计信息

安装

1.克隆或下载此存储库

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

2.安装Python依赖项

# 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.构建API指数(两个选项)

选项A:自动更新(推荐-新!)

配置客户端后,只需使用MCP工具:

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

这将自动:

  • 从help.autodesk.com查找所有API类
  • 下载并解析文档
  • 将结果缓存7天
  • 建立完整的API索引

有关详细信息,请参阅AUTO_UPDATE_GUIDE.md!

选项B:手动构建(传统)

下载离线文档并运行build_index.py:

# 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

注: 文档搜索和代码生成工作没有任何索引!

4.配置MCP客户端

适用于克劳德桌面(Mac/Linux)

编辑 ~/Library/Application Support/Claude/claude_desktop_config.json (Mac)或 ~/.config/Claude/claude_desktop_config.json (Linux):

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

对于Cline(VS代码扩展)

MCP服务器配置通常存储在:

  • 窗户: %appdata%\Code\User\globalStorage\saoudrizwan.claude-dev\settings\cline_mcp_settings.json
  • 雨衣: ~/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

添加此配置:

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

重要提示: 替换 /absolute/path/to/fusion-mcp-docs/ 此目录的实际绝对路径!

5.重新启动MCP客户端

  • Claude Desktop:退出并重新启动应用程序
  • Cline:重新加载VS代码窗口

使用示例

配置后,您可以通过MCP客户端使用这些工具:

搜索API文档

Use search_fusion_docs to find information about "BRepBody class"

生成外接程序

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

查询API结构

Use query_api to find all classes related to "sketch"

获取课程详细信息

Use get_class_info for "adsk.fusion.ExtrudeFeature"

建筑

MCP工具概述

工具 目的 需要索引
search_fusion.docs 搜索在线文档 否
fetch_fusion.doc 获取文档页面 否
query_api 搜索api索引 是
get_class_info 获取类详细信息 是
list_api_namespaces 列出api结构 是
generate_addin 创建外接程序模板 否
generate_script 创建脚本模板 否

文件

  • 服务器.py -主MCP服务器实现
  • build_index.py -从离线文档构建可搜索的API索引
  • fusion_api_index.json -生成的API索引(由build_index.py创建)
  • 需求.txt -Python依赖关系
  • setup_mcp.py -用于自动配置的帮助脚本(旧版)

建立API指数

API索引可实现Fusion 360 API的强大本地查询,而无需访问互联网。以下是如何设置它:

1.获取离线文档

  1. Open Fusion 360
  2. 转到帮助→ API 文档
  3. 下载离线文档包
  4. 将其解压缩到计算机上的目录中

2.配置build_index.py

编辑 build_index.py 并更新 BASE_DIR 变量(第12行):

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

您可能还需要调整 FILES_ROOT_GLOB (第15行)取决于您的文档结构:

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

3.运行索引生成器

python build_index.py

这将:

  • 扫描文档中的所有HTML文件
  • 提取类名、方法、属性、事件
  • 构建一个可搜索的JSON索引
  • 另存为 fusion_api_index.json

根据文档大小,该过程可能需要几分钟。

故障排除

服务器无法启动

  1. 检查Python版本: python3 --version (要求3.10+)
  2. 验证依赖关系: pip install -r requirements.txt
  3. 检查文件权限: chmod +x server.py
  4. 手动测试: python3 server.py (应等待输入)

工具未出现

  1. 验证MCP配置中的绝对路径
  2. 检查MCP客户端日志是否有错误
  3. 完全重新启动MCP客户端
  4. 尝试手动测试: echo '{"jsonrpc":"2.0","method":"tools/list","id":1}' | python3 server.py

API索引工具不工作

  1. 确保 fusion_api_index.json 存在
  2. 检查它是否为空: cat fusion_api_index.json
  3. 重建索引: python build_index.py
  4. 验证BASE_DIR指向正确的文档位置

文档搜索未返回任何结果

  • DuckDuckGo可能是限速请求
  • 几分钟后重试
  • 检查互联网连接
  • 验证help.autodesk.com是否可访问

发展

项目结构

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

添加新工具

要向MCP服务器添加新工具,请执行以下操作:

  1. 在中添加工具定义 list_tools() 函数
  2. 在中实现处理程序逻辑 call_tool() 函数
  3. 根据需要添加辅助函数
  4. 更新此自述文件

测试

手动测试服务器:

# 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

资源

许可证

这是一个非官方的社区项目,不隶属于Autodesk或得到Autodesk的认可。

贡献

欢迎投稿!拜托:

  1. 分叉存储库
  2. 创建要素分支
  3. 进行更改
  4. 提交拉取请求

支持

对于问题或疑问:

  • 检查上面的故障排除部分
  • 查看客户端中的MCP服务器日志
  • 在GitHub上打开一个问题

专为希望借助人工智能访问API的Fusion 360开发人员设计