Skip to main content
Glama
vn-sketchup-mcp

vn-sketchup-mcp

by andyluu98

vn-sketchup-mcp

Điều khiển SketchUp từ Claude Code / Codex / Antigravity (và mọi MCP client dùng stdio) thông qua Model Context Protocol.

Bản Việt hoá + đã vá lỗi của mhyrr/sketchup-mcp: cài phát chạy ngay, không còn crash do lệch phiên bản thư viện mcp.

Control SketchUp from Claude Code / Codex / Antigravity via MCP. A fixed, ready-to-run fork of mhyrr/sketchup-mcp.


Vá gì so với bản gốc? (What is fixed)

Bản gốc crash ngay khi khởi động server vì:

  1. Nó import mcp.server.fastmcp (lớp FastMCP). Nhưng thư viện mcp bản 2.x đã đổi tên FastMCP -> MCPServer, xoá mcp.server.fastmcp. Khi cài bằng uvx/pip không ghim phiên bản, máy kéo về mcp 2.x -> ModuleNotFoundError / crash -> MCP client báo Connection closed.

  2. Gói trên PyPI còn dùng API cũ FastMCP(description=...) (đã bỏ), lỗi unexpected keyword argument 'description'.

Cách vá ở repo này:

  • pyproject.toml ghim mcp[cli]>=1.3,<2 -> luôn cài mcp 1.x còn FastMCP.

  • Dùng server.py bản mới (đã đổi sang FastMCP(instructions=...), hợp lệ với mcp 1.x).

  • Kèm installer 1 lệnh tự copy plugin Ruby vào mọi bản SketchUp + in sẵn cấu hình cho 3 client.

Kết quả: uv run vn-sketchup-mcp chạy ổn, kết nối được SketchUp (đã kiểm chứng trên SketchUp Pro 2018, Ruby 2.2.4; và các bản mới hơn).


Related MCP server: CDT-SketchUp

Kiến trúc (How it works)

Gồm 2 phần:

  1. Plugin SketchUp (Ruby) — chạy 1 TCP server bên trong SketchUp ở cổng 9876, nhận lệnh và thao tác model.

  2. MCP server (Python) — client (Claude Code/Codex/Antigravity) chạy qua stdio; nó nối tới cổng 9876 để đẩy lệnh vào SketchUp.

Claude Code / Codex / Antigravity  <--stdio-->  vn-sketchup-mcp (Python)  <--TCP:9876-->  SketchUp (Ruby plugin)

Yêu cầu

  • uv (tự tải Python 3.12, không cần cài Python riêng)

  • git

  • SketchUp (Pro để dùng được đủ Solid Tools; đã test 2018+)


Cài đặt (Install)

1. Clone

git clone https://github.com/andyluu98/vn-sketchup-mcp.git
cd vn-sketchup-mcp

2. Chạy installer (khuyên dùng)

Windows (PowerShell):

powershell -ExecutionPolicy Bypass -File install.ps1

macOS / Linux:

bash install.sh

Installer sẽ: cài uv nếu thiếu -> uv sync (ghim mcp<2) -> copy plugin Ruby vào mọi bản SketchUp phát hiện được -> in sẵn cấu hình MCP.

3. Bật server trong SketchUp

Mở SketchUp -> menu Extensions > MCP Server > Start Server. Ruby Console hiện Server created on port 9876 là OK. Giữ SketchUp mở khi dùng.


Đăng ký MCP cho từng client

Cấu hình cùng một dạng cho cả 3 (thay <REPO> = đường dẫn tuyệt đối bạn đã clone):

{
  "mcpServers": {
    "sketchup": {
      "command": "uv",
      "args": ["run", "--directory", "<REPO>", "vn-sketchup-mcp"]
    }
  }
}
  • Claude Code: thêm vào ~/.claude.json (mục mcpServers) hoặc chạy:

    claude mcp add sketchup -- uv run --directory <REPO> vn-sketchup-mcp
  • Codex: thêm MCP server dạng trên vào cấu hình Codex (~/.codex/config.toml phần [mcp_servers] hoặc file cấu hình MCP tương ứng).

  • Antigravity: thêm cùng khối mcpServers vào phần cấu hình MCP của Antigravity.

Sau khi thêm, khởi động lại client. Nhớ SketchUp đang mở + đã Start Server.

Nếu uv không nằm trong PATH của client, thay "command": "uv" bằng đường dẫn tuyệt đối tới uv (vd C:\\Users\\<ban>\\.local\\bin\\uv.exe).


Công cụ (MCP tools)

Tool

Mô tả

create_component

Tạo khối cơ bản (cube...) theo vị trí/kích thước

delete_component

Xoá đối tượng

transform_component

Di chuyển/xoay/scale

get_selection

Lấy các đối tượng đang chọn

