pyp6xer_relationship_analysis
Analyzes schedule relationships by type (FS, SS, FF, SF), lag/lead distribution, and identifies activities with no logic ties to improve schedule logic.
Instructions
Analyse relationship types, lag/lead distribution, and logic density.
Reports counts by type (FS/SS/FF/SF), lag distribution, and activities with no logic ties.
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:1088-1133 (handler)Handler function for the pyp6xer_relationship_analysis MCP tool. It analyses relationship types (FS/SS/FF/SF), lag/lead distribution, and logic density in a loaded Primavera P6 XER schedule file.
@mcp.tool(annotations=ToolAnnotations(readOnlyHint=True, destructiveHint=False, idempotentHint=True, openWorldHint=False)) def pyp6xer_relationship_analysis( 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: """Analyse relationship types, lag/lead distribution, and logic density. Reports counts by type (FS/SS/FF/SF), lag distribution, and activities with no logic ties. """ xer = _get_xer(ctx, cache_key) if proj_id: rels = _get_project(xer, proj_id).relationships else: rels = list(xer.relationships.values()) type_counts: dict = {} lag_buckets = {"lead_<0": 0, "zero": 0, "lag_1_5": 0, "lag_6_15": 0, "lag_>15": 0} total_lag = 0 for r in rels: link = r.link type_counts[link] = type_counts.get(link, 0) + 1 lag = r.lag total_lag += lag if lag < 0: lag_buckets["lead_<0"] += 1 elif lag == 0: lag_buckets["zero"] += 1 elif lag <= 5: lag_buckets["lag_1_5"] += 1 elif lag <= 15: lag_buckets["lag_6_15"] += 1 else: lag_buckets["lag_>15"] += 1 n_rels = len(rels) return json.dumps({ "total_relationships": n_rels, "by_type": type_counts, "lag_distribution": lag_buckets, "avg_lag_days": round(total_lag / n_rels, 1) if n_rels else 0, "leads_present": lag_buckets["lead_<0"] > 0, }, indent=2) - server.py:1088-1088 (registration)Registration of the tool via the @mcp.tool decorator on the pyp6xer_relationship_analysis function.
@mcp.tool(annotations=ToolAnnotations(readOnlyHint=True, destructiveHint=False, idempotentHint=True, openWorldHint=False))