pyp6xer_list_resources
List all resources for a project, showing assignment counts and cost/quantity totals from a loaded XER file.
Instructions
List all resources with assignment counts and cost/quantity totals.
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:636-685 (handler)The pyp6xer_list_resources tool handler function. Lists all resources with assignment counts and cost/quantity totals. Aggregates TASKRSRC entries by resource name, computes sums for quantities and costs, and returns sorted results.
@mcp.tool(annotations=ToolAnnotations(readOnlyHint=True, destructiveHint=False, idempotentHint=True, openWorldHint=False)) def pyp6xer_list_resources( 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: """List all resources with assignment counts and cost/quantity totals. Args: cache_key: Cache key of the loaded file. proj_id: Optional project filter (restricts to resources assigned in that project). """ xer = _get_xer(ctx, cache_key) if proj_id: proj = _get_project(xer, proj_id) task_rsrcs = proj.resources else: task_rsrcs = list(xer.tasks.values()) # flatten: all TASKRSRC across all tasks task_rsrcs = [tr for t in xer.tasks.values() for tr in t.resources.values()] # Aggregate by resource name rsrc_stats: dict = {} for tr in task_rsrcs: name = tr.resource.name if name not in rsrc_stats: rsrc_stats[name] = { "name": name, "rsrc_id": tr.resource.uid, "type": tr.resource.type, "assignments": 0, "target_qty": 0.0, "actual_qty": 0.0, "remain_qty": 0.0, "target_cost": 0.0, "actual_cost": 0.0, "remain_cost": 0.0, } s = rsrc_stats[name] s["assignments"] += 1 s["target_qty"] += tr.target_qty s["actual_qty"] += tr.act_reg_qty + tr.act_ot_qty s["remain_qty"] += tr.remain_qty s["target_cost"] += tr.target_cost s["actual_cost"] += tr.act_total_cost s["remain_cost"] += tr.remain_cost resources = sorted(rsrc_stats.values(), key=lambda r: -r["assignments"]) return json.dumps({"total": len(resources), "resources": resources}, indent=2) - server.py:636-636 (registration)Registration via @mcp.tool decorator on the pyp6xer_list_resources function, registered with annotations for read-only, idempotent, non-destructive behavior.
@mcp.tool(annotations=ToolAnnotations(readOnlyHint=True, destructiveHint=False, idempotentHint=True, openWorldHint=False))