Skip to main content
Glama
paulieb89

PyP6Xer MCP Server

pyp6xer_search_activities

Read-onlyIdempotent

Search for activities in a Primavera P6 XER file by name or activity ID using case-insensitive substring matching. Filter by project and limit results.

Instructions

Search activities by name or activity ID (case-insensitive substring match).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesText to search in activity codes and names
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
limitNoMaximum number of results to return
fieldsNoSubset of field names to return; call pyp6xer_get_activity_schema to see available names

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The pyp6xer_search_activities function is the handler/tool implementation. It searches activities by name or activity ID using case-insensitive substring matching. It retrieves tasks from the loaded XER cache, filters by query, and returns matching activities (up to limit).
    @mcp.tool(annotations=ToolAnnotations(readOnlyHint=True, destructiveHint=False, idempotentHint=True, openWorldHint=False))
    def pyp6xer_search_activities(
        query: Annotated[str, Field(description="Text to search in activity codes and names")],
        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,
        limit: Annotated[int, Field(description="Maximum number of results to return", ge=1, le=200)] = 20,
        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:
        """Search activities by name or activity ID (case-insensitive substring match).
    
        Args:
            query:     Search string matched against task_code and name.
            cache_key: Cache key of the loaded file.
            proj_id:   Optional project filter.
            limit:     Maximum results to return (default 20).
            fields:    Subset of fields to return per activity. Call pyp6xer_get_activity_schema
                       for available names. Omit to return all fields.
        """
        xer = _get_xer(ctx, cache_key)
        tasks = _get_tasks(xer, proj_id)
        q = query.lower()
        matches = [
            t for t in tasks
            if q in t.task_code.lower() or q in t.name.lower()
        ][:limit]
    
        return json.dumps({
            "query": query,
            "count": len(matches),
            "activities": [_task_to_dict(t, fields) for t in matches],
        }, indent=2)
  • server.py:598-606 (registration)
    The tool is registered as an MCP tool via the @mcp.tool decorator on line 598, with annotations marking it as read-only, non-destructive, idempotent, and not open-world.
    @mcp.tool(annotations=ToolAnnotations(readOnlyHint=True, destructiveHint=False, idempotentHint=True, openWorldHint=False))
    def pyp6xer_search_activities(
        query: Annotated[str, Field(description="Text to search in activity codes and names")],
        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,
        limit: Annotated[int, Field(description="Maximum number of results to return", ge=1, le=200)] = 20,
        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 pyp6xer_get_activity_schema tool documents the available field names (summary_fields and detail_fields) used by pyp6xer_search_activities. The ACTIVITY_SUMMARY_FIELDS list (lines 110-118) defines which fields are available for the search tool.
    # ── SCHEMA DISCOVERY ─────────────────────────────────────────────────────────
    # ---------------------------------------------------------------------------
    
    @mcp.tool(annotations=ToolAnnotations(readOnlyHint=True, destructiveHint=False, idempotentHint=True, openWorldHint=False))
    def pyp6xer_get_activity_schema() -> str:
        """Return the available field names for activity read tools.
    
        Use the returned field names with the `fields` parameter of
        pyp6xer_list_activities, pyp6xer_get_activity, and pyp6xer_search_activities
        to limit response size to only the columns you need.
    
        summary_fields are available on list_activities and search_activities.
        detail_fields are only available on get_activity (they require fetching
        relationships and resources which are not on the list view).
        """
        return json.dumps({
            "summary_fields": ACTIVITY_SUMMARY_FIELDS,
            "detail_fields": ACTIVITY_DETAIL_FIELDS,
            "note": (
  • The _task_to_dict helper function converts a task object to a dictionary, used by pyp6xer_search_activities to format results.
    def _task_to_dict(task, fields: list[str] | None = None) -> dict:
  • The _get_tasks helper retrieves tasks for a project (or all tasks), used by pyp6xer_search_activities to get the task list.
    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())
Behavior4/5

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

Annotations already declare readOnlyHint and idempotentHint. The description adds behavioral details (substring match, case-insensitive) that go beyond annotations. The presence of an output schema further documents return values. However, it does not cover pagination or empty result behavior.

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, no fluff, front-loaded with verb and resource. Efficient and to the point.

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 the tool has 5 parameters, an output schema, and annotations, the description covers the essential purpose. It could mention the dependency on a loaded XER file, but that is implied by the cache_key parameter. Overall sufficient for a search 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 coverage is 100%, so all parameters have descriptions. The description adds no extra meaning beyond what the schema provides, such as clarifying the role of cache_key or proj_id. Baseline score of 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 specifies the verb 'search', the resource 'activities', and the method 'by name or activity ID (case-insensitive substring match)'. This distinguishes it from sibling tools like pyp6xer_list_activities (list all) and pyp6xer_get_activity (exact ID lookup).

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?

The description implies usage for substring search but does not explicitly state when to use this tool versus alternatives. No exclusions or when-not-to-use guidance is provided, leaving the agent to infer context from sibling names.

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