Skip to main content
Glama
paulieb89

PyP6Xer MCP Server

pyp6xer_export_csv

Read-onlyIdempotent

Export project activities from a loaded Primavera P6 XER file to CSV format, using a cache key and optional project ID and field subset.

Instructions

Export activities to CSV format (returned as a string).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cache_keyNoCache key identifying the loaded XER file (set when calling pyp6xer_load_file)default
proj_idNoProject ID or short name; uses first project if omitted
fieldsNoSubset of field names to return; call pyp6xer_get_activity_schema to see available names

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • server.py:1548-1554 (registration)
    The tool 'pyp6xer_export_csv' is registered as an MCP tool via the @mcp.tool decorator on line 1548.
    @mcp.tool(annotations=ToolAnnotations(readOnlyHint=True, destructiveHint=False, idempotentHint=True, openWorldHint=False))
    def pyp6xer_export_csv(
        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,
        fields: Annotated[list[str] | None, Field(description="Subset of field names to return; call pyp6xer_get_activity_schema to see available names")] = None,
        ctx: Context = None,
    ) -> str:
  • The handler function for pyp6xer_export_csv — loads XER data, serializes activities to CSV using the csv.DictWriter, and returns the CSV content as a JSON response.
    def pyp6xer_export_csv(
        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,
        fields: Annotated[list[str] | None, Field(description="Subset of field names to return; call pyp6xer_get_activity_schema to see available names")] = None,
        ctx: Context = None,
    ) -> str:
        """Export activities to CSV format (returned as a string).
    
        Args:
            cache_key: Cache key of the loaded file.
            proj_id:   Optional project filter.
            fields:    Column names to include. Call pyp6xer_get_activity_schema for
                       available names. Defaults to all standard summary fields.
        """
        xer = _get_xer(ctx, cache_key)
        tasks = _get_tasks(xer, proj_id)
    
        default_fields = [
            "task_code", "name", "status", "type", "wbs", "wbs_name",
            "start", "finish", "target_start", "target_finish",
            "original_duration_days", "remaining_duration_days",
            "total_float_days", "is_critical", "percent_complete",
            "budgeted_cost", "actual_cost", "remaining_cost",
        ]
        cols = fields or default_fields
    
        output = io.StringIO()
        writer = csv.DictWriter(output, fieldnames=cols, extrasaction="ignore")
        writer.writeheader()
        for t in tasks:
            row = _task_to_dict(t)
            writer.writerow(row)
    
        return json.dumps({
            "format": "csv",
            "activity_count": len(tasks),
            "fields": cols,
            "csv_content": output.getvalue(),
        }, indent=2)
  • Input parameters: cache_key (str), proj_id (optional str), fields (optional list of str to select columns), and ctx (Context). Output is a JSON string with format, activity_count, fields, and csv_content.
    def pyp6xer_export_csv(
        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,
        fields: Annotated[list[str] | None, Field(description="Subset of field names to return; call pyp6xer_get_activity_schema to see available names")] = None,
        ctx: Context = None,
  • The _task_to_dict helper function is used by the export CSV handler to convert each task to a dict before writing CSV rows.
    def _task_to_dict(task, fields: list[str] | None = None) -> dict:
        """Standard activity summary dict. Pass fields to project to a subset."""
        try:
            start = _fmt_date(task.start)
        except (ValueError, AttributeError):
            start = ""
        try:
            finish = _fmt_date(task.finish)
        except (ValueError, AttributeError):
            finish = ""
    
        full = {
            "task_id": task.uid,
            "task_code": task.task_code,
            "name": task.name,
            "status": task.status.value,
            "type": task.type.value,
            "wbs": task.wbs.full_code if task.wbs else "",
            "wbs_name": task.wbs.name if task.wbs else "",
            "start": start,
            "finish": finish,
            "target_start": _fmt_date(task.target_start_date),
            "target_finish": _fmt_date(task.target_end_date),
            "original_duration_days": task.original_duration,
            "remaining_duration_days": task.remaining_duration,
            "total_float_days": task.total_float,
            "free_float_days": task.free_float,
            "is_critical": task.is_critical,
            "is_longest_path": task.is_longest_path,
            "percent_complete": round(task.percent_complete * 100, 1),
            "budgeted_cost": task.budgeted_cost,
            "actual_cost": task.actual_cost,
            "remaining_cost": task.remaining_cost,
        }
        if fields:
            return {k: v for k, v in full.items() if k in fields}
        return full
Behavior4/5

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

Annotations already declare it safe (readOnly, idempotent). The description adds that output is a CSV string, which is helpful 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?

Single sentence that is concise and informative without excess. Every word earns its place.

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?

Given output schema exists, description need not detail return values. It covers the core function, though could mention the set of activities exported (all loaded? filtered?).

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 coverage is 100%; description does not add meaning beyond schema descriptions. Baseline 3 is appropriate.

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?

The description clearly states the tool exports activities to CSV format returned as a string, distinguishing it from sibling tools like pyp6xer_export_xer (XER format) and listing tools.

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

Usage Guidelines2/5

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

No guidance on when to use this tool vs alternatives (e.g., pyp6xer_list_activities or pyp6xer_export_xer). The agent must infer from the description alone.

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