Skip to main content
Glama
paulieb89

PyP6Xer MCP Server

pyp6xer_compare_snapshots

Read-onlyIdempotent

Compare two XER file snapshots to detect schedule changes. Identifies added, removed, and modified activities including dates, duration, float, and status.

Instructions

Compare two loaded XER files (snapshots) to identify schedule changes.

Reports added, removed, and changed activities (dates, duration, float, status). Useful for analysing schedule updates between periods.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cache_key_aYesCache key of the base (original) snapshot
cache_key_bYesCache key of the modified snapshot to compare
proj_idNoProject ID or short name; uses first project if omitted

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The main handler function for pyp6xer_compare_snapshots. It loads two XER snapshots by cache_key, compares activities task_code-by-task_code, and reports added, removed, and changed activities (finish date, status, remaining duration, total float, percent complete).
    @mcp.tool(annotations=ToolAnnotations(readOnlyHint=True, destructiveHint=False, idempotentHint=True, openWorldHint=False))
    def pyp6xer_compare_snapshots(
        cache_key_a: Annotated[str, Field(description="Cache key of the base (original) snapshot")],
        cache_key_b: Annotated[str, Field(description="Cache key of the modified snapshot to compare")],
        proj_id: Annotated[str | None, Field(description="Project ID or short name; uses first project if omitted")] = None,
        ctx: Context = None,
    ) -> str:
        """Compare two loaded XER files (snapshots) to identify schedule changes.
    
        Reports added, removed, and changed activities (dates, duration, float, status).
        Useful for analysing schedule updates between periods.
    
        Args:
            cache_key_a: Cache key for the baseline/earlier snapshot.
            cache_key_b: Cache key for the updated/later snapshot.
            proj_id:     Optional project filter (matched by short_name).
        """
        xer_a = _get_xer(ctx, cache_key_a)
        xer_b = _get_xer(ctx, cache_key_b)
    
        def _tasks_by_code(xer, pid):
            tasks = _get_tasks(xer, pid)
            return {t.task_code: t for t in tasks}
    
        # Try to match project by short_name if proj_id provided
        pid_a = proj_id
        pid_b = proj_id
    
        tasks_a = _tasks_by_code(xer_a, pid_a)
        tasks_b = _tasks_by_code(xer_b, pid_b)
    
        codes_a = set(tasks_a.keys())
        codes_b = set(tasks_b.keys())
    
        added = list(codes_b - codes_a)
        removed = list(codes_a - codes_b)
        common = codes_a & codes_b
    
        changes = []
        for code in sorted(common):
            a, b = tasks_a[code], tasks_b[code]
            diffs = {}
            try:
                if a.finish != b.finish:
                    diffs["finish"] = {"from": _fmt_date(a.finish), "to": _fmt_date(b.finish)}
            except Exception:
                pass
            if a.status != b.status:
                diffs["status"] = {"from": a.status.value, "to": b.status.value}
            if a.remaining_duration != b.remaining_duration:
                diffs["remaining_duration_days"] = {"from": a.remaining_duration, "to": b.remaining_duration}
            if a.total_float != b.total_float:
                diffs["total_float_days"] = {"from": a.total_float, "to": b.total_float}
            if abs((a.percent_complete or 0) - (b.percent_complete or 0)) > 0.005:
                diffs["percent_complete"] = {
                    "from": round((a.percent_complete or 0) * 100, 1),
                    "to": round((b.percent_complete or 0) * 100, 1),
                }
            if diffs:
                changes.append({"task_code": code, "name": b.name, "changes": diffs})
    
        return json.dumps({
            "snapshot_a": cache_key_a,
            "snapshot_b": cache_key_b,
            "activities_in_a": len(tasks_a),
            "activities_in_b": len(tasks_b),
            "added": added,
            "removed": removed,
            "changed_count": len(changes),
            "changed": changes,
        }, indent=2)
  • server.py:1590-1596 (registration)
    The tool is registered via the @mcp.tool decorator on the pyp6xer_compare_snapshots function. The decorator also sets ToolAnnotations with readOnlyHint=True, destructiveHint=False, idempotentHint=True, openWorldHint=False.
    @mcp.tool(annotations=ToolAnnotations(readOnlyHint=True, destructiveHint=False, idempotentHint=True, openWorldHint=False))
    def pyp6xer_compare_snapshots(
        cache_key_a: Annotated[str, Field(description="Cache key of the base (original) snapshot")],
        cache_key_b: Annotated[str, Field(description="Cache key of the modified snapshot to compare")],
        proj_id: Annotated[str | None, Field(description="Project ID or short name; uses first project if omitted")] = None,
        ctx: Context = None,
    ) -> str:
  • Input schema defined via Pydantic Field annotations on parameters: cache_key_a (str, required), cache_key_b (str, required), proj_id (str | None, optional), ctx (Context).
    def pyp6xer_compare_snapshots(
        cache_key_a: Annotated[str, Field(description="Cache key of the base (original) snapshot")],
        cache_key_b: Annotated[str, Field(description="Cache key of the modified snapshot to compare")],
        proj_id: Annotated[str | None, Field(description="Project ID or short name; uses first project if omitted")] = None,
        ctx: Context = None,
    ) -> str:
  • Helper functions _get_xer, _get_tasks, and _task_to_dict used by compare_snapshots to retrieve XER data and format activity dictionaries.
    def _get_xer(ctx: Context, cache_key: str) -> Xer:
        return _get_cache(ctx, cache_key)["xer"]
    
    
    def _get_project(xer: Xer, proj_id: str | None):
        if proj_id:
            proj = xer.projects.get(proj_id)
            if proj is None:
                ids = list(xer.projects.keys())
                raise ValueError(
                    f"Project '{proj_id}' not found. Available project IDs: {ids}"
                )
            return proj
        projects = list(xer.projects.values())
        if not projects:
            raise ValueError("No projects found in this XER file.")
        return projects[0]
    
    
    def _get_tasks(xer: Xer, proj_id: str | None):
        """Return tasks for a project (or all tasks if proj_id is None)."""
        if proj_id:
            return _get_project(xer, proj_id).tasks
        return list(xer.tasks.values())
    
    
    def _task_to_dict(task, fields: list[str] | None = None) -> dict:
  • Helper _get_cache used to retrieve cached XER data by cache_key, called by _get_xer which is used by compare_snapshots.
    def _get_cache(ctx: Context, cache_key: str) -> dict:
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already indicate read-only, non-destructive, idempotent. The description adds that it reports added, removed, and changed activities with specific fields, providing useful behavioral context beyond the annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences, no fluff, front-loaded with the main action. Every sentence adds value.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With an output schema present, the description adequately covers the input and behavioral aspects. It lists the change types reported, making it complete for a comparison tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so baseline is 3. The description does not add extra semantics beyond what is in the schema; it merely mentions cache keys and optional proj_id.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Clearly states the tool compares two XER snapshots and lists specific change types (added, removed, changed activities with dates, duration, float, status). The verb 'compare' and resource 'snapshots' are specific, distinguishing it from other tools.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Implies usage for analyzing schedule updates between periods, but does not provide explicit when-not scenarios or alternatives among the many sibling tools (e.g., schedule_health_check, critical_path). Usage is somewhat vague.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/paulieb89/pyp6xer-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server