Skip to main content
Glama

Bonsai-mcp - 通过 IfcOpenShell 实现 IFC 的 Blender 模型上下文协议集成

Bonsai-mcp 是BlenderMCP的一个分支,它扩展了 BlenderMCP 的功能,并通过 Bonsai 专门支持 IFC(工业基础类)模型。此集成是一个快速的概念验证,旨在演示将 Claude 或任何 LLM(尽管仅使用 Claude 桌面客户端进行了测试)连接到 Blender 以执行 IfcOpenShell 命令的功能。

特征

  • IFC 特定功能:查询 IFC 模型、分析空间结构和检查建筑元素

  • 五种强大的 IFC 工具:检查项目信息、列出实体、检查属性、探索空间结构和分析关系

  • 顺序思维:包括来自modelcontextprotocol/servers的顺序思维工具,用于结构化问题解决

  • 来自原始 BlenderMCP 实现的执行代码工具:在 Blender 中创建和修改对象、应用材质以及执行 Python 代码

  • 使用标准模型进行测试:已验证使用默认的 ifcopenshell 房屋模型( AC20-FZK-Haus.ifc )

Related MCP server: BlenderMCP

成分

该系统由两个主要组件组成:

  1. Blender Addon( addon.py ) :Blender 插件,在 Blender 中创建套接字服务器来接收和执行命令,包括 IFC 特定的操作

  2. MCP 服务器 ( blender_mcp_tools.py ) :一个实现模型上下文协议并连接到 Blender 插件的 Python 服务器

安装

先决条件

  • Blender 3.0 或更新版本

  • Python 3.10 或更高版本

  • uv 包管理器

  • Blender 的 Bonsai BIM 插件(用于 IFC 功能)

安装 uv:

苹果:

brew install uv

视窗:

powershell -c "irm https://astral.sh/uv/install.ps1 | iex" 
set Path=C:\Users\[username]\.local\bin;%Path%

对于其他平台,请参阅uv 安装指南。

克隆存储库

git clone https://github.com/JotaDeRodriguez/Bonsai_mcp

Claude 用于桌面集成

编辑您的claude_desktop_config.json文件(Claude > 设置 > 开发人员 > 编辑配置)以包含:

{
    "mcpServers": {
        "Bonsai-mcp": {
            "command": "uv",
            "args": [
              "--directory",
              "\\your\\path\\to\\Bonsai_mcp",
              "run",
              "tools.py"
          ]
        }
    }
}

安装Blender插件

  1. 从这个 repo 下载addon.py文件

  2. 打开 Blender

  3. 前往“编辑”>“首选项”>“附加组件”

  4. 点击“安装...”并选择addon.py文件

  5. 通过选中“接口:Blender MCP - IFC”旁边的框来启用该插件

用法

启动连接

  1. 在 Blender 中,转到 3D 视图侧栏(如果看不到,请按 N)

  2. 找到“Blender MCP - IFC”选项卡

  3. 点击“连接到 Claude”

  4. 确保 MCP 服务器正在运行

与 Claude 一起使用

连接后,您将在 Claude 的界面中看到一个锤子图标,其中包含用于 Blender MCP IFC 集成的工具。

IFC 工具

此 fork 添加了五个强大的 IFC 特定工具:

1. 获取ifc项目信息

获取有关 IFC 项目的基本信息,包括名称、描述和不同实体类型的数量。

例如:“这个 IFC 项目的基本信息是什么?”

2. 列出ifc实体

列出特定类型的 IFC 实体(墙壁、门、空间等)。

例如:“列出此 IFC 模型中的所有墙壁”或“显示这栋建筑中的窗户”

3. 获取ifc属性

通过 GlobalId 获取特定 IFC 实体的所有属性。

例如:“ID 为 1Dvrgv7Tf5IfTEapMkwDQY 的墙的属性是什么?”

4. 获取ifc空间结构

获取 IFC 模型的空间层次结构(场地、建筑、楼层、空间)。

例如:“向我展示这座建筑的空间结构”

5. 获取ifc关系

获取特定 IFC 实体的所有关系。

例如:“入口门的关系是什么?”

执行 Blender 代码

原始 MCP 实现的遗留功能。允许 Claude 在 Blender 中执行任意 Python 代码。请谨慎使用。

顺序思维工具

这种集成还包括顺序思维工具,该工具有助于解决问题和分析问题的详细、逐步的思维过程。