set_material

Gán vật liệu/màu

export_scene

Xuất scene

eval_ruby

Chạy Ruby tuỳ ý trong SketchUp (mạnh nhất: dựng mọi hình học qua SketchUp Ruby API)

create_mortise_tenon, create_dovetail, create_finger_joint

Mộng ghép gỗ

eval_ruby là công cụ linh hoạt nhất: bạn mô tả, agent sinh Ruby dựng nhà/nội thất trực tiếp trong SketchUp.


Xử lý sự cố (Troubleshooting)

Triệu chứng

Nguyên nhân / Cách xử lý

Client báo Connection closed khi khởi động

Thường do mcp 2.x. Repo này đã ghim mcp<2; chạy lại uv sync.

No module named 'mcp.server.fastmcp'

Đang dùng mcp 2.x. uv sync trong repo này để về mcp 1.x.

Không thấy menu Extensions > MCP Server

Plugin chưa cài. Chạy lại installer, hoặc Window > Extension Manager bật "Sketchup MCP Server".

Gọi tool báo lỗi kết nối

Chưa bấm Start Server trong SketchUp, hoặc SketchUp đã đóng.

Lệnh đầu tiên sau khi kết nối lỗi lạ

Thử lại lần nữa (request đầu ngay sau bắt tay đôi khi chập).


Ghi công (Credits)

  • Fork từ mhyrr/sketchup-mcp (MIT).

  • Việt hoá, vá lỗi phiên bản mcp, thêm installer đa client: andyluu98.

MIT License.

Available Tools

10 tools
create_componentC

Create a new component in Sketchup

Inputs: type, position, dimensions. Returns: result

create_dovetailC

Create a dovetail joint between two components

Inputs: pin_id (required), tail_id (required), angle, depth, +6 more. Returns: result

create_finger_jointB

Create a finger joint (box joint) between two components

Inputs: board1_id (required), board2_id (required), depth, width, +5 more. Returns: result

create_mortise_tenonC

Create a mortise and tenon joint between two components

Inputs: tenon_id (required), mortise_id (required), depth, width, +4 more. Returns: result

delete_componentB

Delete a component by ID

Inputs: id (required). Returns: result

eval_rubyB

Evaluate arbitrary Ruby code in Sketchup

Inputs: code (required). Returns: result

export_sceneC

Export the current scene

Inputs: format. Returns: result

get_selectionB

Get currently selected components

Inputs: no named parameters. Returns: result

set_materialC

Set material for a component

Inputs: id (required), material (required). Returns: result

transform_componentC

Transform a component's position, rotation, or scale

Inputs: id (required), scale, position, rotation. Returns: result

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    B3.2/5.0

    Scored across 10 tools

    Disambiguation4/5

    Most tools target distinct operations: component creation, deletion, transformation, selection, materials, scene export, and specific joint types. The main ambiguity is eval_ruby, which can theoretically perform any operation, but its purpose as a scripting escape hatch is clear.

    Naming Consistency5/5

    Tool names consistently follow a verb_noun pattern, such as create_component, delete_component, transform_component, export_scene, and create_dovetail. There is no mixing of casing styles or vague verbs, making the naming predictable.

    Tool Count5/5

    Ten tools is a well-scoped number for a Sketchup-focused server. Each tool covers a meaningful aspect of the modeling workflow, and the count is neither too sparse nor bloated.

    Completeness3/5

    The tool set covers core component operations and joint creation, but lacks direct component read/list operations and joint removal or editing tools. eval_ruby can fill some gaps, but it is a generic escape hatch rather than a structured part of the domain surface.

    Maintenance

    ActivityStale
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      D
      maintenance
      Enables direct interaction and control of SketchUp through Claude AI using the Model Context Protocol and a TCP socket connection. It allows for prompt-assisted 3D modeling, component manipulation, and the execution of arbitrary Ruby code within the SketchUp environment.
      10
      1
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables MCP clients to inspect and manipulate live SketchUp models through a safe loopback bridge, supporting geometry creation, component/group operations, tags, materials, and transformations with persistent-ID safety.
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Connects MCP-aware AI clients to a live SketchUp session so models can be built and edited through natural-language prompts. Exposes typed tools for geometry creation, materials, booleans, edge chamfers/fillets, joinery, scene export, model introspection, viewport screenshots, and an optional arbitrary-Ruby escape hatch.
      24
      MIT
    • A
      license
      C
      quality
      B
      maintenance
      Enables MCP clients to inspect and modify SketchUp models through a local authenticated bridge, covering entity creation and editing, geometry, materials, tags, cameras, scenes, transactions, snapshots, and file or view export. It also offers an optional full SketchUp Ruby API execution channel and batch operations for furniture, architectural, and analysis tasks.
      37
      1
      MIT