Skip to main content
Glama
revit-tunnel-mcp

revit-tunnel-mcp

by xiuchuan666

revit-tunnel MCP (Independent Segments V2)

This is a dedicated MCP independent of the existing general-purpose Revit MCP. It lets an Agent preview, create, and verify shield tunnels through a Node.js stdio MCP, a local-only pyRevit Routes interface, and the Revit 2025 API. The legacy "one family per ring" approach is fully preserved; V2 adds "one independent family instance per segment."

Independent Segment Capabilities

  • Default layout is 9A1K: 9 A segments (37.5° each) and 1 K segment (22.5°) per ring.

  • The default 10 rings create 100 Generic Models family instances that can be individually selected, scheduled, filtered, and tabulated.

  • Supports 1–50 rings, but any single creation is capped at 500 independent segments.

  • Supports outer diameter, thickness, ring width, 3D start point, straight-line longitudinal slope, and alternating positive/negative staggered joints between adjacent rings.

  • Each ring creates only one named work plane, RTM_SEG_HOST_*, shared by all segments in that ring.

  • Every segment has a stable marker, e.g. batch-R0001-A01, batch-R0001-K01.

  • Batch creation is wrapped in a single Revit transaction group; if any family or element fails, the instances, work planes, and newly loaded families in this batch are rolled back together.

Related MCP server: Revit MCP Server

Upgradable Family Content

The family name is determined by the segment role, dimensions, angles, content profile, and content version:

RTM_Segment_{role}_OD{outer}_T{thickness}_W{width}_S{spanMilliDeg}_{profile}_V{version}

The current content provider is basic version 1, which generates one simple annular sector family per geometry. The family type's Type Comments stores RTM_CONTENT:<hash>. Families with the same name are reused only when the content hash matches exactly; a missing or mismatched hash reports a conflict and is never silently overwritten.

Therefore, when adding grout holes, bolt holes, hand holes, grooves, or rebar representation to segments in the future, a new content version can be published. Old batches remain frozen on their original family version; the layout, element numbering, and Agent invocation flow do not need to change.

Element Identity Parameters

All independent segment families use 12 instance shared parameters with fixed GUIDs:

  • RTM_BatchId, RTM_UniqueId

  • RTM_RingIndex, RTM_SegmentIndex

  • RTM_SegmentSlot, RTM_SegmentRole

  • RTM_LayoutId

  • RTM_ContentProfile, RTM_ContentVersion

  • RTM_StartAngle, RTM_EndAngle, RTM_CenterAngle

The fixed GUIDs mean future A, B, and K families, as well as different precision versions, can still use the same schedules, filters, and tags.

Eight MCP Tools

Independent segments V2:

  • list_tunnel_segment_catalog: lists layouts and content versions.

  • preview_tunnel_segments: read-only validation that returns the full per-segment plan and a preview token.

  • create_tunnel_segments: requires the same parameters, preview_token, and confirm=true before creating.

  • inspect_tunnel_segment_batch: read-only reverse lookup of each element's identity, family version, position, orientation, volume, and hosting work plane.

Preserved whole-ring V1:

  • preview_tunnel_rings

  • create_tunnel_rings

  • inspect_tunnel_batch

  • get_tunnel_backend_status (shared by V1/V2)

The recommended call order is: check backend → list catalog → preview → user confirmation → create → inspect batch.

Future Switch to 6A+2B+1K

The layout and family content are already layered. When 6A2B1K is added later, only 9 slots and the A/B/K angle rules need to be added to the versioned catalog; the placer, identity parameters, MCP tools, and inspection interface remain unchanged. If B's geometry differs from A's, the system automatically resolves the new family spec by role and angle.

Safety Boundaries

  • Routes listens only on 127.0.0.1:48884 and is not exposed to the LAN.

  • The Node preview and the pyRevit backend each validate the full plan independently; V2 also recomputes the layout summary, per-ring positions, per-segment angles, markers, family names, and content hashes.

  • Whole rings and independent segments share the global batch_id namespace; duplicate creation is rejected if either side already exists.

  • There are currently no tools to delete, overwrite, or upgrade existing batches.

  • The existing general-purpose Revit MCP and ShieldTunnel.extension are both unmodified.

Installation

  • Source: the project directory after cloning this repository

  • pyRevit extension: %USERPROFILE%\Documents\pyRevit Extensions\RevitTunnelMcp.extension

  • Codex config: [mcp_servers.revit_tunnel] in %USERPROFILE%\.codex\config.toml