工具参数:

  • thought (字符串):当前的思考步骤

  • nextThoughtNeeded (布尔值): 是否需要另一个思考步骤

  • thoughtNumber (整数):当前的想法数量

  • totalThoughts (整数):估计需要的想法总数

  • isRevision (布尔值,可选):这是否改变了以前的想法

  • revisesThought (整数,可选):正在重新考虑哪个想法

  • branchFromThought (整数,可选):分支点思想编号

  • branchId (字符串,可选):分支标识符

  • needsMoreThoughts (布尔值,可选):是否需要更多想法

例如:“使用顺序思维来分析这座建筑的能源效率”

示例命令

以下是您可以要求 Claude 使用 IFC 模型执行的操作的一些示例:

  • “分析一下这个 IFC 模型,告诉我它有多少面墙、多少扇门、多少扇窗户”

  • “给我看看这个建筑模型的空间结构”

  • “列出此 IFC 模型中的所有空间及其属性”

  • “识别该建筑的所有结构元素”

  • “这面墙和其他元素之间是什么关系?”

  • “运用顺序思维,基于 IFC 模型为该建筑制定维护计划”

故障排除

  • 连接问题:确保 Blender 插件服务器正在运行,并且 MCP 服务器已在 Claude 中配置

  • IFC 模型未加载:请确认您已安装 Bonsai BIM 插件,并且已加载 IFC 文件

  • 超时错误:尝试简化您的请求或将其分解为更小的步骤

技术细节

IFC 集成使用 Bonsai BIM 模块访问 Blender 中的 ifcopenshell 功能。通信遵循与原始 BlenderMCP 相同的基于 JSON 的 TCP 套接字协议。

限制和安全注意事项

  • 原始项目中的execute_blender_code工具仍然可用,允许在Blender中运行任意Python代码。请谨慎使用并始终保存您的工作。

  • 复杂的 IFC 模型可能需要将操作分解为更小的步骤。

  • IFC 查询性能取决于模型的大小和复杂性。

致谢

待办事项

游标实现添加“get_selected_ifc_elements”描述

Available Tools

17 tools
execute_blender_codeC
Execute arbitrary Python code in Blender.

Parameters:
- code: The Python code to execute

Inputs: code (required).

export_bc3_budgetA
Export a BC3 budget file (FIEBDC-3/2016) based on the IFC model loaded in Blender.

This tool creates a complete construction budget in BC3 format by:
1. Extracting the complete IFC spatial structure (Project → Site → Building → Storey)
2. Extracting IFC quantities and measurements for all building elements
3. Converting to BC3 hierarchical format with IFC2BC3Converter:
   - Generates budget chapters from IFC spatial hierarchy
   - Groups building elements by type and categories defined in external JSON
   - Assigns unit prices from language-specific JSON database
   - Creates detailed measurements sorted alphabetically
4. Exports to BC3 file with windows-1252 encoding

Features:
- Multi-language support (Spanish/English) for descriptions and labels
- Automatic element categorization using external JSON configuration
- Optimized conversion with O(1) lookups and batch operations
- Detailed measurements with dimensions (units, length, width, height)
- Full FIEBDC-3/2016 format compliance

Configuration files (in resources/bc3_helper_files/):
- precios_unitarios.json / unit_prices.json: Unit prices per IFC type
- spatial_labels_es.json / spatial_labels_en.json: Spatial element translations
- element_categories.json: IFC type to category mappings

Args:
    language: Language for the budget file ('es' for Spanish, 'en' for English). Default is 'es'.

Returns:
    A confirmation message with the path to the generated BC3 file in the exports/ folder.

Inputs: language.

export_drawing_pngA

Export drawings as PNG images with custom resolution.

Creates a drawing, with the view type specified, of the IFC building at the specified 
height above the floor level. Supports custom resolution for high-quality architectural drawings.

Args:
    height_offset: Height in meters above the storey level for the camera position (default 0.5m)
    view_type: Type of view - "top" for plan view, "front", "right" and "left" for elevation views, and "isometric" for 3D view
    resolution_x: Horizontal resolution in pixels (default 1920, max recommended 4096)
    resolution_y: Vertical resolution in pixels (default 1080, max recommended 4096)
    storey_name: Specific storey name to add to the file name (if None, prints default in the file name)
    output_path: Optional file path to save the PNG (if None, returns as base64 image)

Returns:
    metadata and the path of the file image of the drawing at the specified resolution

Inputs: height_offset, view_type, resolution_x, resolution_y, +2 more.

