- TOOL_PROFILE=lean|core|full applied in the lifespan via server-level enable/disable; system_about reports the active profile; opt-in solid_* tools are hidden while ENABLE_3D=false - layouts: layout_list/create/set_current + viewport_create (scaled model viewports) on both backends; drawing_export_pdf(layout=...); ezdxf uses TILEMODE + active-layout binding, COM switches ActiveLayout and restores it - ISO 286: engineering/fits.py authored IT4-11 + fundamental-deviation tables (1-500 mm; shafts d..p/h/js, holes D..H/JS) with clear out-of-scope errors; dimension_linear/radius/diameter gained fit= resolved from the measured nominal - tolerances: DIMTM now signed in deviation/limit modes so double-positive fits (p6 +0.035/+0.022) render correctly; legacy positive-magnitude contract preserved - solids: solid_box/cylinder/extrude/revolve/boolean native on COM (AddBox/AddCylinder/AddRegion+AddExtrudedSolid/AddRevolvedSolid/Boolean); ezdxf reports the honest solid_3d capability boundary - capability maps: paper_space native, new viewport_render feature, ENABLE_3D-gated solid_3d - 60 new tests (profiles, layouts, viewports, layout PDF, fits, gating); version pins in tests now read version.__version__ Co-authored-by: Cursor <cursoragent@cursor.com>
59 lines
2.5 KiB
Python
59 lines
2.5 KiB
Python
"""Centralized configuration for AutoCAD MCP Pro."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
from pathlib import Path
|
|
|
|
|
|
class Settings:
|
|
"""Server configuration loaded from environment variables."""
|
|
|
|
def __init__(self):
|
|
self.backend: str = os.environ.get("AUTOCAD_MCP_BACKEND", "auto").lower().strip()
|
|
self.log_level: str = os.environ.get("LOG_LEVEL", "INFO").upper().strip()
|
|
|
|
raw_paths = os.environ.get("ALLOWED_PATHS", "").strip()
|
|
self.allowed_paths: list[Path] = []
|
|
if raw_paths:
|
|
for p in raw_paths.split(","):
|
|
p = p.strip()
|
|
if p:
|
|
self.allowed_paths.append(Path(p).resolve())
|
|
|
|
self.max_undo_stack: int = int(os.environ.get("MAX_UNDO_STACK", "5"))
|
|
self.dangerous_commands_enabled: bool = (
|
|
os.environ.get("DANGEROUS_COMMANDS_ENABLED", "false").lower().strip() == "true"
|
|
)
|
|
|
|
# Reject opening DXF files larger than this many bytes (default 50 MB).
|
|
# Set to 0 to disable the check.
|
|
self.max_dxf_bytes: int = int(os.environ.get("MAX_DXF_BYTES", str(50 * 1024 * 1024)))
|
|
|
|
# Hard cap on list/select limit params to keep tool responses bounded.
|
|
self.max_list_limit: int = int(os.environ.get("MAX_LIST_LIMIT", "5000"))
|
|
|
|
# Per-call COM timeout. AutoCAD hangs (modal dialogs, long Regen) would
|
|
# otherwise block the single-thread STA executor forever.
|
|
self.com_call_timeout: float = float(os.environ.get("COM_CALL_TIMEOUT", "60"))
|
|
|
|
# HTTP transport: refuse non-loopback bind unless explicitly opted in.
|
|
self.allow_remote_http: bool = (
|
|
os.environ.get("ALLOW_REMOTE_HTTP", "false").lower().strip() == "true"
|
|
)
|
|
self.mcp_auth_token: str = os.environ.get("MCP_AUTH_TOKEN", "").strip()
|
|
|
|
# Exposed tool profile: "full" (default, everything), "core" (hides the
|
|
# raw escape hatches and long-tail tools) or "lean" (a curated ~46-tool
|
|
# drafting/inspection core for clients with tight tool caps). Invalid
|
|
# values fall back to "full" with a warning at startup.
|
|
self.tool_profile: str = os.environ.get("TOOL_PROFILE", "full").lower().strip()
|
|
|
|
# Opt-in 3D solids (COM backend only). Disabled by default because the
|
|
# headless backend cannot produce ACIS solids and live 3D modifies real
|
|
# documents; enable deliberately.
|
|
self.enable_3d: bool = os.environ.get("ENABLE_3D", "false").lower().strip() == "true"
|
|
|
|
|
|
settings = Settings()
|