pyp6xer_clear_cache
Remove specific or all cached Primavera P6 XER files to free server memory and reset analysis state.
Instructions
Remove one or all loaded XER files from the cache.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cache_key | No | Cache key to clear; omit to clear all cached files |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- server.py:369-387 (handler)The handler function that implements the pyp6xer_clear_cache tool. It removes one or all loaded XER files from the in-memory cache.
@mcp.tool(annotations=ToolAnnotations(readOnlyHint=False, destructiveHint=False, idempotentHint=True, openWorldHint=False)) def pyp6xer_clear_cache( cache_key: Annotated[str | None, Field(description="Cache key to clear; omit to clear all cached files")] = None, ctx: Context = None, ) -> str: """Remove one or all loaded XER files from the cache. Args: cache_key: Key to remove. If omitted, clears all cached files. """ cache = ctx.lifespan_context["cache"] if cache_key: if cache_key in cache: del cache[cache_key] return json.dumps({"status": "cleared", "cache_key": cache_key}) return json.dumps({"status": "not_found", "cache_key": cache_key}) count = len(cache) cache.clear() return json.dumps({"status": "cleared_all", "count": count}) - server.py:369-387 (registration)The tool is registered via the @mcp.tool decorator on line 369, which registers pyp6xer_clear_cache with FastMCP.
@mcp.tool(annotations=ToolAnnotations(readOnlyHint=False, destructiveHint=False, idempotentHint=True, openWorldHint=False)) def pyp6xer_clear_cache( cache_key: Annotated[str | None, Field(description="Cache key to clear; omit to clear all cached files")] = None, ctx: Context = None, ) -> str: """Remove one or all loaded XER files from the cache. Args: cache_key: Key to remove. If omitted, clears all cached files. """ cache = ctx.lifespan_context["cache"] if cache_key: if cache_key in cache: del cache[cache_key] return json.dumps({"status": "cleared", "cache_key": cache_key}) return json.dumps({"status": "not_found", "cache_key": cache_key}) count = len(cache) cache.clear() return json.dumps({"status": "cleared_all", "count": count}) - server.py:369-371 (schema)Schema/input definition: cache_key parameter (optional str | None) with Pydantic Field description, and ctx context parameter.
@mcp.tool(annotations=ToolAnnotations(readOnlyHint=False, destructiveHint=False, idempotentHint=True, openWorldHint=False)) def pyp6xer_clear_cache( cache_key: Annotated[str | None, Field(description="Cache key to clear; omit to clear all cached files")] = None,