export_ifc_dataB
Export IFC data to a file in JSON or CSV format.

This tool extracts IFC data and creates a structured export file. You can filter
by entity type and/or building level, and choose the output format.

Args:
    entity_type: Type of IFC entity to export (e.g., "IfcWall") - leave empty for all entities
    level_name: Name of the building level to filter by (e.g., "Level 1") - leave empty for all levels
    output_format: "json" or "csv" format for the output file
    
Returns:
    Confirmation message with the export file path or an error message

Inputs: entity_type, level_name, output_format, ctx.

generate_idsA
Creates an .ids file in Blender/Bonsai by calling the add-on handler 'generate_ids'.

Parameters:
  - title (str): Title of the IDS.
  - specs (list | JSON str): List of 'specs' containing 'applicability' and 'requirements'.
    Each facet is a dict with at least a 'type' field ("Entity", "Attribute", "Property",
    "Material", "Classification", "PartOf") and its corresponding attributes.
  - description, author, ids_version, date_iso, purpose, milestone: IDS metadata fields.
  - output_path (str): Full path to the .ids file to be created. If omitted, the add-on will generate a default name.

Returns:
  - JSON (str) with the handler result: {"ok": bool, "output_path": "...", "message": "..."} 
    or {"ok": False, "error": "..."}

Inputs: title (required), specs (required), description, author, +5 more.

georeference_ifc_modelC

Georeferences the IFC currently opened in Bonsai/BlenderBIM by creating or updating IfcProjectedCRS and IfcMapConversion. Optionally updates IfcSite and writes the file to disk.

Inputs: crs_mode (required), epsg, crs_name, geodetic_datum, +19 more.

get_ifc_georeferencing_infoA
Checks whether the IFC currently opened in Bonsai/BlenderBIM is georeferenced
and returns the key georeferencing information.

Parameters
----------
include_contexts : bool
    If True, adds a breakdown of the RepresentationContexts and operations.
    

Returns
--------
str (JSON pretty-printed)
    {
      "georeferenced": true|false,
      "crs": {
        "name": str|null,
        "geodetic_datum": str|null,
        "vertical_datum": str|null,
        "map_unit": str|null
      },
      "map_conversion": {
        "eastings": float|null,
        "northings": float|null,
        "orthogonal_height": float|null,
        "scale": float|null,
        "x_axis_abscissa": float|null,
        "x_axis_ordinate": float|null
      },
      "world_coordinate_system": {
        "origin": [x, y, z]|null
      },
      "true_north": {
        "direction_ratios": [x, y]|null
      },
      "site": {
        "local_placement_origin": [x, y, z]|null,
        "ref_latitude": [deg, min, sec, millionth]|null,
        "ref_longitude": [deg, min, sec, millionth]|null,
        "ref_elevation": float|null
      },
      "contexts": [...],              # only if include_contexts = true
      "warnings": [ ... ]             # Informational message
    }

Notes
-----
- This tool acts as a wrapper: it sends the "get_ifc_georeferencing_info"
  command to the Blender add-on. The add-on must implement that logic
  (reading IfcProject/IfcGeometricRepresentationContext, IfcMapConversion,
  TargetCRS, IfcSite.RefLatitude/RefLongitude/RefElevation, etc.).
- It always returns a JSON string with indentation for easier reading.

Inputs: include_contexts.

get_ifc_project_infoB
Get basic information about the IFC project, including name, description, 
and counts of different entity types.

Returns:
    A JSON-formatted string with project information

Inputs: no named parameters.

get_ifc_propertiesA
Get properties of IFC entities. Can be used to get properties of a specific entity by GlobalId,
or to get properties of all currently selected objects in Blender.

Args:
    global_id: GlobalId of a specific IFC entity (optional if selected_only is True)
    selected_only: If True, return properties for all selected objects instead of a specific entity

Returns:
    A JSON-formatted string with entity information and properties

Inputs: global_id, selected_only.

get_ifc_quantitiesC
Extract and get basic qtos about the IFC project.

Returns:
    A JSON-formatted string with project quantities information

Inputs: no named parameters.

get_ifc_relationshipsB
Get all relationships for a specific IFC entity.

Args:
    global_id: GlobalId of the IFC entity

Returns:
    A JSON-formatted string with all relationships the entity participates in

Inputs: global_id (required).

get_ifc_spatial_structureB
Get the spatial structure of the IFC model (site, building, storey, space hierarchy).