First install Node.js 22 and the project dependencies:

npm install

Reinstall the extension:

& '.\scripts\install.ps1' -RoutesPort 48884

After installing or modifying, reload pyRevit (or restart Revit).

Verification and Smoke Calls

npm test
python -m pytest -q '.\pyrevit\tests'
node '.\scripts\smoke-test.mjs' --segments --inspect --batch-id=<批次>

Create a two-ring independent segment test batch:

node '.\scripts\smoke-test.mjs' --segments --create --ring-count=2 --batch-id=segment-e2e-01

The legacy whole-ring calls do not use --segments. --create actually modifies the current Revit project and should only be used on a test copy or a confirmed project.

Available Tools

8 tools
create_tunnel_rings创建盾构隧道整体管片环A
Idempotent

使用预览令牌在当前 Revit 项目中创建整体族管片环;不删除或覆盖已有元素。

Inputs: confirm (required), preview_token (required), batch_id, ring_count, +8 more.

create_tunnel_segments创建盾构隧道独立管片A
Idempotent

使用预览令牌在当前 Revit 项目中为每块管片创建独立族构件;不删除或覆盖已有元素。

Inputs: confirm (required), preview_token (required), batch_id, layout_id, +11 more.

get_tunnel_backend_status检查 Revit 隧道后端A
Read-onlyIdempotent

检查 pyRevit 隧道接口、Revit 版本和当前活动项目。

Inputs: no named parameters.

inspect_tunnel_batch核验 Revit 隧道批次B
Read-onlyIdempotent

按批次标识反查整体环、族、标记、包围盒、体积和定向基准;不会修改 Revit。

Inputs: batch_id (required).

inspect_tunnel_segment_batch核验 Revit 独立管片批次A
Read-onlyIdempotent

按批次标识反查每块独立管片的身份、族版本、位置、定向、包围盒和体积;不会修改 Revit。

Inputs: batch_id (required).

list_tunnel_segment_catalog列出盾构隧道管片目录A
Read-onlyIdempotent

列出可用管片布局、角色、角度以及族内容配置和版本;不会修改 Revit。

Inputs: no named parameters.

preview_tunnel_rings预览盾构隧道整体管片环A
Read-onlyIdempotent

校验整体环参数并返回每环位置和预览令牌;此工具不会修改 Revit。

Inputs: batch_id, ring_count, start_x_mm, start_y_mm, +6 more.

preview_tunnel_segments预览盾构隧道独立管片A
Read-onlyIdempotent

校验布局、族版本、线形与尺寸,返回每块独立管片的完整计划和预览令牌;不会修改 Revit。

Inputs: batch_id, layout_id, ring_count, start_x_mm, +9 more.

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A3.9/5.0

    Scored across 8 tools

    Disambiguation5/5

    Each tool targets a distinct resource (catalog, backend status, segments, rings) and action (list, get, preview, inspect, create). Preview vs. inspect are clearly differentiated: preview validates and returns tokens, while inspect returns detailed properties by batch ID.

    Naming Consistency5/5

    All tool names follow a consistent verb-noun snake_case pattern, using verbs like list, get, preview, inspect, and create paired with clear nouns (tunnel_segment_catalog, tunnel_segments, tunnel_rings). Minor variations like segment_batch vs batch still follow the same style.

    Tool Count5/5

    8 tools is well within the ideal range and each tool earns its place, covering catalog, status, preview, inspect, and create for two related domain objects (segments and rings). No redundant or missing tools at the surface level.

    Completeness4/5

    The server covers the full preview->create->inspect lifecycle for both tunnel segments and rings, plus backend status and catalog listing. Missing update/delete operations are not critical for a creation-focused server, but could be a minor gap if modifications are needed.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      Enables AI assistants to interact with Autodesk Revit to query project data, manage elements, and execute generated code via the Model Context Protocol. It provides full compatibility with GitHub Copilot and Claude to automate BIM modeling workflows.
      13
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI clients to interact with Autodesk Revit for building design, editing, analysis, clash detection, MEP, interop, documentation, and model persistence via 48 tools.
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI agents to interact with CAD software through semantic spatial topology and architectural ontology, supporting drawing, block/layer/entity management, and safe preview-apply transaction workflows for AutoCAD, ZWCAD, GstarCAD, and BricsCAD.
      1
      Apache 2.0