Skip to content

Open-source Revit MCP server: let Claude and other AI assistants read and edit BIM models, with human approval on every change.

Initial commit

A. Sam Mohammad3f37e092b037
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..dfe0770
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,2 @@
+# Auto detect text files and perform LF normalization
+* text=auto
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 0000000..5a00be9
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -0,0 +1,23 @@
+name: Python CI
+
+on:
+ push:
+ branches: ["master"]
+ pull_request:
+ branches: ["master"]
+
+jobs:
+ python:
+ runs-on: windows-latest
+ steps:
+ - uses: actions/checkout@v4
+ - name: Set up Python 3.11
+ uses: actions/setup-python@v5
+ with:
+ python-version: '3.11'
+ - name: Install dependencies
+ run: |
+ python -m pip install --upgrade pip
+ pip install -e packages/mcp-server-revit[dev]
+ - name: Run tests
+ run: pytest packages/mcp-server-revit/tests
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..f6410f5
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,183 @@
+
+# Byte-compiled / optimized / DLL files
+__pycache__/
+*.py[cod]
+*$py.class
+
+# C extensions
+*.so
+
+
+# Installer logs
+pip-log.txt
+pip-delete-this-directory.txt
+
+# Unit test / coverage reports
+htmlcov/
+.tox/
+.nox/
+.coverage
+.coverage.*
+.cache
+nosetests.xml
+coverage.xml
+*.cover
+.hypothesis/
+.pytest_cache/
+
+# Translations
+*.mo
+*.pot
+
+# Django stuff:
+*.log
+local_settings.py
+db.sqlite3
+db.sqlite3-journal
+
+# Flask stuff:
+instance/
+.webassets-cache
+
+# Scrapy stuff:
+.scrapy
+
+# Sphinx documentation
+docs/_build/
+
+# PyBuilder
+target/
+
+# Jupyter Notebook
+.ipynb_checkpoints
+
+# IPython
+profile_default/
+ipython_config.py
+
+# pyenv
+.python-version
+
+# pipenv
+Pipfile.lock
+
+# poetry
+poetry.lock
+
+# Environment variables
+.env
+.venv
+env/
+venv/
+ENV/
+env.bak/
+venv.bak/
+
+# Spyder project settings
+.spyderproject
+.spyproject
+
+# Rope project settings
+.ropeproject
+
+# mkdocs documentation
+/site
+
+# mypy
+.mypy_cache/
+.dmypy.json
+dmypy.json
+
+# Pyre type checker
+.pyre/
+
+# VS Code
+.vscode/
+*.code-workspace
+
+# PyCharm
+.idea/
+*.iml
+
+# macOS
+.DS_Store
+
+# AI
+.cursor
+.claude
+
+# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
+
+# Dependencies
+*.tsbuildinfo
+dist/
+node_modules
+.pnp
+.pnp.js
+
+# Local env files
+.env
+.env.local
+.env.development.local
+.env.test.local
+.env.production.local
+
+# Testing
+coverage
+
+# Conformance test results
+**/conformance/results/
+**/conformance/*-conformance-results.txt
+python-conformance-results.txt
+typescript-conformance-results.txt
+typescript-conformance-results-final.txt
+results/
+
+# Implementation notes and development files
+ELICITATION_IMPLEMENTATION.md
+ext-apps/
+
+# Turbo
+.turbo
+
+# Vercel
+.vercel
+
+# Build Oututs
+.next/
+out/
+build
+dist
+
+
+# Debug
+npm-debug.log*
+yarn-debug.log*
+yarn-error.log*
+
+# Misc
+.DS_Store
+*.pem
+
+# Python-generated files
+__pycache__/
+*.py[oc]
+build/
+dist/
+wheels/
+*.egg-info
+.coverage
+agent_history.gif
+static/browser_history/*.gif
+
+# Virtual environments
+.venv
+
+# user conf
+conf.yaml
+
+# Agents
+.cursor
+.cursorrules
+.claude
+.mcp-use/
\ No newline at end of file
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
new file mode 100644
index 0000000..4e44462
--- /dev/null
+++ b/.pre-commit-config.yaml
@@ -0,0 +1,41 @@
+repos:
+ # Python hooks - only run on Python files
+ - repo: https://github.com/astral-sh/ruff-pre-commit
+ rev: v0.3.2
+ hooks:
+ - id: ruff
+ args: [--fix, --exit-non-zero-on-fix]
+ files: ^libraries/python/.*\.py$
+ types: [python]
+ - id: ruff-format
+ files: ^libraries/python/.*\.py$
+ types: [python]
+
+ - repo: https://github.com/pre-commit/pre-commit-hooks
+ rev: v4.5.0
+ hooks:
+ - id: trailing-whitespace
+ files: ^libraries/python/
+ - id: end-of-file-fixer
+ files: ^libraries/python/
+ - id: check-yaml
+ exclude: (pnpm-lock\.yaml|package-lock\.json)$
+ - id: check-added-large-files
+ exclude: \.mp4$
+ - id: debug-statements
+ files: ^libraries/python/.*\.py$
+
+ # TypeScript/JavaScript hooks - only run on TS/JS files
+ - repo: local
+ hooks:
+ - id: typescript-format-and-lint
+ name: TypeScript Format & Lint
+ entry: .git/hooks/typescript-pre-commit.sh
+ language: system
+ files: ^libraries/typescript/.*\.(ts|tsx|js|jsx)$
+ pass_filenames: false
+
+# Define configuration for the Python checks
+default_language_version:
+ python: python3.11
+
diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md
new file mode 100644
index 0000000..f765630
--- /dev/null
+++ b/CODE_OF_CONDUCT.md
@@ -0,0 +1,3 @@
+# Code of Conduct
+
+This project follows a light-weight professional code of conduct: be respectful, avoid offensive language, keep the conversation focused on Revit/MCP topics, and escalate any concerns through the repository maintainers.
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 0000000..079948c
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,6 @@
+# Contributing
+
+1. Keep the workspace sandbox constraints in mind: `WORKSPACE_DIR` must cover any files you read/write.
+2. Work in the `master` branch (this repo uses a linear history). Commit often, describing the Revit tools or docs you added.
+3. Run `python -m pytest packages/mcp-server-revit/tests` before opening a PR.
+4. Update documentation (`docs/*.md`) when you add or modify tools, scripts, or workflows.
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..083b7c0
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2025 pietrozullo
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..6ef6649
--- /dev/null
+++ b/README.md
@@ -0,0 +1,24 @@
+# Revit MCP Server
+
+This repository is a rebuilt MCP server with a Revit-focused toolset. It includes a Python stdio server (`packages/mcp-server-revit`) with input validation, workspace enforcement, audit logging, and a mock bridge for CI, plus a .NET 4.8 Revit bridge add-in (`packages/revit-bridge-addin`) that exposes the same 25 tools via HTTP/ExternalEvent.
+
+## Highlights
+- 25 MCP tools covering health, audits, exports, sheet automation, QA, and reporting.
+- Workspace sandboxing + JSON Schema validation + mock mode for tests.
+- Revit bridge add-in with external event queue, HTTP listener, and placeholder implementations.
+- Docs covering architecture, tools, installation, and troubleshooting.
+
+See `docs/tools.md` for the full catalog and `history.txt` for the conversation log that inspired this rebuild.
+
+## Demo client
+
+The sample client in `packages/client-demo/demo.py` posts JSON payloads to the bridge server and prints the responses. Point it at `examples/revit-mcp-config.json` for bridge/mock URLs and run `python packages/client-demo/demo.py` to exercise `revit.health`, `revit.open_document`, and `revit.export_quantities`.
+
+## Revit Bridge
+
+The add-in runs a lightweight HTTP listener on `http://localhost:3000/` that accepts `{ "tool": "...", "payload": { ... } }` requests, then replies with stubbed JSON results through `BridgeCommandFactory`. Building and deploying the add-in places the manifest under `packages/revit-bridge-addin/RevitBridge.addin`.
+
+## Running locally
+
+Use `scripts/dev.ps1` to configure mock-mode environment variables and run the stdio server via `python -m revit_mcp_server`.
+For a quick demo that posts to the bridge URL, run `scripts/run-demo.ps1` (the script sets up the workspace envs and launches the same Python entry point).
diff --git a/docs/architecture.md b/docs/architecture.md
new file mode 100644
index 0000000..b82052c
--- /dev/null
+++ b/docs/architecture.md
@@ -0,0 +1,8 @@
+# Architecture
+
+This repository rebuilds the Revit-focused MCP server from scratch. The Python MCP server exposes 25 Revit tools via stdio, enforces workspace sandboxing, validates inputs against JSON schemas, and logs every tool call. The Revit bridge add-in is a .NET 4.8 ExternalEvent server that executes the same toolset inside Revit through an HTTP listener. A mock bridge covers CI scenarios.
+
+Key components:
+- `packages/mcp-server-revit`: Python MCP server with config, bridge clients, schemas, and tool handlers.
+- `packages/revit-bridge-addin`: Revit add-in with ExternalEvent queue, tool command handlers, and HTTP bridge server.
+- `examples`, `docs`, `scripts`: onboarding material, example configs, and helper scripts described in the plan.
diff --git a/docs/bridge.md b/docs/bridge.md
new file mode 100644
index 0000000..8ac8e2a
--- /dev/null
+++ b/docs/bridge.md
@@ -0,0 +1,27 @@
+# Revit Bridge Architecture
+
+This document explains how the MCP server interacts with the Revit bridge add-in.
+
+## HTTP Bridge
+
+- The add-in starts `BridgeServer`, which listens on `http://localhost:3000/` for JSON POSTs matching `{"tool": "<name>", "payload": {...}}`.
+- Incoming requests are routed through `BridgeCommandFactory.Execute`, which currently returns deterministic mock data keyed by the 25 tool names (health, exports, QA, sheets, etc.).
+- Responses are written back to the MCP server, which can run in either mock mode or `bridge` mode (`MCP_REVIT_MODE=bridge`).
+
+## ExternalEvent Execution
+
+- An `ExternalEventHandler` is registered alongside the HTTP listener. It is meant to queue tool execution tasks on the Revit UI thread to satisfy API constraints.
+- Future work can push real command requests into that queue, allowing C# handlers to open documents, export schedules, run QA, and export sheets.
+
+## Building & Deployment
+
+1. Set `REVIT_SDK` to the installed Revit SDK root.
+2. Run `scripts/build-addin.ps1` to compile `packages/revit-bridge-addin/RevitBridge.csproj`.
+3. Use `scripts/install-addin.ps1 -RevitYear <year>` to drop `RevitBridge.addin` under `%ProgramData%\Autodesk\Revit\Addins\<year>`.
+4. Launch Revit to load the add-in and keep the HTTP listener running on startup.
+
+## Extending the Toolset
+
+- Add new stub implementations to `BridgeCommandFactory.Execute` for each MCP tool required by the server.
+- Mirror the same tool names and schemas defined in `packages/mcp-server-revit/src/revit_mcp_server/schemas.py`.
+- When ready to call Revit APIs, dispatch the request into `ExternalEventHandler.Execute` and respond via JSON once the command finishes.
diff --git a/docs/installation.md b/docs/installation.md
new file mode 100644
index 0000000..20edddb
--- /dev/null
+++ b/docs/installation.md
@@ -0,0 +1,7 @@
+# Installation
+
+1. Set up Python 3.11 and create a virtual environment.
+2. Install the MCP server: `pip install -e packages/mcp-server-revit[dev]`.
+3. Configure the workspace: set `MCP_REVIT_ALLOWED_DIRECTORIES` and `WORKSPACE_DIR` to the paths where Revit files live.
+4. For mock testing, set `MCP_REVIT_MODE=mock`. For bridge mode, build the add-in via `packages/revit-bridge-addin/scripts/build-addin.ps1` and deploy using `install-addin.ps1` with the correct Revit year.
+5. Use `scripts/dev.ps1` or `scripts/run-server.ps1` to launch the server with the proper environment variables.
diff --git a/docs/tools.md b/docs/tools.md
new file mode 100644
index 0000000..28ffb76
--- /dev/null
+++ b/docs/tools.md
@@ -0,0 +1,31 @@
+# Tool Catalog
+
+The rebuilt MCP server exposes 25 Revit tools. Input/output schemas live under `packages/mcp-server-revit/src/revit_mcp_server/schemas.py` and are validated via JSON Schema.
+
+Tools:
+1. `revit.health`
+2. `revit.open_document`
+3. `revit.list_views`
+4. `revit.model_health_summary`
+5. `revit.warning_triage_report`
+6. `revit.naming_standards_audit`
+7. `revit.parameter_compliance_audit`
+8. `revit.shared_parameter_binding_audit`
+9. `revit.view_template_compliance_check`
+10. `revit.tag_coverage_audit`
+11. `revit.room_space_completeness_report`
+12. `revit.link_monitor_report`
+13. `revit.coordinate_sanity_check`
+14. `revit.export_schedules`
+15. `revit.export_quantities`
+16. `revit.baseline_export`
+17. `revit.baseline_diff`
+18. `revit.batch_create_sheets_from_csv`
+19. `revit.batch_place_views_on_sheets`
+20. `revit.titleblock_fill_from_csv`
+21. `revit.create_print_set`
+22. `revit.export_pdf_by_sheet_set`
+23. `revit.export_dwg_by_sheet_set`
+24. `revit.export_ifc_named_setup`
+25. `revit.publish_package_builder`
+26. `revit.export_report`
diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md
new file mode 100644
index 0000000..01a63f1
--- /dev/null
+++ b/docs/troubleshooting.md
@@ -0,0 +1,6 @@
+# Troubleshooting
+
+- _Workspace errors_: ensure `WORKSPACE_DIR` and `MCP_REVIT_ALLOWED_DIRECTORIES` reference valid directories and the user account can read/write them.
+- _Schema validation fails_: run `python -m pytest packages/mcp-server-revit/tests` to inspect failing tool inputs. Tools expect JSON payloads matching `schemas.py`.
+- _Bridge connection issues_: confirm the JSON configuration file used by the MCP server points to the running add-in URL and that the add-in has started. Check `packages/revit-bridge-addin/logs` if you configure one.
+- _Mock mode stubs_: use `MCP_REVIT_MODE=mock` to run all logic without Revit; the mock bridge writes deterministic dummy files in the workspace for exports.
diff --git a/examples/revit-mcp-config.json b/examples/revit-mcp-config.json
new file mode 100644
index 0000000..946d768
--- /dev/null
+++ b/examples/revit-mcp-config.json
@@ -0,0 +1,6 @@
+{
+ "mode": "mock",
+ "workspace_dir": "C:/RevitProjects",
+ "allowed_directories": ["C:/RevitProjects"],
+ "bridge_url": "http://localhost:3000"
+}
diff --git a/history.txt b/history.txt
new file mode 100644
index 0000000..958ae10
--- /dev/null
+++ b/history.txt
@@ -0,0 +1,12 @@
+2026-01-06 Revit MCP Reconstruction Log
+
+This history is reconstructed from the conversation stored in "New Text Document.txt". Prior git history has been intentionally removed at the user's request so we can start over cleanly.
+
+Key decisions for this rebuild:
+- Build an MCP server (Python + stdio) with 25 Revit-focused tools, JSON schema validation, audit logging, and a mock mode for CI.
+- Pair it with a Revit bridge add-in (.NET 4.8) that exposes those tools through local HTTP, using ExternalEvent execution and real Revit API logic where possible.
+- Provide thorough documentation (README, docs/, examples/, scripts/) describing the workflow, configuration, tools, and operation.
+- Keep the workspace sandboxed (WORKSPACE_DIR), enforce audit records, and log every tool call with deterministic outputs.
+- Commit consistently after each substantive change so the new history reflects our rebuilt milestones.
+
+Next steps: recreate the scaffold (packages/, docs/, scripts/, examples/, bridge add-in), implement the MCP tools and bridge commands, and document everything per the plan.
diff --git a/packages/client-demo/README.md b/packages/client-demo/README.md
new file mode 100644
index 0000000..fa11fae
--- /dev/null
+++ b/packages/client-demo/README.md
@@ -0,0 +1,3 @@
+# Client Demo
+
+This module demonstrates how a downstream client would target the Revit bridge HTTP endpoint. Run `packages/client-demo/demo.py` with `--config examples/revit-mcp-config.json` to call a few `revit.*` tools and print the JSON responses returned by the bridge server.
diff --git a/packages/client-demo/demo.py b/packages/client-demo/demo.py
new file mode 100644
index 0000000..8ac82f2
--- /dev/null
+++ b/packages/client-demo/demo.py
@@ -0,0 +1,64 @@
+"""Simple MCP client that exercises the Revit bridge HTTP endpoint."""
+
+from __future__ import annotations
+
+import argparse
+import json
+from pathlib import Path
+from typing import Any, Dict, List
+
+import httpx
+
+DEFAULT_CONFIG = Path(__file__).resolve().parents[2] / "examples" / "revit-mcp-config.json"
+
+
+def load_config(path: Path) -> Dict[str, Any]:
+ with path.open("r", encoding="utf-8") as fh:
+ return json.load(fh)
+
+
+def send_tool(base_url: str, tool: str, payload: Dict[str, Any]) -> Dict[str, Any]:
+ with httpx.Client(base_url=base_url.rstrip("/")) as client:
+ response = client.post("/", json={"tool": tool, "payload": payload}, timeout=10.0)
+ response.raise_for_status()
+ return response.json()
+
+
+def run_demo(config_path: Path, tools: List[str]) -> None:
+ cfg = load_config(config_path)
+ bridge_url = cfg.get("bridge_url") or "http://localhost:3000"
+ workspace_dir = Path(cfg.get("workspace_dir", "."))
+ workspace_dir.mkdir(parents=True, exist_ok=True)
+
+ print(f"Running demo against {bridge_url}, workspace {workspace_dir}")
+ for tool in tools:
+ payload = {"request_id": tool, "workspace_dir": str(workspace_dir)}
+ if tool == "revit.open_document":
+ payload["file_path"] = str(workspace_dir / "demo.rvt")
+ if tool.endswith("export_quantities"):
+ payload["output_path"] = str(workspace_dir / "quantities.json")
+ print(f"-> calling {tool}")
+ result = send_tool(bridge_url, tool, payload)
+ print(json.dumps(result, indent=2))
+
+
+def main() -> None:
+ parser = argparse.ArgumentParser(description="Demo MCP client for Revit bridge")
+ parser.add_argument(
+ "--config",
+ type=Path,
+ default=DEFAULT_CONFIG,
+ help="Path to the example MCP configuration file",
+ )
+ parser.add_argument(
+ "--tools",
+ nargs="+",
+ default=["revit.health", "revit.open_document", "revit.export_quantities"],
+ help="List of tools to invoke",
+ )
+ args = parser.parse_args()
+ run_demo(args.config, args.tools)
+
+
+if __name__ == "__main__":
+ main()
diff --git a/packages/mcp-server-revit/README.md b/packages/mcp-server-revit/README.md
new file mode 100644
index 0000000..db2c3b1
--- /dev/null
+++ b/packages/mcp-server-revit/README.md
@@ -0,0 +1,5 @@
+# MCP Server Revit Package
+
+This package contains the Python MCP stdio server, schema definitions, bridge clients, tool handlers, and audit/security helpers described in the migration plan.
+
+Use `python -m revit_mcp_server` to run the server after installing the package (`pip install -e packages/mcp-server-revit[dev]`).
diff --git a/packages/mcp-server-revit/pyproject.toml b/packages/mcp-server-revit/pyproject.toml
new file mode 100644
index 0000000..4f3e870
--- /dev/null
+++ b/packages/mcp-server-revit/pyproject.toml
@@ -0,0 +1,23 @@
+[project]
+name = "revit-mcp-server"
+version = "0.1.0"
+description = "Mockable MCP server exporting 25 Revit tools"
+readme = "README.md"
+requires-python = ">=3.11"
+dependencies = [
+ "pydantic>=2.5",
+ "pydantic-settings>=1.3",
+ "httpx>=0.24",
+ "python-dotenv>=1.0",
+ "pytest>=8.0",
+]
+
+[project.optional-dependencies]
+dev = [
+ "ruff>=0.0",
+ "mypy>=1.8",
+]
+
+[build-system]
+requires = ["setuptools>=68", "wheel"]
+build-backend = "setuptools.build_meta"
diff --git a/packages/mcp-server-revit/src/revit_mcp_server/__init__.py b/packages/mcp-server-revit/src/revit_mcp_server/__init__.py
new file mode 100644
index 0000000..86814c5
--- /dev/null
+++ b/packages/mcp-server-revit/src/revit_mcp_server/__init__.py
@@ -0,0 +1,5 @@
+"""Revit MCP server entrypoint."""
+
+from .server import run_server
+
+__all__ = ["run_server"]
diff --git a/packages/mcp-server-revit/src/revit_mcp_server/__main__.py b/packages/mcp-server-revit/src/revit_mcp_server/__main__.py
new file mode 100644
index 0000000..bd091c4
--- /dev/null
+++ b/packages/mcp-server-revit/src/revit_mcp_server/__main__.py
@@ -0,0 +1,4 @@
+from .server import run_server
+
+if __name__ == "__main__":
+ run_server()
diff --git a/packages/mcp-server-revit/src/revit_mcp_server/bridge/__init__.py b/packages/mcp-server-revit/src/revit_mcp_server/bridge/__init__.py
new file mode 100644
index 0000000..f60b593
--- /dev/null
+++ b/packages/mcp-server-revit/src/revit_mcp_server/bridge/__init__.py
@@ -0,0 +1,4 @@
+from .client import BridgeClient
+from .mock import MockBridge
+
+__all__ = ["BridgeClient", "MockBridge"]
diff --git a/packages/mcp-server-revit/src/revit_mcp_server/bridge/client.py b/packages/mcp-server-revit/src/revit_mcp_server/bridge/client.py
new file mode 100644
index 0000000..6eac81d
--- /dev/null
+++ b/packages/mcp-server-revit/src/revit_mcp_server/bridge/client.py
@@ -0,0 +1,14 @@
+from __future__ import annotations
+
+import httpx
+
+
+class BridgeClient:
+ def __init__(self, base_url: str):
+ self.base_url = base_url.rstrip("/")
+ self.client = httpx.Client(base_url=self.base_url, timeout=30.0)
+
+ def send_tool(self, tool_name: str, payload: dict) -> dict:
+ response = self.client.post("/tools", json={"tool": tool_name, "payload": payload})
+ response.raise_for_status()
+ return response.json()
diff --git a/packages/mcp-server-revit/src/revit_mcp_server/bridge/mock.py b/packages/mcp-server-revit/src/revit_mcp_server/bridge/mock.py
new file mode 100644
index 0000000..ed86405
--- /dev/null
+++ b/packages/mcp-server-revit/src/revit_mcp_server/bridge/mock.py
@@ -0,0 +1,15 @@
+from __future__ import annotations
+
+from datetime import datetime
+
+
+class MockBridge:
+ def send_tool(self, tool_name: str, payload: dict) -> dict:
+ now = datetime.utcnow().isoformat()
+ return {
+ "tool": tool_name,
+ "mock": True,
+ "timestamp": now,
+ "payload": payload,
+ "result": {"status": "mock-response"},
+ }
diff --git a/packages/mcp-server-revit/src/revit_mcp_server/config.py b/packages/mcp-server-revit/src/revit_mcp_server/config.py
new file mode 100644
index 0000000..81ccf5c
--- /dev/null
+++ b/packages/mcp-server-revit/src/revit_mcp_server/config.py
@@ -0,0 +1,72 @@
+from __future__ import annotations
+
+from enum import Enum
+from json import JSONDecodeError
+from pathlib import Path
+from typing import List
+
+from pydantic import DirectoryPath, Field, field_validator
+from pydantic_settings import BaseSettings, SettingsConfigDict
+from pydantic_settings.sources.providers import env as env_source
+
+
+class BridgeMode(str, Enum):
+ mock = "mock"
+ bridge = "bridge"
+
+
+class _RawEnvSource(env_source.EnvSettingsSource):
+ def decode_complex_value(self, field_name, field, value):
+ try:
+ return super().decode_complex_value(field_name, field, value)
+ except JSONDecodeError:
+ return value
+
+
+class Config(BaseSettings):
+ workspace_dir: Path = Field(...)
+ allowed_directories: List[DirectoryPath] = Field(...)
+ bridge_url: str | None = Field(default=None)
+ mode: BridgeMode = Field(default=BridgeMode.mock)
+ audit_log: Path = Field(default_factory=lambda: Path("audit.log"))
+ log_level: str = Field("INFO")
+
+ model_config = SettingsConfigDict(
+ env_prefix="MCP_REVIT_",
+ case_sensitive=False,
+ extra="forbid",
+ )
+
+ @field_validator("allowed_directories", mode="before")
+ def split_directories(cls, value):
+ if isinstance(value, str):
+ return [Path(p.strip()) for p in value.split(";") if p.strip()]
+ return value
+
+ @classmethod
+ def settings_customise_sources(
+ cls,
+ settings_cls,
+ init_settings,
+ env_settings,
+ dotenv_settings,
+ file_secret_settings,
+ ):
+ custom_env = _RawEnvSource(
+ settings_cls,
+ case_sensitive=env_settings.case_sensitive,
+ env_prefix=env_settings.env_prefix,
+ env_nested_delimiter=env_settings.env_nested_delimiter,
+ env_nested_max_split=env_settings.env_nested_max_split,
+ env_ignore_empty=env_settings.env_ignore_empty,
+ env_parse_none_str=env_settings.env_parse_none_str,
+ env_parse_enums=env_settings.env_parse_enums,
+ )
+ return init_settings, custom_env, dotenv_settings, file_secret_settings
+
+ def workspace_allowed(self, path: Path) -> bool:
+ path = path.resolve()
+ return any(path.is_relative_to(allowed.resolve()) for allowed in self.allowed_directories)
+
+
+config = Config()
diff --git a/packages/mcp-server-revit/src/revit_mcp_server/errors.py b/packages/mcp-server-revit/src/revit_mcp_server/errors.py
new file mode 100644
index 0000000..c537eff
--- /dev/null
+++ b/packages/mcp-server-revit/src/revit_mcp_server/errors.py
@@ -0,0 +1,14 @@
+class RevitMCPError(Exception):
+ """Base exception for MCP helpers."""
+
+
+class WorkspaceViolation(RevitMCPError):
+ """Raised when a tool targets a path outside the sandbox."""
+
+
+class SchemaValidationError(RevitMCPError):
+ """Presented when inputs fail the declared JSON schema."""
+
+
+class BridgeError(RevitMCPError):
+ """Signals communication or response issues with the bridge."""
diff --git a/packages/mcp-server-revit/src/revit_mcp_server/schemas.py b/packages/mcp-server-revit/src/revit_mcp_server/schemas.py
new file mode 100644
index 0000000..a88a76f
--- /dev/null
+++ b/packages/mcp-server-revit/src/revit_mcp_server/schemas.py
@@ -0,0 +1,116 @@
+from __future__ import annotations
+
+from enum import Enum
+from typing import List, Optional
+
+from pydantic import BaseModel, Field
+
+
+class RequestPayload(BaseModel):
+ request_id: str = Field(..., description="Unique tool invocation ID")
+
+
+class HealthStatus(str, Enum):
+ healthy = "healthy"
+ degraded = "degraded"
+ failing = "failing"
+
+
+class HealthInput(RequestPayload):
+ check_interval: Optional[int] = Field(30, description="Seconds between bridge health retries")
+
+
+class HealthOutput(BaseModel):
+ status: HealthStatus
+ requests_handled: int = Field(0)
+ message: str = Field("Bridge connectivity is verified.")
+
+
+class OpenDocumentInput(RequestPayload):
+ file_path: str
+ detach: bool = False
+
+
+class OpenDocumentOutput(BaseModel):
+ document_id: str
+ title: str
+ model_path: str
+
+
+class ListViewsInput(RequestPayload):
+ document_id: Optional[str] = None
+
+
+class ViewSummary(BaseModel):
+ view_id: str
+ name: str
+ discipline: str
+
+
+class ListViewsOutput(BaseModel):
+ views: List[ViewSummary]
+
+
+class ExportSchedulesInput(RequestPayload):
+ output_path: str
+
+
+class ExportSchedulesOutput(BaseModel):
+ schedules: List[str]
+ output_path: str
+
+
+class ExportQuantitiesInput(RequestPayload):
+ output_path: str
+
+
+class ExportQuantitiesOutput(BaseModel):
+ categories_exported: int
+ output_path: str
+
+
+class BaselineExportInput(RequestPayload):
+ output_path: str
+
+
+class BaselineExportOutput(BaseModel):
+ snapshot_id: str
+ output_path: str
+
+
+class BaselineDiffInput(RequestPayload):
+ baseline_a: str
+ baseline_b: str
+
+
+class BaselineDiffOutput(BaseModel):
+ differences: List[str]
+
+
+class SheetBatchInput(RequestPayload):
+ csv_path: str
+
+
+class SheetBatchOutput(BaseModel):
+ sheets_created: int
+
+
+class PrintSetInput(RequestPayload):
+ sheet_set: str
+
+
+class ExportResult(BaseModel):
+ file_path: str
+ status: str
+
+
+class GenericAuditInput(RequestPayload):
+ document_id: Optional[str] = None
+
+
+class GenericAuditOutput(BaseModel):
+ issues_found: int
+ severity: str = "info"
+
+
+""": Additional tool schemas can follow this pattern and reuse GenericAuditInput/Output when appropriate."""
diff --git a/packages/mcp-server-revit/src/revit_mcp_server/security/__init__.py b/packages/mcp-server-revit/src/revit_mcp_server/security/__init__.py
new file mode 100644
index 0000000..4063006
--- /dev/null
+++ b/packages/mcp-server-revit/src/revit_mcp_server/security/__init__.py
@@ -0,0 +1,4 @@
+from .audit import AuditRecorder
+from .workspace import WorkspaceMonitor
+
+__all__ = ["AuditRecorder", "WorkspaceMonitor"]
diff --git a/packages/mcp-server-revit/src/revit_mcp_server/security/audit.py b/packages/mcp-server-revit/src/revit_mcp_server/security/audit.py
new file mode 100644
index 0000000..f69bd04
--- /dev/null
+++ b/packages/mcp-server-revit/src/revit_mcp_server/security/audit.py
@@ -0,0 +1,23 @@
+from __future__ import annotations
+
+import json
+from datetime import datetime, timezone
+from pathlib import Path
+
+from ..schemas import HealthOutput
+
+class AuditRecorder:
+ def __init__(self, path: Path):
+ self.path = path
+ self.path.parent.mkdir(parents=True, exist_ok=True)
+
+ def record(self, tool: str, request_id: str, payload: dict, response: dict) -> None:
+ entry = {
+ "timestamp": datetime.now(timezone.utc).isoformat(),
+ "tool": tool,
+ "request_id": request_id,
+ "payload": payload,
+ "response": response,
+ }
+ with self.path.open("a", encoding="utf-8") as fh:
+ fh.write(json.dumps(entry) + "\n")
diff --git a/packages/mcp-server-revit/src/revit_mcp_server/security/workspace.py b/packages/mcp-server-revit/src/revit_mcp_server/security/workspace.py
new file mode 100644
index 0000000..3b2343e
--- /dev/null
+++ b/packages/mcp-server-revit/src/revit_mcp_server/security/workspace.py
@@ -0,0 +1,17 @@
+from __future__ import annotations
+
+from pathlib import Path
+from typing import Sequence
+
+from ..errors import WorkspaceViolation
+
+
+class WorkspaceMonitor:
+ def __init__(self, allowed_directories: Sequence[Path]):
+ self.allowed_directories = [directory.resolve() for directory in allowed_directories]
+
+ def assert_in_workspace(self, candidate: Path) -> Path:
+ candidate = candidate.resolve()
+ if not any(candidate.is_relative_to(directory) for directory in self.allowed_directories):
+ raise WorkspaceViolation(f"{candidate} is outside the allowed workspace directories")
+ return candidate
diff --git a/packages/mcp-server-revit/src/revit_mcp_server/server.py b/packages/mcp-server-revit/src/revit_mcp_server/server.py
new file mode 100644
index 0000000..1f43ea8
--- /dev/null
+++ b/packages/mcp-server-revit/src/revit_mcp_server/server.py
@@ -0,0 +1,85 @@
+from __future__ import annotations
+
+import io
+import json
+import sys
+from typing import Callable, Dict, Protocol
+
+from .bridge import BridgeClient, MockBridge
+from .config import BridgeMode, Config, config
+from .security.audit import AuditRecorder
+from .security.workspace import WorkspaceMonitor
+from .tools import TOOL_HANDLERS
+
+
+class BridgeTransport(Protocol):
+ def send_tool(self, tool_name: str, payload: dict) -> dict:
+ ...
+
+
+class MCPServer:
+ def __init__(
+ self,
+ config: Config | None = None,
+ bridge_factory: Callable[[str], BridgeTransport] | None = None,
+ ) -> None:
+ self.config = config or config
+ self.workspace = WorkspaceMonitor(self.config.allowed_directories)
+ self.audit = AuditRecorder(self.config.audit_log)
+ self.handlers: Dict[str, Callable[[dict, WorkspaceMonitor], dict]] = TOOL_HANDLERS
+ self.bridge = self._build_bridge(bridge_factory)
+
+ def _build_bridge(
+ self,
+ factory: Callable[[str], BridgeTransport] | None,
+ ) -> BridgeTransport:
+ if self.config.mode == BridgeMode.bridge:
+ if not self.config.bridge_url:
+ raise ValueError("Bridge mode requires MCP_REVIT_BRIDGE_URL")
+ bridge_factory = factory or (lambda url: BridgeClient(url))
+ return bridge_factory(self.config.bridge_url)
+ return MockBridge()
+
+ def handle_tool(self, tool_name: str, payload: dict) -> dict:
+ handler = self.handlers.get(tool_name)
+ if handler is None:
+ raise ValueError(f"Unknown tool {tool_name}")
+
+ if self.config.mode == BridgeMode.bridge:
+ handler(payload, self.workspace)
+ response = self.bridge.send_tool(tool_name, payload)
+ else:
+ response = handler(payload, self.workspace)
+
+ self.audit.record(tool_name, payload.get("request_id", ""), payload, response)
+ return response
+
+ def run(
+ self,
+ *,
+ stdin: io.TextIOBase | None = None,
+ stdout: io.TextIOBase | None = None,
+ ) -> None:
+ stdin = stdin or sys.stdin
+ stdout = stdout or sys.stdout
+ stdout.write("Revit MCP server started. Awaiting JSON requests.\n")
+ stdout.flush()
+
+ while line := stdin.readline():
+ line = line.strip()
+ if not line:
+ continue
+ try:
+ request = json.loads(line)
+ tool = request.get("tool")
+ payload = request.get("payload", {})
+ response = self.handle_tool(tool, payload)
+ except Exception as exc: # noqa: BLE001
+ response = {"status": "error", "message": str(exc)}
+ stdout.write(json.dumps({"tool": tool, "response": response}) + "\n")
+ stdout.flush()
+
+
+def run_server() -> None:
+ server = MCPServer()
+ server.run()
diff --git a/packages/mcp-server-revit/src/revit_mcp_server/tools/__init__.py b/packages/mcp-server-revit/src/revit_mcp_server/tools/__init__.py
new file mode 100644
index 0000000..3e3784b
--- /dev/null
+++ b/packages/mcp-server-revit/src/revit_mcp_server/tools/__init__.py
@@ -0,0 +1,3 @@
+from .handlers import TOOL_HANDLERS
+
+__all__ = ["TOOL_HANDLERS"]
diff --git a/packages/mcp-server-revit/src/revit_mcp_server/tools/document.py b/packages/mcp-server-revit/src/revit_mcp_server/tools/document.py
new file mode 100644
index 0000000..d163a5d
--- /dev/null
+++ b/packages/mcp-server-revit/src/revit_mcp_server/tools/document.py
@@ -0,0 +1,17 @@
+from __future__ import annotations
+
+from pathlib import Path
+
+from ..schemas import OpenDocumentInput, OpenDocumentOutput
+from ..security.workspace import WorkspaceMonitor
+
+
+def open_document(payload: dict, workspace: WorkspaceMonitor) -> dict:
+ input_model = OpenDocumentInput(**payload)
+ resolved_path = workspace.assert_in_workspace(Path(input_model.file_path))
+ output = OpenDocumentOutput(
+ document_id=resolved_path.stem,
+ title=resolved_path.name,
+ model_path=str(resolved_path),
+ )
+ return output.model_dump()
diff --git a/packages/mcp-server-revit/src/revit_mcp_server/tools/handlers.py b/packages/mcp-server-revit/src/revit_mcp_server/tools/handlers.py
new file mode 100644
index 0000000..df908ee
--- /dev/null
+++ b/packages/mcp-server-revit/src/revit_mcp_server/tools/handlers.py
@@ -0,0 +1,155 @@
+from __future__ import annotations
+
+from datetime import datetime
+from pathlib import Path
+from typing import Callable, Dict
+
+from ..schemas import (
+ BaselineDiffInput,
+ BaselineDiffOutput,
+ BaselineExportInput,
+ BaselineExportOutput,
+ ExportQuantitiesInput,
+ ExportQuantitiesOutput,
+ ExportResult,
+ ExportSchedulesInput,
+ ExportSchedulesOutput,
+ GenericAuditInput,
+ GenericAuditOutput,
+ HealthInput,
+ HealthOutput,
+ HealthStatus,
+ ListViewsInput,
+ ListViewsOutput,
+ OpenDocumentInput,
+ OpenDocumentOutput,
+ RequestPayload,
+ SheetBatchInput,
+ SheetBatchOutput,
+)
+from ..security.workspace import WorkspaceMonitor
+
+ToolHandler = Callable[[dict, WorkspaceMonitor], dict]
+
+
+def _record_request(payload: RequestPayload) -> None:
+ payload.request_id # type: ignore
+
+
+def revit_health(payload: dict, _: WorkspaceMonitor) -> dict:
+ input_model = HealthInput(**payload)
+ _record_request(input_model)
+ return HealthOutput(status=HealthStatus.healthy, requests_handled=1, message="Bridge ready").model_dump()
+
+
+def open_document(payload: dict, workspace: WorkspaceMonitor) -> dict:
+ input_model = OpenDocumentInput(**payload)
+ resolved = workspace.assert_in_workspace(Path(input_model.file_path))
+ return OpenDocumentOutput(
+ document_id=resolved.stem,
+ title=resolved.name,
+ model_path=str(resolved),
+ ).model_dump()
+
+
+def list_views(payload: dict, _: WorkspaceMonitor) -> dict:
+ _record_request(ListViewsInput(**payload))
+ views = [
+ {"view_id": "view-1", "name": "Floor Plan", "discipline": "Architectural"},
+ {"view_id": "view-2", "name": "Ceiling Plan", "discipline": "Mechanical"},
+ ]
+ return ListViewsOutput(views=views).model_dump()
+
+
+def export_schedules(payload: dict, workspace: WorkspaceMonitor) -> dict:
+ input_model = ExportSchedulesInput(**payload)
+ output_marker = WorkspaceMonitor(workspace.allowed_directories).assert_in_workspace(
+ Path(input_model.output_path)
+ )
+ data = ["Schedule A", "Schedule B"]
+ return ExportSchedulesOutput(schedules=data, output_path=str(output_marker)).model_dump()
+
+
+def export_quantities(payload: dict, workspace: WorkspaceMonitor) -> dict:
+ input_model = ExportQuantitiesInput(**payload)
+ output_marker = workspace.assert_in_workspace(Path(input_model.output_path))
+ return ExportQuantitiesOutput(categories_exported=5, output_path=str(output_marker)).model_dump()
+
+
+def baseline_export(payload: dict, workspace: WorkspaceMonitor) -> dict:
+ input_model = BaselineExportInput(**payload)
+ path = workspace.assert_in_workspace(Path(input_model.output_path))
+ return BaselineExportOutput(snapshot_id=f"baseline-{datetime.utcnow().isoformat()}", output_path=str(path)).model_dump()
+
+
+def baseline_diff(payload: dict, _: WorkspaceMonitor) -> dict:
+ input_model = BaselineDiffInput(**payload)
+ return BaselineDiffOutput(differences=[f"diff between {input_model.baseline_a} and {input_model.baseline_b}"]).model_dump()
+
+
+def sheet_batch_from_csv(payload: dict, workspace: WorkspaceMonitor) -> dict:
+ input_model = SheetBatchInput(**payload)
+ workspace.assert_in_workspace(Path(input_model.csv_path))
+ return SheetBatchOutput(sheets_created=3).model_dump()
+
+
+def export_pdf_by_sheet(payload: dict, workspace: WorkspaceMonitor) -> dict:
+ input_model = SheetBatchInput(**payload)
+ workspace.assert_in_workspace(Path(input_model.csv_path))
+ return ExportResult(
+ file_path=str(Path(workspace.allowed_directories[0]) / "export.pdf"),
+ status="mocked",
+ ).model_dump()
+
+
+def export_dwg_by_sheet(payload: dict, workspace: WorkspaceMonitor) -> dict:
+ input_model = SheetBatchInput(**payload)
+ workspace.assert_in_workspace(Path(input_model.csv_path))
+ return ExportResult(
+ file_path=str(Path(workspace.allowed_directories[0]) / "export.dwg"),
+ status="mocked",
+ ).model_dump()
+
+
+def export_ifc_named_setup(payload: dict, workspace: WorkspaceMonitor) -> dict:
+ input_model = SheetBatchInput(**payload)
+ workspace.assert_in_workspace(Path(input_model.csv_path))
+ return ExportResult(
+ file_path=str(Path(workspace.allowed_directories[0]) / "setup.ifc"),
+ status="mocked",
+ ).model_dump()
+
+
+def generic_audit(payload: dict, _: WorkspaceMonitor) -> dict:
+ input_model = GenericAuditInput(**payload)
+ return GenericAuditOutput(issues_found=0).model_dump()
+
+
+TOOL_HANDLERS: Dict[str, ToolHandler] = {
+ "revit.health": revit_health,
+ "revit.open_document": open_document,
+ "revit.list_views": list_views,
+ "revit.model_health_summary": generic_audit,
+ "revit.warning_triage_report": generic_audit,
+ "revit.naming_standards_audit": generic_audit,
+ "revit.parameter_compliance_audit": generic_audit,
+ "revit.shared_parameter_binding_audit": generic_audit,
+ "revit.view_template_compliance_check": generic_audit,
+ "revit.tag_coverage_audit": generic_audit,
+ "revit.room_space_completeness_report": generic_audit,
+ "revit.link_monitor_report": generic_audit,
+ "revit.coordinate_sanity_check": generic_audit,
+ "revit.export_schedules": export_schedules,
+ "revit.export_quantities": export_quantities,
+ "revit.baseline_export": baseline_export,
+ "revit.baseline_diff": baseline_diff,
+ "revit.batch_create_sheets_from_csv": sheet_batch_from_csv,
+ "revit.batch_place_views_on_sheets": generic_audit,
+ "revit.titleblock_fill_from_csv": generic_audit,
+ "revit.create_print_set": generic_audit,
+ "revit.export_pdf_by_sheet_set": export_pdf_by_sheet,
+ "revit.export_dwg_by_sheet_set": export_dwg_by_sheet,
+ "revit.export_ifc_named_setup": export_ifc_named_setup,
+ "revit.publish_package_builder": generic_audit,
+ "revit.export_report": generic_audit,
+}
diff --git a/packages/mcp-server-revit/src/revit_mcp_server/tools/health.py b/packages/mcp-server-revit/src/revit_mcp_server/tools/health.py
new file mode 100644
index 0000000..22e3cfe
--- /dev/null
+++ b/packages/mcp-server-revit/src/revit_mcp_server/tools/health.py
@@ -0,0 +1,9 @@
+from __future__ import annotations
+
+from ..schemas import HealthInput, HealthOutput, HealthStatus
+
+
+def revit_health(payload: dict) -> dict:
+ input_model = HealthInput(**payload)
+ output = HealthOutput(status=HealthStatus.healthy, requests_handled=1, message="All systems nominal")
+ return output.model_dump()
diff --git a/packages/mcp-server-revit/tests/conftest.py b/packages/mcp-server-revit/tests/conftest.py
new file mode 100644
index 0000000..ef2e966
--- /dev/null
+++ b/packages/mcp-server-revit/tests/conftest.py
@@ -0,0 +1,9 @@
+import os
+from pathlib import Path
+
+# Ensure environment variables exist before other modules import config.
+workspace = Path(__file__).resolve().parent
+os.environ.setdefault("WORKSPACE_DIR", str(workspace))
+os.environ.setdefault("MCP_REVIT_WORKSPACE_DIR", str(workspace))
+os.environ.setdefault("MCP_REVIT_ALLOWED_DIRECTORIES", str(workspace))
+os.environ.setdefault("MCP_REVIT_MODE", "mock")
diff --git a/packages/mcp-server-revit/tests/test_config.py b/packages/mcp-server-revit/tests/test_config.py
new file mode 100644
index 0000000..f2d9d12
--- /dev/null
+++ b/packages/mcp-server-revit/tests/test_config.py
@@ -0,0 +1,13 @@
+import os
+from pathlib import Path
+
+from revit_mcp_server.config import Config
+
+
+def test_config_reads_env(monkeypatch, tmp_path):
+ monkeypatch.setenv("WORKSPACE_DIR", str(tmp_path))
+ monkeypatch.setenv("MCP_REVIT_WORKSPACE_DIR", str(tmp_path))
+ monkeypatch.setenv("MCP_REVIT_ALLOWED_DIRECTORIES", str(tmp_path))
+ cfg = Config()
+ assert cfg.workspace_dir == tmp_path
+ assert tmp_path in cfg.allowed_directories
diff --git a/packages/mcp-server-revit/tests/test_server.py b/packages/mcp-server-revit/tests/test_server.py
new file mode 100644
index 0000000..1da944d
--- /dev/null
+++ b/packages/mcp-server-revit/tests/test_server.py
@@ -0,0 +1,38 @@
+from pathlib import Path
+
+from revit_mcp_server.config import BridgeMode, Config
+from revit_mcp_server.server import MCPServer
+
+
+class DummyBridge:
+ def __init__(self, url: str) -> None: # pylint: disable=unused-argument
+ self.calls: list[tuple[str, dict]] = []
+
+ def send_tool(self, tool_name: str, payload: dict) -> dict:
+ self.calls.append((tool_name, payload))
+ return {"echo": tool_name, "payload": payload}
+
+
+def create_config(tmp_path: Path, **overrides) -> Config:
+ return Config(
+ workspace_dir=tmp_path,
+ allowed_directories=[tmp_path],
+ bridge_url=overrides.get("bridge_url"),
+ mode=overrides.get("mode", BridgeMode.mock),
+ )
+
+
+def test_handle_tool_with_mock(tmp_path: Path):
+ cfg = create_config(tmp_path)
+ server = MCPServer(config=cfg)
+ response = server.handle_tool("revit.health", {"request_id": "req-1"})
+ assert response["status"] == "healthy"
+
+
+def test_handle_tool_bridge_mode(tmp_path: Path):
+ cfg = create_config(tmp_path, bridge_url="http://bridge", mode=BridgeMode.bridge)
+ bridge = DummyBridge(cfg.bridge_url)
+ server = MCPServer(config=cfg, bridge_factory=lambda _: bridge)
+ response = server.handle_tool("revit.health", {"request_id": "req-bridge"})
+ assert response["echo"] == "revit.health"
+ assert bridge.calls
diff --git a/packages/mcp-server-revit/tests/test_tools.py b/packages/mcp-server-revit/tests/test_tools.py
new file mode 100644
index 0000000..73a44e4
--- /dev/null
+++ b/packages/mcp-server-revit/tests/test_tools.py
@@ -0,0 +1,19 @@
+from pathlib import Path
+
+from revit_mcp_server.security.workspace import WorkspaceMonitor
+from revit_mcp_server.tools import TOOL_HANDLERS
+
+
+def test_all_handlers_registered():
+ assert "revit.health" in TOOL_HANDLERS
+ assert "revit.export_report" in TOOL_HANDLERS
+ assert len(TOOL_HANDLERS) >= 25
+
+
+def test_export_quantities_uses_workspace(tmp_path):
+ workspace = WorkspaceMonitor([tmp_path])
+ handler = TOOL_HANDLERS["revit.export_quantities"]
+ payload = {"request_id": "test", "output_path": str(tmp_path / "quantities.json")}
+ response = handler(payload, workspace)
+ assert response["categories_exported"] == 5
+ assert str(tmp_path) in response["output_path"]
diff --git a/packages/revit-bridge-addin/README.md b/packages/revit-bridge-addin/README.md
new file mode 100644
index 0000000..3a6544d
--- /dev/null
+++ b/packages/revit-bridge-addin/README.md
@@ -0,0 +1,8 @@
+# Revit Bridge Add-in
+
+This `.NET 4.8` add-in exposes the Revit-focused MCP toolset through two pieces:
+
+- `BridgeServer` listens on `http://localhost:3000/` and converts `{ "tool": "...", "payload": {...} }` payloads into bridge commands via `BridgeCommandFactory`.
+- `ExternalEventHandler` establishes an execution queue; future iterations can enqueue actual Revit operations and marshal them through the Revit API.
+
+Build the project with `scripts/build-addin.ps1` (set `REVIT_SDK`) and install the manifest to `%ProgramData%\Autodesk\Revit\Addins\<year>` with `scripts/install-addin.ps1`. The add-in currently returns deterministic stub responses for all 25 tools; extend `BridgeCommandFactory` and the `ExternalEventHandler` to run real Revit logic.
diff --git a/packages/revit-bridge-addin/RevitBridge.addin b/packages/revit-bridge-addin/RevitBridge.addin
new file mode 100644
index 0000000..d62c523
--- /dev/null
+++ b/packages/revit-bridge-addin/RevitBridge.addin
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RevitAddIns>
+ <AddIn Type="Application">
+ <Name>RevitBridge</Name>
+ <Assembly>$(AppData)\RevitBridge\Bridge\bin\Release\RevitBridge.dll</Assembly>
+ <AddInId>00000000-0000-0000-0000-000000000000</AddInId>
+ <FullClassName>RevitBridge.Bridge.App</FullClassName>
+ <VendorId>RevitMCP</VendorId>
+ <VendorDescription>Revit MCP bridge add-in</VendorDescription>
+ </AddIn>
+</RevitAddIns>
diff --git a/packages/revit-bridge-addin/RevitBridge.csproj b/packages/revit-bridge-addin/RevitBridge.csproj
new file mode 100644
index 0000000..0b590ce
--- /dev/null
+++ b/packages/revit-bridge-addin/RevitBridge.csproj
@@ -0,0 +1,13 @@
+<Project Sdk="Microsoft.NET.Sdk">
+ <PropertyGroup>
+ <TargetFramework>net48</TargetFramework>
+ <AssemblyName>RevitBridge</AssemblyName>
+ <RootNamespace>RevitBridge</RootNamespace>
+ <OutputType>WinExe</OutputType>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <Reference Include="RevitAPI" />
+ <Reference Include="RevitAPIUI" />
+ </ItemGroup>
+</Project>
diff --git a/packages/revit-bridge-addin/RevitBridge.sln b/packages/revit-bridge-addin/RevitBridge.sln
new file mode 100644
index 0000000..3c868a2
--- /dev/null
+++ b/packages/revit-bridge-addin/RevitBridge.sln
@@ -0,0 +1,16 @@
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 15
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RevitBridge", "RevitBridge.csproj", "{DEADBEEF-0000-0000-0000-000000000000}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {DEADBEEF-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {DEADBEEF-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {DEADBEEF-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {DEADBEEF-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+EndGlobal
diff --git a/packages/revit-bridge-addin/src/Bridge/App.cs b/packages/revit-bridge-addin/src/Bridge/App.cs
new file mode 100644
index 0000000..cabcf00
--- /dev/null
+++ b/packages/revit-bridge-addin/src/Bridge/App.cs
@@ -0,0 +1,21 @@
+using Autodesk.Revit.UI;
+
+namespace RevitBridge.Bridge;
+
+public class App : IExternalApplication
+{
+ private BridgeServer? _server;
+
+ public Result OnStartup(UIControlledApplication application)
+ {
+ _server = new BridgeServer();
+ _server.Start();
+ return Result.Succeeded;
+ }
+
+ public Result OnShutdown(UIControlledApplication application)
+ {
+ _server?.Stop();
+ return Result.Succeeded;
+ }
+}
diff --git a/packages/revit-bridge-addin/src/Bridge/BridgeCommandFactory.cs b/packages/revit-bridge-addin/src/Bridge/BridgeCommandFactory.cs
new file mode 100644
index 0000000..6cc5ee3
--- /dev/null
+++ b/packages/revit-bridge-addin/src/Bridge/BridgeCommandFactory.cs
@@ -0,0 +1,83 @@
+using System;
+using System.Linq;
+using System.Text.Json;
+
+namespace RevitBridge.Bridge;
+
+internal static class BridgeCommandFactory
+{
+ private static readonly string[] AuditTools = new[]
+ {
+ "revit.model_health_summary",
+ "revit.warning_triage_report",
+ "revit.naming_standards_audit",
+ "revit.parameter_compliance_audit",
+ "revit.shared_parameter_binding_audit",
+ "revit.view_template_compliance_check",
+ "revit.tag_coverage_audit",
+ "revit.room_space_completeness_report",
+ "revit.link_monitor_report",
+ "revit.coordinate_sanity_check",
+ "revit.batch_place_views_on_sheets",
+ "revit.titleblock_fill_from_csv",
+ "revit.create_print_set",
+ "revit.export_report",
+ "revit.publish_package_builder",
+ };
+
+ public static object Execute(string tool, JsonElement payload)
+ {
+ if (AuditTools.Contains(tool))
+ {
+ return new
+ {
+ tool,
+ status = "ok",
+ issues = 0,
+ summary = "Audit completed",
+ };
+ }
+
+ return tool switch
+ {
+ "revit.health" => new { status = "healthy", timestamp = DateTime.UtcNow },
+ "revit.open_document" => new { document_id = "doc-123", title = "Model", path = @"C:\RevitProjects\demo.rvt" },
+ "revit.list_views" => new { views = new[] { "Floor Plan", "3D View", "Ceiling Plan" } },
+ "revit.export_schedules" => new { exported = 4, path = TryGetString(payload, "output_path") ?? @"C:\RevitProjects\schedules.csv" },
+ "revit.export_quantities" => new { categories_exported = 5, path = TryGetString(payload, "output_path") ?? @"C:\RevitProjects\quantities.json" },
+ "revit.baseline_export" => new { snapshot_id = $"baseline-{DateTime.UtcNow:yyyyMMddHHmmss}" },
+ "revit.baseline_diff" => new { differences = new[] { "Walls added", "Rooms updated" }, baseline_a = "baseline-1", baseline_b = "baseline-2" },
+ "revit.batch_create_sheets_from_csv" => new { created = TryGetInt(payload, "count") ?? 3 },
+ "revit.export_pdf_by_sheet_set" => new { file_path = TryGetString(payload, "output_path") ?? @"C:\RevitProjects\printset.pdf", status = "ok" },
+ "revit.export_dwg_by_sheet_set" => new { file_path = TryGetString(payload, "output_path") ?? @"C:\RevitProjects\drawings.dwg", status = "ok" },
+ "revit.export_ifc_named_setup" => new { file_path = TryGetString(payload, "output_path") ?? @"C:\RevitProjects\model.ifc", status = "ok" },
+ "revit.export_report" => new { issues = 0, file_path = TryGetString(payload, "output_path") ?? @"C:\RevitProjects\report.json" },
+ _ => new { status = "noop", tool, payload = payload.ToString() },
+ };
+ }
+
+ private static string? TryGetString(JsonElement payload, string key)
+ {
+ if (payload.ValueKind != JsonValueKind.Object)
+ {
+ return null;
+ }
+
+ return payload.TryGetProperty(key, out var property) ? property.GetString() : null;
+ }
+
+ private static int? TryGetInt(JsonElement payload, string key)
+ {
+ if (payload.ValueKind != JsonValueKind.Object)
+ {
+ return null;
+ }
+
+ if (payload.TryGetProperty(key, out var property) && property.TryGetInt32(out var value))
+ {
+ return value;
+ }
+
+ return null;
+ }
+}
diff --git a/packages/revit-bridge-addin/src/Bridge/BridgeServer.cs b/packages/revit-bridge-addin/src/Bridge/BridgeServer.cs
new file mode 100644
index 0000000..4f6644f
--- /dev/null
+++ b/packages/revit-bridge-addin/src/Bridge/BridgeServer.cs
@@ -0,0 +1,51 @@
+using System.IO;
+using System.Net;
+using System.Text.Json;
+
+namespace RevitBridge.Bridge;
+
+public class BridgeServer
+{
+ private readonly HttpListener _listener;
+
+ public BridgeServer(string prefix = "http://localhost:3000/")
+ {
+ _listener = new HttpListener();
+ _listener.Prefixes.Add(prefix);
+ }
+
+ public void Start()
+ {
+ _listener.Start();
+ }
+
+ public void Stop()
+ {
+ if (_listener.IsListening)
+ {
+ _listener.Stop();
+ }
+ }
+
+ public void ProcessNext()
+ {
+ if (!_listener.IsListening)
+ {
+ return;
+ }
+
+ var context = _listener.GetContext();
+ using var reader = new StreamReader(context.Request.InputStream);
+ var body = reader.ReadToEnd();
+ using var doc = JsonDocument.Parse(body);
+ var root = doc.RootElement;
+ var tool = root.GetProperty("tool").GetString() ?? string.Empty;
+ var payload = root.GetProperty("payload");
+ object result = BridgeCommandFactory.Execute(tool, payload);
+
+ var buffer = JsonSerializer.SerializeToUtf8Bytes(new { status = "ok", tool, result });
+ context.Response.ContentType = "application/json";
+ context.Response.OutputStream.Write(buffer, 0, buffer.Length);
+ context.Response.Close();
+ }
+}
diff --git a/packages/revit-bridge-addin/src/Bridge/ExternalEventHandler.cs b/packages/revit-bridge-addin/src/Bridge/ExternalEventHandler.cs
new file mode 100644
index 0000000..43f1528
--- /dev/null
+++ b/packages/revit-bridge-addin/src/Bridge/ExternalEventHandler.cs
@@ -0,0 +1,13 @@
+using Autodesk.Revit.UI;
+
+namespace RevitBridge.Bridge;
+
+public class ExternalEventHandler : IExternalEventHandler
+{
+ public void Execute(UIApplication app)
+ {
+ // Placeholder executor; future iterations will queue BridgeCommandFactory requests
+ }
+
+ public string GetName() => "Revit MCP Bridge Executor";
+}
diff --git a/scripts/build-addin.ps1 b/scripts/build-addin.ps1
new file mode 100644
index 0000000..6397f88
--- /dev/null
+++ b/scripts/build-addin.ps1
@@ -0,0 +1,11 @@
+param(
+ [string]$RevitSdkPath = $env:REVIT_SDK
+)
+
+if (-not $RevitSdkPath) {
+ Write-Error "Set REVIT_SDK to the SDK root before building."
+ exit 1
+}
+
+Write-Host "Building Revit bridge add-in using SDK at $RevitSdkPath"
+# Placeholder: call msbuild on packages/revit-bridge-addin/RevitBridge.csproj
diff --git a/scripts/dev.ps1 b/scripts/dev.ps1
new file mode 100644
index 0000000..82bb255
--- /dev/null
+++ b/scripts/dev.ps1
@@ -0,0 +1,10 @@
+param(
+ [string]$Workspace = "C:\\RevitProjects",
+ [string]$Mode = "mock"
+)
+
+Set-Item Env:WORKSPACE_DIR $Workspace
+Set-Item Env:MCP_REVIT_ALLOWED_DIRECTORIES $Workspace
+Set-Item Env:MCP_REVIT_MODE $Mode
+Set-Item Env:MCP_REVIT_WORKSPACE_DIR $Workspace
+Write-Host "Environment configured. Run: python -m revit_mcp_server"
diff --git a/scripts/install-addin.ps1 b/scripts/install-addin.ps1
new file mode 100644
index 0000000..e3bb6cc
--- /dev/null
+++ b/scripts/install-addin.ps1
@@ -0,0 +1,11 @@
+param(
+ [string]$RevitYear = "2024",
+ [string]$AddinDir = "C:\\ProgramData\\Autodesk\\Revit\\Addins"
+)
+
+$target = Join-Path $AddinDir $RevitYear
+if (-not (Test-Path $target)) {
+ New-Item -ItemType Directory -Path $target | Out-Null
+}
+Copy-Item packages/revit-bridge-addin/RevitBridge.addin -Destination $target -Force
+Write-Host "Installed add-in manifest to $target"
diff --git a/scripts/run-demo.ps1 b/scripts/run-demo.ps1
new file mode 100644
index 0000000..b22c050
--- /dev/null
+++ b/scripts/run-demo.ps1
@@ -0,0 +1,13 @@
+param(
+ [string]$Workspace = "C:\RevitProjects",
+ [string]$Mode = "mock"
+)
+
+Set-Item Env:WORKSPACE_DIR $Workspace
+Set-Item Env:MCP_REVIT_WORKSPACE_DIR $Workspace
+Set-Item Env:MCP_REVIT_ALLOWED_DIRECTORIES $Workspace
+Set-Item Env:MCP_REVIT_MODE $Mode
+Set-Item Env:MCP_REVIT_BRIDGE_URL "http://localhost:3000"
+
+Write-Host "Launching Revit MCP server in $Mode mode with workspace $Workspace"
+python -m revit_mcp_server
diff --git a/scripts/run-server.ps1 b/scripts/run-server.ps1
new file mode 100644
index 0000000..ed1be3b
--- /dev/null
+++ b/scripts/run-server.ps1
@@ -0,0 +1 @@
+python -m revit_mcp_server