Returns:
    A JSON-formatted string representing the hierarchical structure of the IFC model

Inputs: no named parameters.

get_ifc_total_structureA
Get the complete IFC structure including spatial hierarchy and all building elements.

This function extends the basic spatial structure to include building elements like walls,
doors, windows, columns, beams, etc. that are contained within each spatial element.
It provides a comprehensive view of how the building is organized both spatially and
in terms of its physical components.

Returns:
    A JSON-formatted string representing the complete hierarchical structure of the IFC model
    including spatial elements and their contained building elements, plus summary statistics

Inputs: no named parameters.

get_selected_ifc_entitiesA
Get IFC entities corresponding to the currently selected objects in Blender.
This allows working specifically with objects the user has manually selected in the Blender UI.

Returns:
    A JSON-formatted string with information about the selected IFC entities

Inputs: no named parameters.

get_user_viewA
Capture and return the current Blender viewport as an image.
Shows what the user is currently seeing in Blender.

Focus mostly on the 3D viewport. Use the UI to assist in your understanding of the scene but only refer to it if specifically prompted.

Args:
    max_dimension: Maximum dimension (width or height) in pixels for the returned image
    compression_quality: Image compression quality (1-100, higher is better quality but larger)

Returns:
    An image of the current Blender viewport

Inputs: no named parameters.

list_ifc_entitiesB
List IFC entities of a specific type. Can be filtered to only include objects
currently selected in the Blender UI.

Args:
    entity_type: Type of IFC entity to list (e.g., "IfcWall")
    limit: Maximum number of entities to return
    selected_only: If True, only return information about selected objects

Returns:
    A JSON-formatted string listing the specified entities

Inputs: entity_type, limit, selected_only.

place_ifc_objectB
Place an IFC object at a specified location with optional rotation.

This tool allows you to create and position IFC elements in the model.
The object is placed using the specified IFC type and positioned
at the given coordinates with optional rotation around the Z axis.

Args:
    type_name: Name of the IFC element type to place (must exist in the model)
    x: X-coordinate in model space
    y: Y-coordinate in model space
    z: Z-coordinate in model space
    rotation: Rotation angle in degrees around the Z axis (default: 0)
    
Returns:
    A message with the result of the placement operation

Inputs: type_name (required), x (required), y (required), z (required), +2 more.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.6/5.0

    Scored across 17 tools

    Disambiguation4/5

    Most tools have distinct purposes with clear boundaries, such as export_bc3_budget for budget generation and get_ifc_georeferencing_info for georeferencing checks. However, some overlap exists between get_ifc_spatial_structure and get_ifc_total_structure, where the latter extends the former, potentially causing confusion about which to use for hierarchical data. Tools like get_ifc_properties and get_ifc_quantities are clearly differentiated by focusing on properties versus quantities.

    Naming Consistency5/5

    Tool names follow a highly consistent verb_noun pattern throughout, using snake_case uniformly. Examples include execute_blender_code, export_bc3_budget, get_ifc_project_info, and list_ifc_entities. This predictability makes it easy for agents to understand and navigate the toolset without confusion from mixed naming conventions.

    Tool Count4/5

    With 17 tools, the count is slightly high but reasonable for the domain of IFC/BIM modeling and Blender integration, which involves data extraction, export, visualization, and manipulation. Most tools serve specific functions like georeferencing, drawing export, or entity listing, though a few could potentially be consolidated (e.g., spatial structure tools) without losing functionality.

    Completeness5/5

    The toolset provides comprehensive coverage for IFC/BIM workflows, including data retrieval (e.g., get_ifc_project_info, get_ifc_properties), export functions (e.g., export_bc3_budget, export_drawing_png), spatial analysis (e.g., get_ifc_spatial_structure), and manipulation (e.g., place_ifc_object, georeference_ifc_model). It supports CRUD-like operations and lifecycle management, with no obvious gaps that would hinder agent performance in this domain.

    Maintenance

    ActivityNo data
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      D
      maintenance
      Connects Blender to Claude AI through the Model Context Protocol, enabling AI-assisted 3D modeling, scene creation, and manipulation through natural language commands.
      17
      2
      MIT
    • A
      license
      B
      quality
      D
      maintenance
      Connects Claude AI to Blender via the Model Context Protocol to enable prompt-assisted 3D modeling, scene creation, and object manipulation. It allows users to control Blender through natural language for tasks such as modifying materials, inspecting scenes, and executing custom Python code.
      22
      MIT