Implement complete MCP server for parsing Primavera P6 XER files and exposing schedule data through MCP tools. All 4 user stories complete. Tools implemented: - load_xer: Parse XER files into SQLite database - list_activities: Query activities with pagination and filtering - get_activity: Get activity details by ID - list_relationships: Query activity dependencies - get_predecessors/get_successors: Query activity relationships - get_project_summary: Project overview with counts - list_milestones: Query milestone activities - get_critical_path: Query driving path activities Features: - Tab-delimited XER format parsing with pluggable table handlers - In-memory SQLite database for fast queries - Pagination with 100-item default limit - Multi-project file support with project selection - ISO8601 date formatting - NO_FILE_LOADED error handling for all query tools Test coverage: 81 tests (contract, integration, unit)
31 lines
853 B
Python
31 lines
853 B
Python
"""Base class for XER table handlers."""
|
|
|
|
from abc import ABC, abstractmethod
|
|
|
|
|
|
class TableHandler(ABC):
|
|
"""Abstract base class for XER table handlers.
|
|
|
|
Each handler is responsible for parsing a specific table type
|
|
from the XER file and returning structured data.
|
|
"""
|
|
|
|
@property
|
|
@abstractmethod
|
|
def table_name(self) -> str:
|
|
"""Return the XER table name this handler processes (e.g., 'PROJECT', 'TASK')."""
|
|
...
|
|
|
|
@abstractmethod
|
|
def parse_row(self, fields: list[str], values: list[str]) -> dict | None:
|
|
"""Parse a single row of data from the XER file.
|
|
|
|
Args:
|
|
fields: List of column names from the %F line
|
|
values: List of values from the %R line
|
|
|
|
Returns:
|
|
Dictionary of parsed data, or None if the row should be skipped
|
|
"""
|
|
...
|