pyp6xer_wbs_analysis
Analyze WBS hierarchy with rollups of task counts, schedule range, and cost summary per node. Gain insights into project structure and performance.
Instructions
Return the WBS hierarchy with task counts and cost rollups per node.
Shows each WBS element's direct and total (rolled-up) activity counts, schedule range, and cost summary.
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:1203-1239 (handler)The pyp6xer_wbs_analysis tool handler function. It returns the WBS hierarchy with task counts and cost rollups per node. Defined with @mcp.tool decorator, takes cache_key, proj_id, and ctx parameters.
@mcp.tool(annotations=ToolAnnotations(readOnlyHint=True, destructiveHint=False, idempotentHint=True, openWorldHint=False)) def pyp6xer_wbs_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: """Return the WBS hierarchy with task counts and cost rollups per node. Shows each WBS element's direct and total (rolled-up) activity counts, schedule range, and cost summary. """ xer = _get_xer(ctx, cache_key) proj = _get_project(xer, proj_id) def _wbs_node_dict(node) -> dict: all_tasks = node.all_tasks direct_tasks = node.tasks if hasattr(node, "tasks") else [] completed = sum(1 for t in all_tasks if t.status.is_completed) return { "wbs_id": node.uid, "code": node.full_code, "name": node.name, "depth": node.depth, "direct_activities": len(direct_tasks), "total_activities": len(all_tasks), "completed_activities": completed, "budgeted_cost": round(node.budgeted_cost, 2), "actual_cost": round(node.actual_cost, 2), "remaining_cost": round(node.remaining_cost, 2), "children_count": len(node.children), } nodes = sorted(proj.wbs_nodes, key=lambda n: n.full_code) return json.dumps({ "total_wbs_nodes": len(nodes), "wbs_nodes": [_wbs_node_dict(n) for n in nodes], }, indent=2) - server.py:1199-1201 (registration)Registration decorator @mcp.tool on pyp6xer_wbs_analysis function. The tool is registered as an MCP tool via the FastMCP framework with readOnlyHint=True, destructiveHint=False, idempotentHint=True, openWorldHint=False annotations.
# --------------------------------------------------------------------------- # ── WBS ANALYSIS ───────────────────────────────────────────────────────────── # ---------------------------------------------------------------------------