feat: implement XER MCP Server with 9 schedule query tools
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)
This commit is contained in:
36
src/xer_mcp/tools/get_critical_path.py
Normal file
36
src/xer_mcp/tools/get_critical_path.py
Normal file
@@ -0,0 +1,36 @@
|
||||
"""get_critical_path MCP tool implementation."""
|
||||
|
||||
from xer_mcp.db.queries import query_critical_path
|
||||
from xer_mcp.server import is_file_loaded
|
||||
|
||||
|
||||
async def get_critical_path() -> dict:
|
||||
"""Get all activities on the critical path.
|
||||
|
||||
Returns activities where driving_path_flag is set, ordered by target start date.
|
||||
The critical path determines the minimum project duration.
|
||||
|
||||
Returns:
|
||||
Dictionary with list of critical path activities, each containing:
|
||||
- task_id: Activity ID
|
||||
- task_code: Activity code
|
||||
- task_name: Activity name
|
||||
- task_type: Activity type (TT_Task, TT_Mile, etc.)
|
||||
- target_start_date: Target start date
|
||||
- target_end_date: Target end date
|
||||
- total_float_hr_cnt: Total float in hours
|
||||
- status_code: Activity status
|
||||
"""
|
||||
if not is_file_loaded():
|
||||
return {
|
||||
"error": {
|
||||
"code": "NO_FILE_LOADED",
|
||||
"message": "No XER file is loaded. Use the load_xer tool first.",
|
||||
}
|
||||
}
|
||||
|
||||
critical_activities = query_critical_path()
|
||||
|
||||
return {
|
||||
"critical_activities": critical_activities,
|
||||
}
|
||||
Reference in New Issue
Block a user