feat(pid): instrument index, line list and equipment list from the graph

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FKFStjEFzpGyLq5bMpWxTd
This commit is contained in:
Umut CAN
2026-09-16 10:49:30 +03:00
co-authored by Claude Opus 5
parent 6ad3734c47
commit 4e523ac6ed
7 changed files with 497 additions and 8 deletions
+90 -1
View File
@@ -6357,7 +6357,7 @@ async def solid_boolean(
# ---------------------------------------------------------------------------
# ── SECTION 17: P&ID (4 tools) ──────────────────────────────────────────────
# ── SECTION 17: P&ID (7 tools) ──────────────────────────────────────────────
# ---------------------------------------------------------------------------
@@ -6580,6 +6580,95 @@ async def pid_graph(
)
@cad_tool(
summary=(
"Instrument index derived from the P&ID graph (tag, function, loop, "
"connections); optional CSV."
),
cost="read",
)
@mcp.tool(
annotations={"title": "P&ID: Instrument Index", "readOnlyHint": True},
tags={"pid", "query"},
)
async def pid_instrument_index(
csv_path: Annotated[str | None, "Write the rows as CSV here (inside ALLOWED_PATHS)"] = None,
tolerance: Annotated[
float, Field(default=0.5, gt=0, description="Endpoint-to-port snap distance (mm)")
] = 0.5,
scope: Annotated[str, "current_space | all"] = "current_space",
ctx: Context = None,
) -> dict:
"""Every instrument bubble with its ISA-5.1 reading and what it connects to.
Rows come from `pid_graph`, never from typed-in lists; the drawing is not
modified. `csv_path` is the only file this tool writes.
"""
from engineering.pid.deliverables import deliverable
return await deliverable(
_backend(ctx), "instrument_index", csv_path, tolerance=tolerance, scope=scope
)
@cad_tool(
summary=(
"Line list derived from the P&ID graph (number, class, size, spec, from/to); optional CSV."
),
cost="read",
)
@mcp.tool(
annotations={"title": "P&ID: Line List", "readOnlyHint": True},
tags={"pid", "query"},
)
async def pid_line_list(
csv_path: Annotated[str | None, "Write the rows as CSV here (inside ALLOWED_PATHS)"] = None,
tolerance: Annotated[
float, Field(default=0.5, gt=0, description="Endpoint-to-port snap distance (mm)")
] = 0.5,
scope: Annotated[str, "current_space | all"] = "current_space",
ctx: Context = None,
) -> dict:
"""Every P&ID line with its number, class, size/service/spec/insulation and endpoints.
Rows come from `pid_graph`; untagged lines sort last with `line_number: null`.
The drawing is not modified; `csv_path` is the only file this tool writes.
"""
from engineering.pid.deliverables import deliverable
return await deliverable(_backend(ctx), "line_list", csv_path, tolerance=tolerance, scope=scope)
@cad_tool(
summary=(
"Equipment list derived from the P&ID graph (tag, kind, ports, connections); optional CSV."
),
cost="read",
)
@mcp.tool(
annotations={"title": "P&ID: Equipment List", "readOnlyHint": True},
tags={"pid", "query"},
)
async def pid_equipment_list(
csv_path: Annotated[str | None, "Write the rows as CSV here (inside ALLOWED_PATHS)"] = None,
tolerance: Annotated[
float, Field(default=0.5, gt=0, description="Endpoint-to-port snap distance (mm)")
] = 0.5,
scope: Annotated[str, "current_space | all"] = "current_space",
ctx: Context = None,
) -> dict:
"""Every equipment, valve and connector node with its ports and how many lines reach them.
Rows come from `pid_graph`; the drawing is not modified and `csv_path` is
the only file this tool writes.
"""
from engineering.pid.deliverables import deliverable
return await deliverable(
_backend(ctx), "equipment_list", csv_path, tolerance=tolerance, scope=scope
)
# ---------------------------------------------------------------------------
# ── RESOURCES ───────────────────────────────────────────────────────────────
# ---------------------------------------------------------------------------