Skip to main content
Glama
paulieb89

PyP6Xer MCP Server

pyp6xer_lookahead

Read-onlyIdempotent

Retrieve activities active within the next N days from the data date, including in-progress and starting activities.

Instructions

Return activities active within the next N days from the data date.

An activity is included if: finish >= data_date AND start <= data_date + days_ahead. This covers in-progress activities and those starting in the window.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cache_keyNoCache key identifying the loaded XER file (set when calling pyp6xer_load_file)default
days_aheadNoNumber of calendar days ahead to include in the lookahead window
proj_idNoProject ID or short name; uses first project if omitted

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function for the pyp6xer_lookahead tool. It retrieves activities active within a configurable lookahead window (default 14 days) from the project's data date. Filters out completed activities, includes in-progress and starting activities, and returns them sorted by start date.
    @mcp.tool(annotations=ToolAnnotations(readOnlyHint=True, destructiveHint=False, idempotentHint=True, openWorldHint=False))
    def pyp6xer_lookahead(
        cache_key: Annotated[str, Field(description="Cache key identifying the loaded XER file (set when calling pyp6xer_load_file)")] = "default",
        days_ahead: Annotated[int, Field(description="Number of calendar days ahead to include in the lookahead window", ge=1)] = 14,
        proj_id: Annotated[str | None, Field(description="Project ID or short name; uses first project if omitted")] = None,
        ctx: Context = None,
    ) -> str:
        """Return activities active within the next N days from the data date.
    
        An activity is included if: finish >= data_date AND start <= data_date + days_ahead.
        This covers in-progress activities and those starting in the window.
    
        Args:
            cache_key:  Cache key of the loaded file.
            days_ahead: Lookahead window length in days (default 14).
            proj_id:    Optional project filter.
        """
        xer = _get_xer(ctx, cache_key)
        proj = _get_project(xer, proj_id)
        tasks = proj.tasks if proj_id else list(xer.tasks.values())
    
        data_date = proj.data_date
        window_end = data_date + timedelta(days=days_ahead)
    
        activities = []
        for t in tasks:
            if t.status.is_completed:
                continue
            try:
                start = t.start
                finish = t.finish
            except Exception:
                continue
            if finish >= data_date and start <= window_end:
                d = _task_to_dict(t, fields=[
                    "task_code", "name", "start", "finish",
                    "target_finish", "total_float_days", "percent_complete",
                    "is_critical", "status", "wbs_name",
                ])
                activities.append(d)
    
        activities.sort(key=lambda a: a.get("start") or "")
    
        return json.dumps({
            "data_date": _fmt_date(data_date),
            "window_end": _fmt_date(window_end),
            "days_ahead": days_ahead,
            "activity_count": len(activities),
            "activities": activities,
        }, indent=2)
  • server.py:1036-1037 (registration)
    The tool is registered via the @mcp.tool decorator on FastMCP instance, which registers it as an MCP tool named 'pyp6xer_lookahead'.
    @mcp.tool(annotations=ToolAnnotations(readOnlyHint=True, destructiveHint=False, idempotentHint=True, openWorldHint=False))
    def pyp6xer_lookahead(
  • Input schema/type definitions for the tool's parameters: cache_key (str), days_ahead (int, ge=1, default 14), proj_id (optional str), and ctx (Context).
        cache_key: Annotated[str, Field(description="Cache key identifying the loaded XER file (set when calling pyp6xer_load_file)")] = "default",
        days_ahead: Annotated[int, Field(description="Number of calendar days ahead to include in the lookahead window", ge=1)] = 14,
        proj_id: Annotated[str | None, Field(description="Project ID or short name; uses first project if omitted")] = None,
        ctx: Context = None,
    ) -> str:
  • Helper function used by pyp6xer_lookahead to retrieve the Xer object from the shared cache.
    def _get_xer(ctx: Context, cache_key: str) -> Xer:
        return _get_cache(ctx, cache_key)["xer"]
  • Helper function used by pyp6xer_lookahead to format dates for the JSON output.
    def _fmt_date(dt: datetime | None) -> str:
        if dt is None:
            return ""
        return dt.strftime(DATE_FMT)
Behavior4/5

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

Annotations already declare readOnlyHint, destructiveHint, and idempotentHint as safe. The description adds the precise behavioral logic of the lookahead window and references 'data date', providing context beyond annotations. No contradiction.

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?

The description is two sentences long, front-loading the purpose. Every sentence is necessary: the first states the overall function, the second gives the specific inclusion logic. No wasted words.

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

Completeness5/5

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

Given that the tool has an output schema (not shown but present), the description does not need to explain return values. The inclusion condition is fully specified, and the tool's scope is clear. The description is complete for a filtered list tool with good annotations.

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%; all three parameters are well-documented in the schema. The description does not add additional parameter details beyond what the schema provides, so it meets the baseline of 3 without adding extra value.

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?

Description clearly states 'Return activities active within the next N days from the data date', specifying verb 'return' and resource 'activities' with a unique filter. This distinguishes from sibling tools like pyp6xer_list_activities which lists all activities, and pyp6xer_search_activities which uses search queries.

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

Usage Guidelines4/5

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

Description provides the exact inclusion condition: 'finish >= data_date AND start <= data_date + days_ahead', which tells when to use this tool. However, it does not explicitly state when not to use it or mention alternatives for other filtering needs. The condition itself gives clear context for usage.

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