pyp6xer_critical_path
Identify all critical path activities from Primavera P6 XER files, sorted by early start, with float, dates, and predecessor/successor counts.
Instructions
Return all activities on the critical path (total float ≤ 0 or longest path flag).
Activities are sorted by early start date. Includes float, dates, and predecessor/successor counts.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cache_key | No | Cache key identifying the loaded XER file (set when calling pyp6xer_load_file) | default |
| proj_id | No | Project ID or short name; uses first project if omitted |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- server.py:717-752 (handler)The pyp6xer_critical_path tool function. It retrieves activities on the critical path (total float ≤ 0 or longest path flag), sorts by early start date, and returns them with predecessor/successor counts.
@mcp.tool(annotations=ToolAnnotations(readOnlyHint=True, destructiveHint=False, idempotentHint=True, openWorldHint=False)) def pyp6xer_critical_path( cache_key: Annotated[str, Field(description="Cache key identifying the loaded XER file (set when calling pyp6xer_load_file)")] = "default", proj_id: Annotated[str | None, Field(description="Project ID or short name; uses first project if omitted")] = None, ctx: Context = None, ) -> str: """Return all activities on the critical path (total float ≤ 0 or longest path flag). Activities are sorted by early start date. Includes float, dates, and predecessor/successor counts. """ xer = _get_xer(ctx, cache_key) tasks = _get_tasks(xer, proj_id) critical = [t for t in tasks if t.is_critical or t.is_longest_path] def _sort_key(t): try: return t.start except Exception: return datetime.max critical.sort(key=_sort_key) result = [] for t in critical: d = _task_to_dict(t) d["predecessor_count"] = len(t.predecessors) d["successor_count"] = len(t.successors) result.append(d) return json.dumps({ "critical_count": len(result), "total_activities": len(tasks), "critical_pct": round(len(result) / len(tasks) * 100, 1) if tasks else 0, "activities": result, }, indent=2) - server.py:717-718 (registration)Registration of pyp6xer_critical_path as an MCP tool via the @mcp.tool decorator with readOnlyHint=True, destructiveHint=False, idempotentHint=True, openWorldHint=False.
@mcp.tool(annotations=ToolAnnotations(readOnlyHint=True, destructiveHint=False, idempotentHint=True, openWorldHint=False)) def pyp6xer_critical_path( - server.py:717-722 (schema)Input parameters for the tool: cache_key (str, default 'default'), proj_id (optional str), and ctx (Context injected by FastMCP).
@mcp.tool(annotations=ToolAnnotations(readOnlyHint=True, destructiveHint=False, idempotentHint=True, openWorldHint=False)) def pyp6xer_critical_path( cache_key: Annotated[str, Field(description="Cache key identifying the loaded XER file (set when calling pyp6xer_load_file)")] = "default", proj_id: Annotated[str | None, Field(description="Project ID or short name; uses first project if omitted")] = None, ctx: Context = None, ) -> str: