17 Commits
master ... main

Author SHA1 Message Date
f57fc14162 Merge branch '002-direct-db-access': Direct database access for scripts (v0.2.0) 2026-01-08 13:02:07 -05:00
05ffc3793c docs: update CLAUDE.md and bump version to 0.2.0
- Add persistent SQLite database to active technologies
- Update recent changes section for 002-direct-db-access
- Bump package version to 0.2.0 in uv.lock
2026-01-08 13:01:49 -05:00
e250cc7444 docs: mark all tasks as complete in tasks.md 2026-01-08 12:56:29 -05:00
d6a79bf24a feat: add direct database access for scripts (v0.2.0)
Implement persistent SQLite database feature that allows scripts to
query schedule data directly via SQL after loading XER files through MCP.

Key changes:
- Extend load_xer with db_path parameter for persistent database
- Add get_database_info tool to retrieve database connection details
- Add schema introspection with tables, columns, primary/foreign keys
- Support WAL mode for concurrent read access
- Use atomic write pattern to prevent corruption

New features:
- db_path=None: in-memory database (default, backward compatible)
- db_path="": auto-generate path from XER filename (.sqlite extension)
- db_path="/path/to/db": explicit persistent database path

Response includes complete DatabaseInfo:
- db_path: absolute path (or :memory:)
- is_persistent: boolean
- source_file: loaded XER path
- loaded_at: ISO timestamp
- schema: tables with columns, primary keys, foreign keys, row counts

Closes: User Story 1, 2, 3 from 002-direct-db-access spec
2026-01-08 12:54:56 -05:00
3e7ad39eb8 docs: add specification and implementation plan for direct database access feature
This feature (002-direct-db-access) enables scripts to query schedule data
directly via SQL after loading XER files through MCP. Key additions:

- spec.md: Feature specification with 3 user stories
- plan.md: Implementation plan with constitution check
- research.md: Technology decisions (SQLite file, WAL mode, atomic writes)
- data-model.md: DatabaseInfo, SchemaInfo, TableInfo entities
- contracts/mcp-tools.json: Extended load_xer schema, new get_database_info tool
- quickstart.md: Usage examples for direct database access
- tasks.md: 16 implementation tasks across 6 phases
2026-01-08 12:38:42 -05:00
48628fd30e Merge branch '001-schedule-tools'
# Conflicts:
#	README.md
2026-01-08 12:22:53 -05:00
a7b6b76db8 feat: add milestone_type field to distinguish start/finish milestones
Add milestone_type field to milestone queries that indicates whether
a milestone is a start milestone ('start') or finish milestone ('finish').

Changes:
- Add milestone_type column to activities table schema
- Parse milestone_type from XER TASK table (MS_Start/MS_Finish)
- Include milestone_type in list_milestones response
- Update contract tests for milestone_type field
- Update specs, contracts, and documentation

The milestone_type is determined by:
1. Explicit milestone_type field in XER (MS_Start -> 'start', MS_Finish -> 'finish')
2. Derived from task_type (TT_Mile -> 'start', TT_FinMile -> 'finish')
2026-01-08 12:18:34 -05:00
bf2f85813e fix: include finish milestones (TT_FinMile) in milestone queries
The list_milestones tool was only returning start milestones (TT_Mile)
and missing all finish milestones. P6 uses two task types for milestones:
- TT_Mile = Start Milestone
- TT_FinMile = Finish Milestone

Changes:
- Update query_milestones() to include both TT_Mile and TT_FinMile
- Derive milestone_type from task_type when not explicitly set:
  - TT_Mile -> 'start'
  - TT_FinMile -> 'finish'
- Add unit tests for milestone_type derivation from task_type

This fixes the E-J Electric schedule returning 5 milestones instead of 62.
2026-01-08 11:55:43 -05:00
af8cdc1d31 feat: add driving flag to relationship query responses
Add computed driving flag to all relationship queries (list_relationships,
get_predecessors, get_successors). A relationship is marked as driving when
the predecessor's early end date plus lag determines the successor's early
start date.

Changes:
- Add early_start_date and early_end_date columns to activities schema
- Parse early dates from TASK table in XER files
- Implement is_driving_relationship() helper with 24hr tolerance for
  calendar gaps
- Update all relationship queries to compute and return driving flag
- Add contract and unit tests for driving flag functionality
- Update spec, contracts, and documentation
2026-01-07 07:21:58 -05:00
2255b65ef6 feat: add data_date to project summary response
Include the schedule data date (last_recalc_date from XER) in the
get_project_summary tool response. This shows when the schedule
was last calculated in P6.

Changes:
- Add last_recalc_date column to projects table schema
- Parse last_recalc_date in PROJECT table handler
- Include last_recalc_date in db loader
- Return data_date field in get_project_summary query
- Update contract test to verify data_date presence
2026-01-06 22:42:10 -05:00
8fc2a87607 chore: add MCP server configuration for project 2026-01-06 22:31:08 -05:00
70c1cf3094 docs: add README with installation and usage instructions 2026-01-06 22:29:53 -05:00
a6413eaaae Initial commit 2026-01-06 21:31:07 -05:00
ccc8296418 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)
2026-01-06 21:27:35 -05:00
2cd54118a1 docs: add implementation task list with 67 tasks
Task breakdown by user story:
- US1 Load XER File (P1): 17 tasks
- US2 Query Activities (P1): 10 tasks
- US3 Query Relationships (P2): 9 tasks
- US4 Query Summary (P3): 9 tasks

TDD mandated: test tasks precede implementation tasks.
Parallel opportunities identified for models, table handlers,
and concurrent user story development after US1.
2026-01-06 21:02:52 -05:00
d3474b0f8b docs: add implementation plan and clarify no-file-loaded errors
Plan artifacts:
- plan.md: Technical context, constitution check, project structure
- research.md: XER format, MCP SDK, SQLite schema decisions
- data-model.md: Entity definitions and database schema
- contracts/mcp-tools.json: MCP tool schemas (9 tools)
- quickstart.md: Usage guide with examples
- CLAUDE.md: Agent context file

Spec updates:
- Add FR-015: NO_FILE_LOADED error requirement
- Add acceptance scenarios for no-file-loaded errors to US3, US4
2026-01-06 20:57:55 -05:00
0170eb7fef docs: add project schedule tools feature specification
Feature spec for MCP tools to query XER schedule data:
- 4 user stories (load file, query activities, relationships, summary)
- 14 functional requirements including pagination (100 item default)
- Clarifications: P6 critical flags, multi-project selection, internal calendars
2026-01-06 19:58:42 -05:00
79 changed files with 9364 additions and 0 deletions

49
.gitignore vendored Normal file
View File

@@ -0,0 +1,49 @@
# Python
__pycache__/
*.py[cod]
*$py.class
*.so
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
# Virtual environments
.venv/
venv/
ENV/
# IDE
.idea/
.vscode/
*.swp
*.swo
# Testing
.pytest_cache/
.coverage
htmlcov/
.tox/
.nox/
# Schedule files
schedules/
# OS
.DS_Store
Thumbs.db
.claude/skills/

8
.mcp.json Normal file
View File

@@ -0,0 +1,8 @@
{
"mcpServers": {
"xer-mcp": {
"command": "uv",
"args": ["run", "python", "-m", "xer_mcp"]
}
}
}

1
.python-version Normal file
View File

@@ -0,0 +1 @@
3.14

35
CLAUDE.md Normal file
View File

@@ -0,0 +1,35 @@
# xer-mcp Development Guidelines
Auto-generated from all feature plans. Last updated: 2026-01-06
## Active Technologies
- SQLite in-memory database (001-schedule-tools)
- Python 3.14 + mcp>=1.0.0 (MCP SDK), sqlite3 (stdlib) (001-schedule-tools)
- In-memory SQLite database (populated from XER files at runtime) (001-schedule-tools)
- SQLite database file (persistent) in addition to existing in-memory option (002-direct-db-access)
- Python 3.14 + mcp (MCP SDK), sqlite3 (stdlib) (001-schedule-tools)
## Project Structure
```text
src/
tests/
```
## Commands
cd src [ONLY COMMANDS FOR ACTIVE TECHNOLOGIES][ONLY COMMANDS FOR ACTIVE TECHNOLOGIES] pytest [ONLY COMMANDS FOR ACTIVE TECHNOLOGIES][ONLY COMMANDS FOR ACTIVE TECHNOLOGIES] ruff check .
## Code Style
Python 3.14: Follow standard conventions
## Recent Changes
- 002-direct-db-access: Added Python 3.14 + mcp>=1.0.0 (MCP SDK), sqlite3 (stdlib)
- 001-schedule-tools: Added Python 3.14 + mcp>=1.0.0 (MCP SDK), sqlite3 (stdlib)
- 001-schedule-tools: Added Python 3.14 + mcp (MCP SDK), sqlite3 (stdlib)
<!-- MANUAL ADDITIONS START -->
<!-- MANUAL ADDITIONS END -->

220
README.md Normal file
View File

@@ -0,0 +1,220 @@
# XER MCP Server
An MCP (Model Context Protocol) server for parsing Primavera P6 XER files and exposing schedule data to AI assistants.
## Features
- Parse Primavera P6 XER export files
- Query activities, relationships, milestones, and critical path
- Pagination support with configurable limits
- Multi-project file support
- In-memory SQLite database for fast queries
## Installation
Requires Python 3.12+
```bash
# Clone the repository
git clone https://git.prettyhefty.com/Bill/xer-mcp.git
cd xer-mcp
# Install with uv
uv sync
# Or install with pip
pip install -e .
```
## Configuration
### Claude Desktop
Add to your Claude Desktop configuration (`~/.config/claude/claude_desktop_config.json` on Linux, `~/Library/Application Support/Claude/claude_desktop_config.json` on macOS):
```json
{
"mcpServers": {
"xer-mcp": {
"command": "uv",
"args": ["run", "--directory", "/path/to/xer-mcp", "python", "-m", "xer_mcp"]
}
}
}
```
### Other MCP Clients
Run the server directly:
```bash
uv run python -m xer_mcp
```
The server communicates via stdio using the MCP protocol.
## Available Tools
### load_xer
Load a Primavera P6 XER file for querying.
**Parameters:**
- `file_path` (required): Absolute path to the XER file
- `project_id` (optional): Project ID to select (required for multi-project files)
**Example:**
```json
{
"file_path": "/path/to/schedule.xer"
}
```
### list_activities
List activities with optional filtering and pagination.
**Parameters:**
- `start_date` (optional): Filter activities starting on or after (YYYY-MM-DD)
- `end_date` (optional): Filter activities ending on or before (YYYY-MM-DD)
- `wbs_id` (optional): Filter by WBS element ID
- `activity_type` (optional): Filter by type (TT_Task, TT_Mile, TT_LOE, TT_WBS, TT_Rsrc)
- `limit` (optional): Maximum results (default: 100, max: 1000)
- `offset` (optional): Number of results to skip (default: 0)
**Returns:** List of activities with pagination metadata
### get_activity
Get detailed information for a specific activity.
**Parameters:**
- `activity_id` (required): The task_id of the activity
**Returns:** Activity details including WBS name and relationship counts
### list_relationships
List all activity relationships (dependencies) with pagination.
**Parameters:**
- `limit` (optional): Maximum results (default: 100, max: 1000)
- `offset` (optional): Number of results to skip (default: 0)
**Returns:** List of relationships with predecessor/successor info
### get_predecessors
Get predecessor activities for a given activity.
**Parameters:**
- `activity_id` (required): The task_id of the activity
**Returns:** List of predecessor activities with relationship type and lag
### get_successors
Get successor activities for a given activity.
**Parameters:**
- `activity_id` (required): The task_id of the activity
**Returns:** List of successor activities with relationship type and lag
### get_project_summary
Get a summary of the loaded project.
**Parameters:** None
**Returns:**
- `project_name`: Name of the project
- `plan_start_date`: Planned start date
- `plan_end_date`: Planned end date
- `activity_count`: Total number of activities
- `milestone_count`: Number of milestones
- `critical_activity_count`: Number of activities on critical path
### list_milestones
List all milestone activities in the project.
**Parameters:** None
**Returns:** List of milestone activities with dates and status
### get_critical_path
Get all activities on the critical path.
**Parameters:** None
**Returns:** List of critical path activities ordered by start date
## Usage Example
1. First, load an XER file:
```
Use the load_xer tool with file_path: "/path/to/my-schedule.xer"
```
2. Get a project overview:
```
Use the get_project_summary tool
```
3. List upcoming milestones:
```
Use the list_milestones tool
```
4. View critical path:
```
Use the get_critical_path tool
```
5. Query specific activities:
```
Use list_activities with start_date: "2026-01-01" and end_date: "2026-03-31"
```
## Error Handling
All query tools return a `NO_FILE_LOADED` error if called before loading an XER file:
```json
{
"error": {
"code": "NO_FILE_LOADED",
"message": "No XER file is loaded. Use the load_xer tool first."
}
}
```
## Relationship Types
The server supports all P6 relationship types:
- **FS** (Finish-to-Start): Successor starts after predecessor finishes
- **SS** (Start-to-Start): Successor starts when predecessor starts
- **FF** (Finish-to-Finish): Successor finishes when predecessor finishes
- **SF** (Start-to-Finish): Successor finishes when predecessor starts
## Development
```bash
# Run tests
uv run pytest
# Run with coverage
uv run pytest --cov=xer_mcp
# Lint
uv run ruff check src/ tests/
# Format
uv run ruff format src/ tests/
```
## License
MIT

50
pyproject.toml Normal file
View File

@@ -0,0 +1,50 @@
[project]
name = "xer-mcp"
version = "0.2.0"
description = "MCP server for querying Primavera P6 XER schedule data"
readme = "README.md"
requires-python = ">=3.14"
dependencies = [
"mcp>=1.0.0",
]
[project.optional-dependencies]
dev = [
"pytest>=8.0.0",
"pytest-asyncio>=0.24.0",
"ruff>=0.8.0",
]
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[tool.hatch.build.targets.wheel]
packages = ["src/xer_mcp"]
[tool.ruff]
line-length = 100
target-version = "py314"
[tool.ruff.lint]
select = [
"E", # pycodestyle errors
"W", # pycodestyle warnings
"F", # Pyflakes
"I", # isort
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"UP", # pyupgrade
]
ignore = [
"E501", # line too long (handled by formatter)
]
[tool.ruff.format]
quote-style = "double"
indent-style = "space"
[tool.pytest.ini_options]
asyncio_mode = "auto"
testpaths = ["tests"]
pythonpath = ["src"]

View File

@@ -0,0 +1,42 @@
# Specification Quality Checklist: Project Schedule Tools
**Purpose**: Validate specification completeness and quality before proceeding to planning
**Created**: 2026-01-06
**Feature**: [spec.md](../spec.md)
## Content Quality
- [x] No implementation details (languages, frameworks, APIs)
- [x] Focused on user value and business needs
- [x] Written for non-technical stakeholders
- [x] All mandatory sections completed
## Requirement Completeness
- [x] No [NEEDS CLARIFICATION] markers remain
- [x] Requirements are testable and unambiguous
- [x] Success criteria are measurable
- [x] Success criteria are technology-agnostic (no implementation details)
- [x] All acceptance scenarios are defined
- [x] Edge cases are identified
- [x] Scope is clearly bounded
- [x] Dependencies and assumptions identified
## Feature Readiness
- [x] All functional requirements have clear acceptance criteria
- [x] User scenarios cover primary flows
- [x] Feature meets measurable outcomes defined in Success Criteria
- [x] No implementation details leak into specification
## Notes
- Specification passed all validation checks
- Clarification session completed 2026-01-06 (4 questions resolved)
- Ready for `/speckit.plan`
- 4 user stories defined (2 P1, 1 P2, 1 P3)
- 14 functional requirements specified (added FR-013, FR-014 for pagination)
- 7 measurable success criteria defined
- 5 edge cases documented
- Pagination limits (100 default) added to User Stories 2 and 3
- Multi-project handling clarified in User Story 1

View File

@@ -0,0 +1,374 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "XER MCP Server Tools",
"description": "MCP tool definitions for Primavera P6 XER file analysis",
"version": "0.1.0",
"tools": [
{
"name": "load_xer",
"description": "Load a Primavera P6 XER file and parse its schedule data. For multi-project files, specify project_id to select a project.",
"inputSchema": {
"type": "object",
"properties": {
"file_path": {
"type": "string",
"description": "Absolute path to the XER file"
},
"project_id": {
"type": "string",
"description": "Project ID to select (required for multi-project files)"
}
},
"required": ["file_path"]
},
"outputSchema": {
"type": "object",
"properties": {
"success": { "type": "boolean" },
"project": {
"type": "object",
"properties": {
"proj_id": { "type": "string" },
"proj_short_name": { "type": "string" },
"plan_start_date": { "type": "string", "format": "date-time" },
"plan_end_date": { "type": "string", "format": "date-time" }
}
},
"activity_count": { "type": "integer" },
"relationship_count": { "type": "integer" },
"available_projects": {
"type": "array",
"items": {
"type": "object",
"properties": {
"proj_id": { "type": "string" },
"proj_short_name": { "type": "string" }
}
},
"description": "Only present for multi-project files without selection"
},
"warnings": {
"type": "array",
"items": { "type": "string" }
}
}
}
},
{
"name": "list_activities",
"description": "List activities from the loaded XER file with optional filtering and pagination.",
"inputSchema": {
"type": "object",
"properties": {
"start_date": {
"type": "string",
"format": "date",
"description": "Filter activities starting on or after this date (YYYY-MM-DD)"
},
"end_date": {
"type": "string",
"format": "date",
"description": "Filter activities ending on or before this date (YYYY-MM-DD)"
},
"wbs_id": {
"type": "string",
"description": "Filter by WBS element ID"
},
"activity_type": {
"type": "string",
"enum": ["TT_Task", "TT_Mile", "TT_LOE", "TT_WBS", "TT_Rsrc"],
"description": "Filter by activity type"
},
"limit": {
"type": "integer",
"default": 100,
"minimum": 1,
"maximum": 1000,
"description": "Maximum number of activities to return"
},
"offset": {
"type": "integer",
"default": 0,
"minimum": 0,
"description": "Number of activities to skip"
}
}
},
"outputSchema": {
"type": "object",
"properties": {
"activities": {
"type": "array",
"items": {
"$ref": "#/$defs/ActivitySummary"
}
},
"pagination": { "$ref": "#/$defs/Pagination" }
}
}
},
{
"name": "get_activity",
"description": "Get detailed information for a specific activity by ID.",
"inputSchema": {
"type": "object",
"properties": {
"activity_id": {
"type": "string",
"description": "The task_id of the activity"
}
},
"required": ["activity_id"]
},
"outputSchema": {
"$ref": "#/$defs/ActivityDetail"
}
},
{
"name": "list_relationships",
"description": "List all relationships (dependencies) with pagination.",
"inputSchema": {
"type": "object",
"properties": {
"limit": {
"type": "integer",
"default": 100,
"minimum": 1,
"maximum": 1000
},
"offset": {
"type": "integer",
"default": 0,
"minimum": 0
}
}
},
"outputSchema": {
"type": "object",
"properties": {
"relationships": {
"type": "array",
"items": { "$ref": "#/$defs/Relationship" }
},
"pagination": { "$ref": "#/$defs/Pagination" }
}
}
},
{
"name": "get_predecessors",
"description": "Get all predecessor activities for a given activity.",
"inputSchema": {
"type": "object",
"properties": {
"activity_id": {
"type": "string",
"description": "The task_id of the activity"
}
},
"required": ["activity_id"]
},
"outputSchema": {
"type": "object",
"properties": {
"activity_id": { "type": "string" },
"predecessors": {
"type": "array",
"items": { "$ref": "#/$defs/RelatedActivity" }
}
}
}
},
{
"name": "get_successors",
"description": "Get all successor activities for a given activity.",
"inputSchema": {
"type": "object",
"properties": {
"activity_id": {
"type": "string",
"description": "The task_id of the activity"
}
},
"required": ["activity_id"]
},
"outputSchema": {
"type": "object",
"properties": {
"activity_id": { "type": "string" },
"successors": {
"type": "array",
"items": { "$ref": "#/$defs/RelatedActivity" }
}
}
}
},
{
"name": "get_project_summary",
"description": "Get high-level summary of the loaded project.",
"inputSchema": {
"type": "object",
"properties": {}
},
"outputSchema": {
"type": "object",
"properties": {
"project": {
"type": "object",
"properties": {
"proj_id": { "type": "string" },
"proj_short_name": { "type": "string" },
"plan_start_date": { "type": "string", "format": "date-time" },
"plan_end_date": { "type": "string", "format": "date-time" }
}
},
"activity_count": { "type": "integer" },
"milestone_count": { "type": "integer" },
"relationship_count": { "type": "integer" },
"wbs_element_count": { "type": "integer" },
"critical_activity_count": { "type": "integer" }
}
}
},
{
"name": "list_milestones",
"description": "List all milestone activities with pagination.",
"inputSchema": {
"type": "object",
"properties": {
"limit": {
"type": "integer",
"default": 100,
"minimum": 1,
"maximum": 1000
},
"offset": {
"type": "integer",
"default": 0,
"minimum": 0
}
}
},
"outputSchema": {
"type": "object",
"properties": {
"milestones": {
"type": "array",
"items": { "$ref": "#/$defs/ActivitySummary" }
},
"pagination": { "$ref": "#/$defs/Pagination" }
}
}
},
{
"name": "get_critical_path",
"description": "Get activities on the critical path (using P6's stored critical flags).",
"inputSchema": {
"type": "object",
"properties": {
"limit": {
"type": "integer",
"default": 100,
"minimum": 1,
"maximum": 1000
},
"offset": {
"type": "integer",
"default": 0,
"minimum": 0
}
}
},
"outputSchema": {
"type": "object",
"properties": {
"critical_activities": {
"type": "array",
"items": { "$ref": "#/$defs/ActivitySummary" }
},
"pagination": { "$ref": "#/$defs/Pagination" }
}
}
}
],
"$defs": {
"ActivitySummary": {
"type": "object",
"properties": {
"task_id": { "type": "string" },
"task_code": { "type": "string" },
"task_name": { "type": "string" },
"task_type": { "type": "string" },
"target_start_date": { "type": "string", "format": "date-time" },
"target_end_date": { "type": "string", "format": "date-time" },
"status_code": { "type": "string" },
"driving_path_flag": { "type": "boolean" },
"milestone_type": { "type": "string", "enum": ["start", "finish", null], "description": "Type of milestone: 'start' for start milestones, 'finish' for finish milestones, null for non-milestones" }
}
},
"ActivityDetail": {
"type": "object",
"properties": {
"task_id": { "type": "string" },
"task_code": { "type": "string" },
"task_name": { "type": "string" },
"task_type": { "type": "string" },
"wbs_id": { "type": "string" },
"wbs_name": { "type": "string" },
"target_start_date": { "type": "string", "format": "date-time" },
"target_end_date": { "type": "string", "format": "date-time" },
"act_start_date": { "type": "string", "format": "date-time" },
"act_end_date": { "type": "string", "format": "date-time" },
"total_float_hr_cnt": { "type": "number" },
"status_code": { "type": "string" },
"driving_path_flag": { "type": "boolean" },
"predecessor_count": { "type": "integer" },
"successor_count": { "type": "integer" }
}
},
"Relationship": {
"type": "object",
"properties": {
"task_pred_id": { "type": "string" },
"task_id": { "type": "string" },
"task_name": { "type": "string" },
"pred_task_id": { "type": "string" },
"pred_task_name": { "type": "string" },
"pred_type": {
"type": "string",
"enum": ["FS", "SS", "FF", "SF"]
},
"lag_hr_cnt": { "type": "number" },
"driving": {
"type": "boolean",
"description": "True if this relationship drives the successor's early start date"
}
}
},
"RelatedActivity": {
"type": "object",
"properties": {
"task_id": { "type": "string" },
"task_code": { "type": "string" },
"task_name": { "type": "string" },
"relationship_type": {
"type": "string",
"enum": ["FS", "SS", "FF", "SF"]
},
"lag_hr_cnt": { "type": "number" },
"driving": {
"type": "boolean",
"description": "True if this relationship drives the successor's early start date"
}
}
},
"Pagination": {
"type": "object",
"properties": {
"total_count": { "type": "integer" },
"offset": { "type": "integer" },
"limit": { "type": "integer" },
"has_more": { "type": "boolean" }
}
}
}
}

View File

@@ -0,0 +1,253 @@
# Data Model: Project Schedule Tools
**Date**: 2026-01-06
**Branch**: `001-schedule-tools`
## Entity Overview
```
┌─────────────┐ ┌─────────────┐
│ Project │───────│ WBS │
└─────────────┘ └─────────────┘
│ │
│ │
▼ ▼
┌─────────────┐ ┌─────────────┐
│ Activity │◄──────│ Relationship│
└─────────────┘ └─────────────┘
┌─────────────┐
│ Calendar │ (internal only)
└─────────────┘
```
## Entities
### Project
Top-level container representing a P6 project.
| Field | Type | Required | Description |
|-------|------|----------|-------------|
| proj_id | string | Yes | Unique project identifier from P6 |
| proj_short_name | string | Yes | Short display name |
| plan_start_date | datetime | No | Planned start date |
| plan_end_date | datetime | No | Planned end date |
| loaded_at | datetime | Yes | When file was loaded into server |
**XER Source**: `PROJECT` table
**Validation Rules**:
- proj_id must be unique within loaded data
- proj_short_name must not be empty
### Activity
A unit of work in the schedule.
| Field | Type | Required | Description |
|-------|------|----------|-------------|
| task_id | string | Yes | Unique activity identifier |
| proj_id | string | Yes | Parent project reference |
| wbs_id | string | No | WBS element reference |
| task_code | string | Yes | User-visible activity code |
| task_name | string | Yes | Activity description |
| task_type | enum | Yes | TT_Task, TT_Mile, TT_LOE, TT_WBS, TT_Rsrc |
| milestone_type | enum | No | 'start' for start milestones, 'finish' for finish milestones, null for non-milestones |
| target_start_date | datetime | No | Planned start |
| target_end_date | datetime | No | Planned finish |
| early_start_date | datetime | No | Calculated early start (for driving computation) |
| early_end_date | datetime | No | Calculated early finish (for driving computation) |
| act_start_date | datetime | No | Actual start |
| act_end_date | datetime | No | Actual finish |
| total_float_hr_cnt | float | No | Total float in hours |
| driving_path_flag | boolean | No | True if on critical path |
| status_code | enum | No | TK_NotStart, TK_Active, TK_Complete |
**XER Source**: `TASK` table
**Validation Rules**:
- task_id must be unique
- task_code must not be empty
- task_name must not be empty
- If act_start_date exists, target_start_date should exist
- If act_end_date exists, act_start_date must exist
**State Transitions**:
```
TK_NotStart ──[actual start recorded]──► TK_Active
TK_Active ──[actual finish recorded]──► TK_Complete
```
### Relationship
A dependency link between two activities.
| Field | Type | Required | Description |
|-------|------|----------|-------------|
| task_pred_id | string | Yes | Unique relationship identifier |
| task_id | string | Yes | Successor activity (the one being constrained) |
| pred_task_id | string | Yes | Predecessor activity (the one constraining) |
| pred_type | enum | Yes | PR_FS, PR_SS, PR_FF, PR_SF |
| lag_hr_cnt | float | No | Lag time in hours (can be negative) |
| driving | boolean | No | **Computed** - True if this relationship determines successor's early dates |
**XER Source**: `TASKPRED` table
**Driving Flag Computation** (not stored, computed at query time):
The `driving` flag indicates whether this predecessor relationship constrains the successor activity's early start date. It is computed by comparing dates:
```python
# For FS (Finish-to-Start) relationships:
driving = (predecessor.early_end_date + lag_hr_cnt successor.early_start_date)
# With 1-hour tolerance for floating point arithmetic
```
This requires JOIN on activity dates when querying relationships.
**Relationship Types**:
| Code | Name | Meaning |
|------|------|---------|
| PR_FS | Finish-to-Start | Successor starts after predecessor finishes |
| PR_SS | Start-to-Start | Successor starts after predecessor starts |
| PR_FF | Finish-to-Finish | Successor finishes after predecessor finishes |
| PR_SF | Start-to-Finish | Successor finishes after predecessor starts |
**Validation Rules**:
- task_id and pred_task_id must reference existing activities
- task_id must not equal pred_task_id (no self-reference)
- pred_type must be one of the four valid types
### WBS (Work Breakdown Structure)
Hierarchical organization of activities.
| Field | Type | Required | Description |
|-------|------|----------|-------------|
| wbs_id | string | Yes | Unique WBS identifier |
| proj_id | string | Yes | Parent project reference |
| parent_wbs_id | string | No | Parent WBS element (null for root) |
| wbs_short_name | string | Yes | Short code |
| wbs_name | string | No | Full description |
| wbs_level | integer | No | Hierarchy depth (0 = root) |
**XER Source**: `PROJWBS` table
**Validation Rules**:
- wbs_id must be unique
- parent_wbs_id must reference existing WBS or be null
- No circular parent references
### Calendar (Internal)
Work schedule definition. Not exposed via MCP tools.
| Field | Type | Required | Description |
|-------|------|----------|-------------|
| clndr_id | string | Yes | Unique calendar identifier |
| clndr_name | string | Yes | Calendar name |
| day_hr_cnt | float | No | Hours per work day |
| week_hr_cnt | float | No | Hours per work week |
**XER Source**: `CALENDAR` table
**Note**: Parsed and stored but not exposed as queryable. Used internally if duration calculations are needed in future.
### PaginationMetadata
Response wrapper for paginated queries.
| Field | Type | Required | Description |
|-------|------|----------|-------------|
| total_count | integer | Yes | Total items matching query |
| offset | integer | Yes | Current offset (0-based) |
| limit | integer | Yes | Items per page |
| has_more | boolean | Yes | True if more items exist |
## SQLite Schema
```sql
-- Projects
CREATE TABLE projects (
proj_id TEXT PRIMARY KEY,
proj_short_name TEXT NOT NULL,
plan_start_date TEXT,
plan_end_date TEXT,
loaded_at TEXT NOT NULL DEFAULT (datetime('now'))
);
-- Activities
CREATE TABLE activities (
task_id TEXT PRIMARY KEY,
proj_id TEXT NOT NULL,
wbs_id TEXT,
task_code TEXT NOT NULL,
task_name TEXT NOT NULL,
task_type TEXT NOT NULL,
target_start_date TEXT,
target_end_date TEXT,
early_start_date TEXT, -- Used for driving relationship computation
early_end_date TEXT, -- Used for driving relationship computation
act_start_date TEXT,
act_end_date TEXT,
total_float_hr_cnt REAL,
driving_path_flag INTEGER DEFAULT 0,
status_code TEXT,
FOREIGN KEY (proj_id) REFERENCES projects(proj_id),
FOREIGN KEY (wbs_id) REFERENCES wbs(wbs_id)
);
-- Relationships
CREATE TABLE relationships (
task_pred_id TEXT PRIMARY KEY,
task_id TEXT NOT NULL,
pred_task_id TEXT NOT NULL,
pred_type TEXT NOT NULL,
lag_hr_cnt REAL DEFAULT 0,
FOREIGN KEY (task_id) REFERENCES activities(task_id),
FOREIGN KEY (pred_task_id) REFERENCES activities(task_id)
);
-- WBS
CREATE TABLE wbs (
wbs_id TEXT PRIMARY KEY,
proj_id TEXT NOT NULL,
parent_wbs_id TEXT,
wbs_short_name TEXT NOT NULL,
wbs_name TEXT,
FOREIGN KEY (proj_id) REFERENCES projects(proj_id),
FOREIGN KEY (parent_wbs_id) REFERENCES wbs(wbs_id)
);
-- Calendars (internal)
CREATE TABLE calendars (
clndr_id TEXT PRIMARY KEY,
clndr_name TEXT NOT NULL,
day_hr_cnt REAL,
week_hr_cnt REAL
);
-- Indexes
CREATE INDEX idx_activities_proj ON activities(proj_id);
CREATE INDEX idx_activities_wbs ON activities(wbs_id);
CREATE INDEX idx_activities_type ON activities(task_type);
CREATE INDEX idx_activities_critical ON activities(driving_path_flag) WHERE driving_path_flag = 1;
CREATE INDEX idx_activities_dates ON activities(target_start_date, target_end_date);
CREATE INDEX idx_relationships_task ON relationships(task_id);
CREATE INDEX idx_relationships_pred ON relationships(pred_task_id);
CREATE INDEX idx_wbs_parent ON wbs(parent_wbs_id);
CREATE INDEX idx_wbs_proj ON wbs(proj_id);
```
## Date Handling
All dates stored as ISO8601 strings in SQLite for portability:
- Format: `YYYY-MM-DDTHH:MM:SS`
- Timezone: Preserved from XER if present, otherwise naive
- Comparisons: String comparison works correctly with ISO8601
XER date format: `YYYY-MM-DD HH:MM` (space-separated, no seconds)
Conversion on import: Add `:00` for seconds, replace space with `T`

View File

@@ -0,0 +1,155 @@
# Implementation Plan: Project Schedule Tools
**Branch**: `001-schedule-tools` | **Date**: 2026-01-08 | **Spec**: [spec.md](./spec.md)
**Input**: Feature specification from `/specs/001-schedule-tools/spec.md`
## Summary
Build an MCP server that provides 9 tools for querying Primavera P6 XER schedule data. The server parses XER files into an in-memory SQLite database and exposes tools for loading files, querying activities, relationships, milestones, critical path, and project summary. Uses Python 3.14 with the MCP SDK and follows TDD practices per the project constitution.
## Technical Context
**Language/Version**: Python 3.14
**Primary Dependencies**: mcp>=1.0.0 (MCP SDK), sqlite3 (stdlib)
**Storage**: In-memory SQLite database (populated from XER files at runtime)
**Testing**: pytest>=8.0.0, pytest-asyncio>=0.24.0
**Target Platform**: Local server (Linux/macOS/Windows with file system access)
**Project Type**: Single project
**Performance Goals**: Load + query XER files ≤5 seconds for 10,000 activities; query response <1 second
**Constraints**: Memory sufficient for 50,000 activities; single-user operation
**Scale/Scope**: MCP server with 9 tools; handles typical P6 project files (up to 50,000 activities)
## Constitution Check
*GATE: Must pass before Phase 0 research. Re-check after Phase 1 design.*
| Principle | Requirement | Status | Notes |
|-----------|-------------|--------|-------|
| **I. Test-First Development** | TDD mandatory; tests fail before implementation | ✅ PASS | Contract tests for all 9 MCP tools; integration tests for XER parsing |
| **II. Extensibility Architecture** | Core parsing separate from MCP transport; pluggable handlers | ✅ PASS | Table handlers are pluggable (`parser/table_handlers/`); tools are modular (`tools/`) |
| **III. MCP Protocol Compliance** | Complete JSON schemas; MCP error format; compliant transport | ✅ PASS | Using official MCP SDK; tool definitions include JSON schemas |
| **IV. XER Format Fidelity** | No data loss; preserve precision; handle all standard tables | ✅ PASS | Parsing TASK, TASKPRED, PROJECT, PROJWBS, CALENDAR; dates preserve precision |
| **V. Semantic Versioning** | SemVer for releases; breaking changes documented | ✅ PASS | Version 0.1.0; initial development phase |
| **Technical Standards** | Python 3.14; type hints; ruff formatting | ✅ PASS | pyproject.toml configured for Python 3.14, ruff, pytest |
**Gate Result**: PASS - All constitution principles satisfied. Proceed to Phase 0.
## Project Structure
### Documentation (this feature)
```text
specs/001-schedule-tools/
├── spec.md # Feature specification
├── plan.md # This file (/speckit.plan command output)
├── research.md # Phase 0 output (/speckit.plan command)
├── data-model.md # Phase 1 output (/speckit.plan command)
├── quickstart.md # Phase 1 output (/speckit.plan command)
├── contracts/ # Phase 1 output (/speckit.plan command)
└── tasks.md # Phase 2 output (/speckit.tasks command - NOT created by /speckit.plan)
```
### Source Code (repository root)
```text
src/xer_mcp/
├── __init__.py
├── __main__.py # Entry point
├── server.py # MCP server setup and tool registration
├── errors.py # Error types
├── models/ # Data models (dataclasses)
│ ├── __init__.py
│ ├── project.py
│ ├── activity.py
│ ├── relationship.py
│ ├── wbs.py
│ ├── calendar.py
│ └── pagination.py
├── parser/ # XER file parsing
│ ├── __init__.py
│ ├── xer_parser.py # Main parser
│ └── table_handlers/ # Pluggable table handlers
│ ├── __init__.py
│ ├── base.py
│ ├── project.py
│ ├── task.py
│ ├── taskpred.py
│ ├── projwbs.py
│ └── calendar.py
├── db/ # SQLite database layer
│ ├── __init__.py
│ ├── schema.py # Table definitions
│ ├── loader.py # Data loading
│ └── queries.py # Query functions
└── tools/ # MCP tool implementations
├── __init__.py
├── load_xer.py
├── list_activities.py
├── get_activity.py
├── list_relationships.py
├── get_predecessors.py
├── get_successors.py
├── get_project_summary.py
├── list_milestones.py
└── get_critical_path.py
tests/
├── __init__.py
├── conftest.py # Shared fixtures
├── contract/ # MCP tool contract tests
│ ├── __init__.py
│ ├── test_load_xer.py
│ ├── test_list_activities.py
│ ├── test_get_activity.py
│ ├── test_list_relationships.py
│ ├── test_get_predecessors.py
│ ├── test_get_successors.py
│ ├── test_get_project_summary.py
│ ├── test_list_milestones.py
│ └── test_get_critical_path.py
├── integration/ # XER parsing integration tests
│ ├── __init__.py
│ └── test_xer_parsing.py
└── unit/ # Unit tests
├── __init__.py
├── test_parser.py
├── test_table_handlers.py
└── test_db_queries.py
```
**Structure Decision**: Single project structure with domain-specific organization: `models/` for data structures, `parser/` for XER file handling with pluggable table handlers, `db/` for SQLite storage layer, and `tools/` for MCP tool implementations. Tests follow contract/integration/unit hierarchy per constitution requirements.
## Complexity Tracking
> **Fill ONLY if Constitution Check has violations that must be justified**
No violations. All constitution principles satisfied.
## Post-Design Constitution Re-Check
*Re-evaluation after Phase 1 design artifacts are complete.*
| Principle | Status | Verification |
|-----------|--------|--------------|
| **I. Test-First Development** | ✅ PASS | Contract tests defined in `tests/contract/` for all 9 tools; integration tests in `tests/integration/` |
| **II. Extensibility Architecture** | ✅ PASS | Table handlers pluggable via registry pattern; tools are modular functions; schema separates concerns |
| **III. MCP Protocol Compliance** | ✅ PASS | `contracts/mcp-tools.json` defines complete JSON schemas for all tools with input/output schemas |
| **IV. XER Format Fidelity** | ✅ PASS | Data model preserves all date precision; handles all 5 standard tables; driving flag computed accurately |
| **V. Semantic Versioning** | ✅ PASS | Version 0.1.0 in contract schema; following SemVer |
| **Technical Standards** | ✅ PASS | Type hints throughout models; ruff configured; pytest async mode enabled |
**Post-Design Gate Result**: PASS - Design artifacts align with constitution. Ready for task generation.
## Generated Artifacts
| Artifact | Path | Description |
|----------|------|-------------|
| Research | `specs/001-schedule-tools/research.md` | Technology decisions, XER format analysis, driving flag computation |
| Data Model | `specs/001-schedule-tools/data-model.md` | Entity definitions, SQLite schema, validation rules |
| Contracts | `specs/001-schedule-tools/contracts/mcp-tools.json` | MCP tool JSON schemas (input/output) |
| Quickstart | `specs/001-schedule-tools/quickstart.md` | Usage guide with examples |
| Agent Context | `CLAUDE.md` | Updated with Python 3.14, MCP SDK, SQLite |
## Next Steps
Run `/speckit.tasks` to generate implementation tasks from this plan.

View File

@@ -0,0 +1,302 @@
# Quickstart: XER MCP Server
This guide shows how to set up and use the XER MCP Server for querying Primavera P6 schedule data.
## Prerequisites
- Python 3.14+
- uv package manager
- An XER file exported from Primavera P6
## Installation
```bash
# Clone the repository
git clone <repo-url>
cd xer-mcp
# Install dependencies with uv
uv sync
# Verify installation
uv run python -m xer_mcp --help
```
## Configuration
Add the server to your MCP client configuration (e.g., Claude Desktop):
```json
{
"mcpServers": {
"xer-mcp": {
"command": "uv",
"args": ["run", "python", "-m", "xer_mcp"],
"cwd": "/path/to/xer-mcp"
}
}
}
```
## Basic Usage
### 1. Load an XER File
```
Use the load_xer tool with file_path="/path/to/schedule.xer"
```
**Response** (single project):
```json
{
"success": true,
"project": {
"proj_id": "P001",
"proj_short_name": "Construction Phase 1",
"plan_start_date": "2026-01-15T00:00:00",
"plan_end_date": "2026-06-30T00:00:00"
},
"activity_count": 450,
"relationship_count": 520
}
```
**Response** (multi-project, no selection):
```json
{
"success": false,
"available_projects": [
{"proj_id": "P001", "proj_short_name": "Phase 1"},
{"proj_id": "P002", "proj_short_name": "Phase 2"}
],
"message": "Multiple projects found. Please specify project_id."
}
```
### 2. List Activities
```
Use the list_activities tool
```
**Response**:
```json
{
"activities": [
{
"task_id": "A1000",
"task_code": "A1000",
"task_name": "Site Preparation",
"task_type": "TT_Task",
"target_start_date": "2026-01-15T08:00:00",
"target_end_date": "2026-01-22T17:00:00",
"status_code": "TK_NotStart",
"driving_path_flag": true
}
],
"pagination": {
"total_count": 450,
"offset": 0,
"limit": 100,
"has_more": true
}
}
```
### 3. Filter Activities by Date Range
```
Use the list_activities tool with start_date="2026-02-01" and end_date="2026-02-28"
```
### 4. Get Activity Details
```
Use the get_activity tool with activity_id="A1000"
```
**Response**:
```json
{
"task_id": "A1000",
"task_code": "A1000",
"task_name": "Site Preparation",
"task_type": "TT_Task",
"wbs_id": "WBS001",
"wbs_name": "Pre-Construction",
"target_start_date": "2026-01-15T08:00:00",
"target_end_date": "2026-01-22T17:00:00",
"act_start_date": null,
"act_end_date": null,
"total_float_hr_cnt": 0,
"status_code": "TK_NotStart",
"driving_path_flag": true,
"predecessor_count": 0,
"successor_count": 5
}
```
### 5. Query Predecessors/Successors
```
Use the get_predecessors tool with activity_id="A1050"
```
**Response**:
```json
{
"activity_id": "A1050",
"predecessors": [
{
"task_id": "A1000",
"task_code": "A1000",
"task_name": "Site Preparation",
"relationship_type": "FS",
"lag_hr_cnt": 0,
"driving": true
},
{
"task_id": "A1010",
"task_code": "A1010",
"task_name": "Permits Approved",
"relationship_type": "FS",
"lag_hr_cnt": 8,
"driving": false
}
]
}
```
The `driving` flag indicates which predecessor relationship constrains the successor's early start date. A driving relationship is one where the predecessor's completion (plus lag) determines when the successor can begin.
### 6. Get Project Summary
```
Use the get_project_summary tool
```
**Response**:
```json
{
"project": {
"proj_id": "P001",
"proj_short_name": "Construction Phase 1",
"plan_start_date": "2026-01-15T00:00:00",
"plan_end_date": "2026-06-30T00:00:00"
},
"activity_count": 450,
"milestone_count": 25,
"relationship_count": 520,
"wbs_element_count": 30,
"critical_activity_count": 85
}
```
### 7. Get Critical Path
```
Use the get_critical_path tool
```
**Response**:
```json
{
"critical_activities": [
{
"task_id": "A1000",
"task_code": "A1000",
"task_name": "Site Preparation",
"task_type": "TT_Task",
"target_start_date": "2026-01-15T08:00:00",
"target_end_date": "2026-01-22T17:00:00"
}
],
"pagination": {
"total_count": 85,
"offset": 0,
"limit": 100,
"has_more": false
}
}
```
### 8. List Milestones
```
Use the list_milestones tool
```
**Response**:
```json
{
"milestones": [
{
"task_id": "M001",
"task_code": "MS-START",
"task_name": "Project Start",
"target_start_date": "2026-01-15T08:00:00",
"target_end_date": "2026-01-15T08:00:00",
"status_code": "TK_Complete",
"milestone_type": "start"
},
{
"task_id": "M025",
"task_code": "MS-END",
"task_name": "Project Complete",
"target_start_date": "2026-06-30T17:00:00",
"target_end_date": "2026-06-30T17:00:00",
"status_code": "TK_NotStart",
"milestone_type": "finish"
}
]
}
```
The `milestone_type` field indicates whether the milestone is a Start Milestone (`"start"`) or a Finish Milestone (`"finish"`).
## Pagination
All list operations support pagination:
```
Use the list_activities tool with limit=50 and offset=100
```
This returns activities 101-150 (0-indexed).
## Error Handling
| Error | Meaning | Solution |
|-------|---------|----------|
| FILE_NOT_FOUND | XER file path doesn't exist | Check file path |
| PARSE_ERROR | XER file is malformed | Verify file is valid P6 export |
| NO_FILE_LOADED | Query before load_xer | Call load_xer first |
| PROJECT_SELECTION_REQUIRED | Multi-project file | Specify project_id in load_xer |
| ACTIVITY_NOT_FOUND | Invalid activity_id | Check activity exists |
## Relationship Types
| Code | Name | Meaning |
|------|------|---------|
| FS | Finish-to-Start | B starts after A finishes |
| SS | Start-to-Start | B starts after A starts |
| FF | Finish-to-Finish | B finishes after A finishes |
| SF | Start-to-Finish | B finishes after A starts |
## Activity Types
| Code | Name | Description |
|------|------|-------------|
| TT_Task | Task | Normal work activity with duration |
| TT_Mile | Milestone | Zero-duration marker |
| TT_LOE | Level of Effort | Duration spans linked activities |
| TT_WBS | WBS Summary | Summary of child activities |
| TT_Rsrc | Resource Dependent | Duration from resource assignment |
## Tips for AI Assistants
1. **Start with summary**: Call `get_project_summary` first to understand scope
2. **Use pagination**: Large schedules may have thousands of activities
3. **Filter early**: Use date ranges and WBS filters to reduce results
4. **Check critical path**: `get_critical_path` identifies schedule-driving work
5. **Follow relationships**: Use `get_predecessors`/`get_successors` to trace dependencies

View File

@@ -0,0 +1,277 @@
# Research: Project Schedule Tools
**Date**: 2026-01-06
**Branch**: `001-schedule-tools`
## XER File Format
### Decision: Parse tab-delimited format with %T table headers
**Rationale**: XER is Primavera P6's native export format. It uses a simple text-based structure that's straightforward to parse without external libraries.
**Format Structure**:
```
ERMHDR ...header info...
%T TABLE_NAME
%F field1 field2 field3 ...
%R value1 value2 value3 ...
%R value1 value2 value3 ...
%T NEXT_TABLE
...
%E
```
**Key Tables for Schedule Tools**:
| Table | Purpose | Key Fields |
|-------|---------|------------|
| PROJECT | Project metadata | proj_id, proj_short_name, plan_start_date, plan_end_date |
| TASK | Activities | task_id, task_code, task_name, task_type, target_start_date, target_end_date, act_start_date, act_end_date, driving_path_flag |
| TASKPRED | Relationships | task_pred_id, task_id, pred_task_id, pred_type, lag_hr_cnt |
| PROJWBS | WBS structure | wbs_id, wbs_short_name, wbs_name, parent_wbs_id, proj_id |
| CALENDAR | Work calendars | clndr_id, clndr_name, day_hr_cnt |
**Alternatives Considered**:
- XML export: More complex to parse, larger file sizes
- Database direct access: Requires P6 installation, not portable
## MCP Python SDK
### Decision: Use `mcp` package with stdio transport
**Rationale**: The official MCP Python SDK provides a clean async interface for building MCP servers. Stdio transport is simplest for local tools.
**Implementation Pattern**:
```python
from mcp.server import Server
from mcp.server.stdio import stdio_server
server = Server("xer-mcp")
@server.tool()
async def load_xer(file_path: str, project_id: str | None = None) -> dict:
"""Load an XER file and optionally select a project."""
...
async def main():
async with stdio_server() as (read_stream, write_stream):
await server.run(read_stream, write_stream, server.create_initialization_options())
```
**Key Considerations**:
- All tools are async functions decorated with `@server.tool()`
- Tool parameters use Python type hints for JSON schema generation
- Return values are automatically serialized to JSON
- Errors should raise `McpError` with appropriate error codes
**Alternatives Considered**:
- SSE transport: Adds complexity, not needed for local use
- Custom protocol: Would break MCP compatibility
## SQLite Schema Design
### Decision: In-memory SQLite with normalized tables
**Rationale**: SQLite in-memory mode provides fast queries without file I/O overhead. Normalized tables map directly to XER structure while enabling efficient JOINs for relationship queries.
**Schema Design**:
```sql
-- Project table
CREATE TABLE projects (
proj_id TEXT PRIMARY KEY,
proj_short_name TEXT NOT NULL,
plan_start_date TEXT, -- ISO8601
plan_end_date TEXT,
loaded_at TEXT NOT NULL
);
-- Activities table
CREATE TABLE activities (
task_id TEXT PRIMARY KEY,
proj_id TEXT NOT NULL REFERENCES projects(proj_id),
wbs_id TEXT,
task_code TEXT NOT NULL,
task_name TEXT NOT NULL,
task_type TEXT, -- TT_Task, TT_Mile, TT_LOE, etc.
target_start_date TEXT,
target_end_date TEXT,
act_start_date TEXT,
act_end_date TEXT,
total_float_hr_cnt REAL,
driving_path_flag TEXT, -- 'Y' or 'N'
status_code TEXT
);
-- Relationships table
CREATE TABLE relationships (
task_pred_id TEXT PRIMARY KEY,
task_id TEXT NOT NULL REFERENCES activities(task_id),
pred_task_id TEXT NOT NULL REFERENCES activities(task_id),
pred_type TEXT NOT NULL, -- PR_FS, PR_SS, PR_FF, PR_SF
lag_hr_cnt REAL DEFAULT 0
);
-- WBS table
CREATE TABLE wbs (
wbs_id TEXT PRIMARY KEY,
proj_id TEXT NOT NULL REFERENCES projects(proj_id),
parent_wbs_id TEXT REFERENCES wbs(wbs_id),
wbs_short_name TEXT NOT NULL,
wbs_name TEXT
);
-- Indexes for common queries
CREATE INDEX idx_activities_proj ON activities(proj_id);
CREATE INDEX idx_activities_wbs ON activities(wbs_id);
CREATE INDEX idx_activities_type ON activities(task_type);
CREATE INDEX idx_activities_dates ON activities(target_start_date, target_end_date);
CREATE INDEX idx_relationships_task ON relationships(task_id);
CREATE INDEX idx_relationships_pred ON relationships(pred_task_id);
CREATE INDEX idx_wbs_parent ON wbs(parent_wbs_id);
```
**Query Patterns**:
- Pagination: `LIMIT ? OFFSET ?` with `COUNT(*)` for total
- Date filtering: `WHERE target_start_date >= ? AND target_end_date <= ?`
- Critical path: `WHERE driving_path_flag = 'Y'`
- Predecessors: `SELECT * FROM relationships WHERE task_id = ?`
- Successors: `SELECT * FROM relationships WHERE pred_task_id = ?`
**Alternatives Considered**:
- File-based SQLite: Adds complexity for file management, not needed for single-session use
- In-memory dictionaries: Would require custom indexing for efficient queries
- DuckDB: Overkill for this use case, larger dependency
## XER Parsing Strategy
### Decision: Streaming line-by-line parser with table handler registry
**Rationale**: XER files can be large (50K+ activities). Streaming avoids loading entire file into memory. Table handler registry enables extensibility per constitution.
**Implementation Approach**:
1. Read file line by line
2. Track current table context (%T lines)
3. Parse %F lines as field headers
4. Parse %R lines as records using current field map
5. Dispatch to registered table handler
6. Handler converts to model and inserts into SQLite
**Encoding Handling**:
- XER files use Windows-1252 encoding by default
- Attempt UTF-8 first, fallback to Windows-1252
- Log encoding detection result
## Pagination Implementation
### Decision: Offset-based pagination with metadata
**Rationale**: Simple to implement with SQLite's LIMIT/OFFSET. Metadata enables clients to navigate results.
**Response Format**:
```python
@dataclass
class PaginatedResponse:
items: list[dict]
pagination: PaginationMetadata
@dataclass
class PaginationMetadata:
total_count: int
offset: int
limit: int
has_more: bool
```
**Default Limit**: 100 items (per spec clarification)
## Error Handling
### Decision: Structured MCP errors with codes
**Rationale**: MCP protocol defines error format. Consistent error codes help clients handle failures.
**Error Codes**:
| Code | Name | When Used |
|------|------|-----------|
| -32001 | FILE_NOT_FOUND | XER file path doesn't exist |
| -32002 | PARSE_ERROR | XER file is malformed |
| -32003 | NO_FILE_LOADED | Query attempted before load |
| -32004 | PROJECT_SELECTION_REQUIRED | Multi-project file without selection |
| -32005 | ACTIVITY_NOT_FOUND | Requested activity ID doesn't exist |
| -32006 | INVALID_PARAMETER | Bad filter/pagination parameters |
## Driving Relationship Flag
**Research Date**: 2026-01-06
### Question: What field in the XER TASKPRED table contains the driving relationship flag?
**Finding**: The TASKPRED table in P6 XER files does NOT contain a direct `driving_flag` field.
**Evidence**: Analysis of sample XER file (S48019R - Proposal Schedule):
```
%F task_pred_id task_id pred_task_id proj_id pred_proj_id pred_type lag_hr_cnt comments float_path aref arls
```
Fields available:
- `task_pred_id` - Unique relationship identifier
- `task_id` - Successor activity ID
- `pred_task_id` - Predecessor activity ID
- `proj_id` / `pred_proj_id` - Project identifiers
- `pred_type` - Relationship type (PR_FS, PR_SS, PR_FF, PR_SF)
- `lag_hr_cnt` - Lag duration in hours
- `comments` - User comments
- `float_path` - Float path indicator (contains dates, not boolean)
- `aref` / `arls` - Activity reference dates
### Question: Where is driving/critical path information stored in P6 XER files?
**Finding**: The `driving_path_flag` is stored at the ACTIVITY level on the TASK table, not on individual relationships.
**Evidence**:
```
TASK table includes: driving_path_flag (Y/N)
```
This flag indicates whether an activity is on the driving/critical path, but does not indicate which specific predecessor relationship is driving that activity's dates.
### Question: Can driving relationships be derived from available data?
**Finding**: Yes, driving relationships can be computed using schedule date comparison logic.
A relationship is "driving" when the successor activity's early start is constrained by the predecessor's completion. For a Finish-to-Start (FS) relationship:
```
driving = (predecessor.early_end_date + lag_hours ≈ successor.early_start_date)
```
### Decision: Compute driving flag at query time using early dates
**Rationale**:
1. P6 does not export a pre-computed driving flag per relationship
2. The driving relationship determination can be computed from activity dates
3. This matches how P6 itself determines driving relationships in the UI
**Implementation Approach**:
1. Early dates (`early_start_date`, `early_end_date`) are already parsed from TASK table
2. When querying relationships, compute `driving` by comparing dates
3. For FS: Compare `pred.early_end_date + lag` to `succ.early_start_date`
4. Use 1-hour tolerance for floating point date arithmetic
**Alternatives Considered**:
1. **Static flag from XER**: Not available in standard exports
2. **Always false**: Would not provide value to users
3. **Require user to specify**: Adds complexity, not aligned with P6 behavior
### Schema Impact
No schema changes needed for relationships table. Required activity date columns are already present:
- `activities.early_start_date` - Already in schema ✓
- `activities.early_end_date` - Already in schema ✓
The driving flag will be computed at query time via JOIN on activity dates.
### Validation Plan
- [ ] Verify early_start_date and early_end_date are parsed correctly from TASK table
- [ ] Test driving computation against known P6 schedules
- [ ] Confirm results match P6 "show driving" feature where possible

View File

@@ -0,0 +1,152 @@
# Feature Specification: Project Schedule Tools
**Feature Branch**: `001-schedule-tools`
**Created**: 2026-01-06
**Status**: Draft
**Input**: User description: "MCP tools to query activities, relationships, and schedules from XER data"
## User Scenarios & Testing *(mandatory)*
### User Story 1 - Load XER File (Priority: P1)
As an AI assistant user, I want to load an XER file into the MCP server so that I can query its schedule data.
**Why this priority**: This is a prerequisite for all other functionality - no queries are possible without first loading data.
**Independent Test**: Can be tested by providing a file path and verifying the file is successfully parsed and available for queries.
**Acceptance Scenarios**:
1. **Given** a valid XER file path with a single project, **When** I request to load the file, **Then** the file is parsed, the project is auto-selected, and a success confirmation is returned with basic file info (project name, activity count)
2. **Given** a valid XER file path with multiple projects, **When** I request to load the file without specifying a project, **Then** I receive a list of available projects and a prompt to select one
3. **Given** a valid XER file path with multiple projects, **When** I request to load the file with a specific project ID, **Then** that project is selected and loaded
4. **Given** an invalid file path, **When** I request to load the file, **Then** I receive a clear error message indicating the file was not found
5. **Given** a corrupted or invalid XER file, **When** I request to load the file, **Then** I receive a clear error message describing the parsing failure
6. **Given** a file is already loaded, **When** I load a new file, **Then** the previous data is replaced with the new file's data
---
### User Story 2 - Query Project Activities (Priority: P1)
As an AI assistant user, I want to query activities from a loaded XER file so that I can understand what work is planned in the project schedule.
**Why this priority**: Activities are the fundamental building blocks of any P6 schedule. Without the ability to query activities, no other schedule analysis is possible.
**Independent Test**: Can be fully tested by loading an XER file and querying for activities. Delivers immediate value by exposing schedule data to AI assistants.
**Acceptance Scenarios**:
1. **Given** an XER file is loaded, **When** I request all activities, **Then** I receive a list of activities with their names, IDs, and dates (limited to 100 by default)
2. **Given** an XER file is loaded, **When** I request activities filtered by date range, **Then** I receive only activities that fall within that range (limited to 100 by default)
3. **Given** an XER file is loaded, **When** I request a specific activity by ID, **Then** I receive the complete details for that activity
4. **Given** no XER file is loaded, **When** I request activities, **Then** I receive a clear error message indicating no file is loaded
5. **Given** an XER file with more than 100 activities, **When** I request activities without specifying a limit, **Then** I receive the first 100 activities plus pagination metadata (total count, has_more flag)
6. **Given** an XER file is loaded, **When** I request activities with offset and limit parameters, **Then** I receive the specified page of results
---
### User Story 3 - Query Activity Relationships (Priority: P2)
As an AI assistant user, I want to query the relationships (dependencies) between activities so that I can understand the logical sequence of work and identify critical paths.
**Why this priority**: Relationships define the logical flow of work and are essential for schedule analysis, but require activities to be queryable first.
**Independent Test**: Can be tested by loading an XER file and querying predecessor/successor relationships for any activity.
**Acceptance Scenarios**:
1. **Given** an XER file is loaded, **When** I request predecessors for an activity, **Then** I receive a list of predecessor activities with their relationship types (FS, SS, FF, SF), lag values, and driving flag
2. **Given** an XER file is loaded, **When** I request successors for an activity, **Then** I receive a list of successor activities with their relationship types, lag values, and driving flag
3. **Given** an activity has no predecessors, **When** I request its predecessors, **Then** I receive an empty list (not an error)
4. **Given** an XER file is loaded, **When** I request all relationships, **Then** I receive the dependency network with relationship types, lag values, and driving flags (limited to 100 by default) with pagination metadata
5. **Given** an XER file is loaded, **When** I request relationships with offset and limit parameters, **Then** I receive the specified page of results
6. **Given** no XER file is loaded, **When** I request relationships or predecessors/successors, **Then** I receive a clear error message indicating no file is loaded
---
### User Story 4 - Query Project Summary (Priority: P3)
As an AI assistant user, I want to get a high-level summary of the project schedule so that I can quickly understand project scope, timeline, and key milestones.
**Why this priority**: Provides valuable context for AI analysis but depends on activity and relationship data being accessible first.
**Independent Test**: Can be tested by loading an XER file and requesting project summary information.
**Acceptance Scenarios**:
1. **Given** an XER file is loaded, **When** I request the project summary, **Then** I receive project name, data date, start date, finish date, and total activity count
2. **Given** an XER file with milestones, **When** I request milestones, **Then** I receive a list of all milestone activities (both Start Milestones and Finish Milestones) with their target dates and milestone type
3. **Given** an XER file is loaded, **When** I request the critical path, **Then** I receive the sequence of activities that determine the project end date
4. **Given** no XER file is loaded, **When** I request project summary, milestones, or critical path, **Then** I receive a clear error message indicating no file is loaded
---
### Edge Cases
- What happens when an XER file contains no activities? Return empty results with a clear indication that the file has no schedule data.
- What happens when activity IDs are duplicated in the XER file? Use the last occurrence and log a warning.
- What happens when relationship references point to non-existent activities? Skip invalid relationships and include them in a warnings list.
- What happens when date fields are missing or malformed? Use null values for missing dates and report parsing warnings.
- What happens when the XER file uses an unsupported version format? Attempt best-effort parsing and report version compatibility warnings.
## Requirements *(mandatory)*
### Functional Requirements
- **FR-001**: System MUST parse standard Primavera P6 XER file format and extract schedule data
- **FR-002**: System MUST expose an MCP tool to load an XER file from a specified file path
- **FR-003**: System MUST expose an MCP tool to list all activities with filtering options (by date range, by WBS, by activity type)
- **FR-004**: System MUST expose an MCP tool to retrieve detailed information for a specific activity by ID
- **FR-005**: System MUST expose an MCP tool to query predecessor and successor relationships for any activity, including relationship type, lag value, and driving flag
- **FR-006**: System MUST expose an MCP tool to retrieve project summary information (name, data date, plan dates, activity count)
- **FR-007**: System MUST expose an MCP tool to list milestone activities, including both Start Milestones (TT_Mile with task_type='TT_Mile' and milestone_type='start') and Finish Milestones (task_type='TT_Mile' and milestone_type='finish')
- **FR-008**: System MUST expose an MCP tool to identify the critical path
- **FR-009**: System MUST return structured data that AI assistants can process and present to users
- **FR-010**: System MUST provide clear, actionable error messages when operations fail
- **FR-011**: System MUST preserve all date/time precision from the original XER file
- **FR-012**: System MUST handle XER files with multiple projects by requiring explicit project selection; single-project files auto-select the only project
- **FR-013**: System MUST implement pagination for list queries with a default limit of 100 items, supporting offset and limit parameters
- **FR-014**: System MUST return pagination metadata (total_count, has_more, offset, limit) with all paginated responses
- **FR-015**: System MUST return an informative error (NO_FILE_LOADED) when any query tool is invoked before an XER file has been successfully loaded
### Key Entities
- **Project**: The top-level container representing a P6 project with name, ID, start/finish dates, and calendar assignments
- **Activity**: A unit of work with ID, name, type (task/milestone/LOE), milestone_type (start/finish for milestones, null otherwise), planned dates, actual dates, duration, and status
- **Relationship**: A dependency link between two activities with type (FS/SS/FF/SF), lag value, and driving flag
- **WBS (Work Breakdown Structure)**: Hierarchical organization of activities with ID, name, parent reference, and level
- **Calendar**: Work schedule definition that determines working days and hours for activities (internal use only; not exposed as queryable entity)
- **Resource**: Labor, equipment, or material assigned to activities (exposed for future resource analysis features)
## Success Criteria *(mandatory)*
### Measurable Outcomes
- **SC-001**: Users can load and query an XER file within 5 seconds for files up to 10,000 activities
- **SC-002**: Users can retrieve activity details in under 1 second after file is loaded
- **SC-003**: All standard XER table types used in schedule analysis are correctly parsed (TASK, TASKPRED, PROJECT, PROJWBS, CALENDAR)
- **SC-004**: 100% of valid relationship types (FS, SS, FF, SF) are correctly identified and queryable
- **SC-005**: Users receive actionable error messages that identify the specific issue when operations fail
- **SC-006**: Critical path identification uses P6's stored critical flags, ensuring exact match with P6's own critical path
- **SC-007**: AI assistants can successfully integrate with the MCP server and execute all exposed tools
## Clarifications
### Session 2026-01-06
- Q: What should be the default result limit for activity/relationship queries? → A: 100 items default limit per query
- Q: How should critical path be determined? → A: Use P6's stored critical flags from XER data
- Q: How should multi-project XER files be handled? → A: Require explicit project selection if multiple exist
- Q: Should calendar data be exposed as queryable? → A: Internal use only (not exposed as queryable)
- Q: What happens when any query tool is called without a file loaded? → A: Return informative error indicating no XER file is loaded; applies to all tools except load_xer
- Q: Should project summary include the data date? → A: Yes, include the data date (schedule "as-of" date) in project summary response
- Q: Should relationship queries return the driving flag? → A: Yes, include the driving property in all relationship responses (predecessors, successors, list relationships)
- Q: Which milestone types should be included in milestone queries? → A: Include both Start Milestones and Finish Milestones
## Assumptions
- XER files follow the standard Primavera P6 export format (tab-delimited with %T headers)
- The MCP server runs locally and has file system access to read XER files
- Users have valid XER files exported from P6 (versions 6.0 through current)
- Single-user operation - no concurrent access handling required for MVP
- Memory is sufficient to hold parsed schedule data for typical project sizes (up to 50,000 activities)

View File

@@ -0,0 +1,255 @@
# Tasks: Add Milestone Type to List Milestones Tool
**Input**: Design documents from `/specs/001-schedule-tools/`
**Prerequisites**: plan.md (required), spec.md (required), research.md, data-model.md, contracts/
**Tests**: TDD is mandated by constitution - tests MUST be written and fail before implementation.
**Scope**: Enhancement to existing implementation - add `milestone_type` (start/finish) to milestone query responses per spec clarification.
**Change Summary**: The spec was updated to require that the `list_milestones` tool return both Start Milestones and Finish Milestones with their `milestone_type` field (start/finish for milestones, null otherwise).
## Format: `[ID] [P?] [Story] Description`
- **[P]**: Can run in parallel (different files, no dependencies)
- **[Story]**: Which user story this task belongs to (US4 = Query Project Summary)
- Include exact file paths in descriptions
## Path Conventions
- **Source**: `src/xer_mcp/`
- **Tests**: `tests/`
- **Config**: `pyproject.toml`
---
## Phase 1: Setup (Schema Enhancement)
**Purpose**: Add milestone_type column needed for distinguishing start vs finish milestones
- [x] T001 Update activities table schema to add milestone_type column in src/xer_mcp/db/schema.py
---
## Phase 2: Foundational (Parser Enhancement)
**Purpose**: Parse milestone_type from TASK table and store in database
**⚠️ CRITICAL**: Must complete before milestone queries can return the type
### Tests
- [x] T002 [P] Unit test for TASK handler parsing milestone_type in tests/unit/test_table_handlers.py (verify milestone_type extracted for TT_Mile activities)
### Implementation
- [x] T003 Update TASK table handler to parse milestone_type field in src/xer_mcp/parser/table_handlers/task.py
- [x] T004 Update database loader to store milestone_type when inserting activities in src/xer_mcp/db/loader.py
**Checkpoint**: milestone_type is now parsed and stored - queries can begin
---
## Phase 3: User Story 4 - Add Milestone Type to Queries (Priority: P3)
**Goal**: Return `milestone_type` field in milestone query responses
**Independent Test**: Load XER file, query milestones, verify milestone_type is present and correctly identifies start vs finish milestones
### Tests for User Story 4
> **NOTE: Write these tests FIRST, ensure they FAIL before implementation**
- [x] T005 [P] [US4] Update contract test to verify milestone_type field in list_milestones response in tests/contract/test_list_milestones.py
- [x] T006 [P] [US4] Add test case verifying both start and finish milestones are returned with correct types in tests/contract/test_list_milestones.py
### Implementation for User Story 4
- [x] T007 [US4] Update query_milestones function to SELECT and return milestone_type in src/xer_mcp/db/queries.py
- [x] T008 [US4] Update list_milestones tool docstring to document milestone_type field in src/xer_mcp/tools/list_milestones.py
**Checkpoint**: milestone_type now included in milestone responses
---
## Phase 4: Documentation & Contracts
**Purpose**: Update contracts and documentation to reflect the new field
- [x] T009 [P] Update ActivitySummary schema to include optional milestone_type field in specs/001-schedule-tools/contracts/mcp-tools.json
- [x] T010 [P] Update Activity entity in data-model.md to include milestone_type field in specs/001-schedule-tools/data-model.md
- [x] T011 Update quickstart.md milestone example to show milestone_type in output in specs/001-schedule-tools/quickstart.md
---
## Phase 5: Polish & Validation
**Purpose**: Verify integration and ensure no regressions
- [x] T012 Run all tests to verify no regressions: uv run pytest tests/
- [x] T013 Run ruff check and fix any linting issues: uv run ruff check src/
- [x] T014 Validate list_milestones output matches updated contract schema
---
## Dependencies & Execution Order
### Phase Dependencies
```
Phase 1 (Schema)
Phase 2 (Parser)
Phase 3 (Queries) ← MAIN WORK
Phase 4 (Docs) ← Can run in parallel with Phase 3
Phase 5 (Polish)
```
### Task Dependencies Within Phases
```
T001 (Schema)
├── T002 (Parser test)
T003 (Parser impl) ← depends on T001
T004 (Loader) ← depends on T003
├── T005, T006 (Contract tests)
T007 (Query impl) ← depends on T004
T008 (Tool docs)
```
### Parallel Opportunities
**Phase 2 Tests + Phase 3 Tests** (can write all tests in parallel):
```bash
Task T002: "Unit test for TASK handler parsing milestone_type"
Task T005: "Update contract test for list_milestones"
Task T006: "Add test for start/finish milestone types"
```
**Phase 4 Documentation** (can run in parallel):
```bash
Task T009: "Update ActivitySummary schema"
Task T010: "Update Activity entity in data-model.md"
Task T011: "Update quickstart.md example"
```
---
## Implementation Details
### Milestone Type Determination
In Primavera P6, milestones are identified by `task_type = 'TT_Mile'`. The distinction between Start and Finish milestones is typically:
1. **XER Field**: Check for `milestone_type` field in TASK table (values: `MS_Start`, `MS_Finish`)
2. **Fallback**: If field not present, can infer from dates:
- Start milestone: Has only `target_start_date` (or start = end)
- Finish milestone: Has only `target_end_date` (or represents completion)
### Schema Change
```sql
-- Add to activities table
milestone_type TEXT -- 'start', 'finish', or NULL for non-milestones
```
### Query Change
```sql
SELECT task_id, task_code, task_name,
target_start_date, target_end_date,
status_code, milestone_type
FROM activities
WHERE task_type = 'TT_Mile'
ORDER BY target_start_date, task_code
```
### Response Format
```json
{
"milestones": [
{
"task_id": "M001",
"task_code": "MS-START",
"task_name": "Project Start",
"milestone_type": "start",
"target_start_date": "2026-01-15T08:00:00",
"target_end_date": "2026-01-15T08:00:00",
"status_code": "TK_Complete"
},
{
"task_id": "M002",
"task_code": "MS-END",
"task_name": "Project Complete",
"milestone_type": "finish",
"target_start_date": "2026-06-30T17:00:00",
"target_end_date": "2026-06-30T17:00:00",
"status_code": "TK_NotStart"
}
]
}
```
---
## Summary
| Phase | Tasks | Focus |
|-------|-------|-------|
| Setup | 1 | Schema update |
| Foundational | 3 | Parser enhancement |
| US4 Implementation | 4 | Milestone type in queries |
| Documentation | 3 | Contracts & docs |
| Polish | 3 | Validation |
| **Total** | **14** | |
### Task Distribution by Type
| Type | Count | IDs |
|------|-------|-----|
| Schema | 1 | T001 |
| Tests | 3 | T002, T005, T006 |
| Implementation | 4 | T003, T004, T007, T008 |
| Documentation | 3 | T009, T010, T011 |
| Validation | 3 | T012, T013, T014 |
### Independent Test Criteria
| Verification | How to Test |
|--------------|-------------|
| milestone_type parsed | Unit test: parse XER with milestones, verify milestone_type extracted |
| milestone_type in response | Contract test: call list_milestones, verify milestone_type field present |
| Start/Finish distinction | Contract test: verify "Project Start" has type="start", "Project Complete" has type="finish" |
### MVP Scope
Complete through T008 for minimal viable milestone_type implementation.
---
## Notes
- [P] tasks = different files, no dependencies on incomplete tasks
- [US4] = User Story 4 (Query Project Summary - milestones)
- Constitution mandates TDD: write tests first, verify they fail, then implement
- milestone_type is stored in database, not computed at query time
- For non-milestone activities, milestone_type should be NULL
- Commit after each task or logical group

View File

@@ -0,0 +1,37 @@
# Specification Quality Checklist: Direct Database Access for Scripts
**Purpose**: Validate specification completeness and quality before proceeding to planning
**Created**: 2026-01-08
**Feature**: [spec.md](../spec.md)
## Content Quality
- [x] No implementation details (languages, frameworks, APIs)
- [x] Focused on user value and business needs
- [x] Written for non-technical stakeholders
- [x] All mandatory sections completed
## Requirement Completeness
- [x] No [NEEDS CLARIFICATION] markers remain
- [x] Requirements are testable and unambiguous
- [x] Success criteria are measurable
- [x] Success criteria are technology-agnostic (no implementation details)
- [x] All acceptance scenarios are defined
- [x] Edge cases are identified
- [x] Scope is clearly bounded
- [x] Dependencies and assumptions identified
## Feature Readiness
- [x] All functional requirements have clear acceptance criteria
- [x] User scenarios cover primary flows
- [x] Feature meets measurable outcomes defined in Success Criteria
- [x] No implementation details leak into specification
## Notes
- All items pass validation
- Spec is ready for `/speckit.clarify` or `/speckit.plan`
- The feature cleanly extends existing functionality (load_xer) with persistent database output
- Assumptions section documents reasonable defaults for database location and persistence behavior

View File

@@ -0,0 +1,168 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "XER MCP Server Tools - Direct Database Access Extension",
"description": "MCP tool definitions for persistent database access",
"version": "0.2.0",
"tools": [
{
"name": "load_xer",
"description": "Load a Primavera P6 XER file and parse its schedule data. Optionally persist to a SQLite database file for direct script access.",
"inputSchema": {
"type": "object",
"properties": {
"file_path": {
"type": "string",
"description": "Absolute path to the XER file"
},
"project_id": {
"type": "string",
"description": "Project ID to select (required for multi-project files)"
},
"db_path": {
"type": "string",
"description": "Path for persistent SQLite database file. If omitted, uses in-memory database. If empty string, auto-generates path from XER filename (same directory, .sqlite extension)."
}
},
"required": ["file_path"]
},
"outputSchema": {
"type": "object",
"properties": {
"success": { "type": "boolean" },
"project": {
"type": "object",
"properties": {
"proj_id": { "type": "string" },
"proj_short_name": { "type": "string" },
"plan_start_date": { "type": "string", "format": "date-time" },
"plan_end_date": { "type": "string", "format": "date-time" }
}
},
"activity_count": { "type": "integer" },
"relationship_count": { "type": "integer" },
"database": { "$ref": "#/$defs/DatabaseInfo" },
"available_projects": {
"type": "array",
"items": {
"type": "object",
"properties": {
"proj_id": { "type": "string" },
"proj_short_name": { "type": "string" }
}
},
"description": "Only present for multi-project files without selection"
},
"warnings": {
"type": "array",
"items": { "type": "string" }
}
}
}
},
{
"name": "get_database_info",
"description": "Get information about the currently loaded database including file path and schema. Use this to get connection details for direct SQL access.",
"inputSchema": {
"type": "object",
"properties": {}
},
"outputSchema": {
"type": "object",
"properties": {
"database": { "$ref": "#/$defs/DatabaseInfo" },
"error": { "$ref": "#/$defs/Error" }
}
}
}
],
"$defs": {
"DatabaseInfo": {
"type": "object",
"properties": {
"db_path": {
"type": "string",
"description": "Absolute path to SQLite database file, or ':memory:' for in-memory"
},
"is_persistent": {
"type": "boolean",
"description": "True if file-based database, false if in-memory"
},
"source_file": {
"type": "string",
"description": "Path to XER file that was loaded"
},
"loaded_at": {
"type": "string",
"format": "date-time",
"description": "When data was loaded"
},
"schema": { "$ref": "#/$defs/SchemaInfo" }
},
"required": ["db_path", "is_persistent", "loaded_at", "schema"]
},
"SchemaInfo": {
"type": "object",
"properties": {
"version": {
"type": "string",
"description": "Schema version"
},
"tables": {
"type": "array",
"items": { "$ref": "#/$defs/TableInfo" }
}
},
"required": ["version", "tables"]
},
"TableInfo": {
"type": "object",
"properties": {
"name": { "type": "string" },
"columns": {
"type": "array",
"items": { "$ref": "#/$defs/ColumnInfo" }
},
"primary_key": {
"type": "array",
"items": { "type": "string" }
},
"foreign_keys": {
"type": "array",
"items": { "$ref": "#/$defs/ForeignKeyInfo" }
},
"row_count": { "type": "integer" }
},
"required": ["name", "columns", "primary_key", "row_count"]
},
"ColumnInfo": {
"type": "object",
"properties": {
"name": { "type": "string" },
"type": { "type": "string" },
"nullable": { "type": "boolean" },
"default": { "type": "string" }
},
"required": ["name", "type", "nullable"]
},
"ForeignKeyInfo": {
"type": "object",
"properties": {
"column": { "type": "string" },
"references_table": { "type": "string" },
"references_column": { "type": "string" }
},
"required": ["column", "references_table", "references_column"]
},
"Error": {
"type": "object",
"properties": {
"code": {
"type": "string",
"enum": ["NO_FILE_LOADED", "DATABASE_ERROR", "FILE_NOT_WRITABLE", "DISK_FULL"]
},
"message": { "type": "string" }
},
"required": ["code", "message"]
}
}
}

View File

@@ -0,0 +1,181 @@
# Data Model: Direct Database Access for Scripts
**Date**: 2026-01-08
**Branch**: `002-direct-db-access`
## Entity Overview
```
┌─────────────────┐
│ DatabaseInfo │
└─────────────────┘
┌─────────────────┐ ┌─────────────────┐
│ SchemaInfo │───────│ TableInfo │
└─────────────────┘ └─────────────────┘
┌─────────────────┐
│ ColumnInfo │
└─────────────────┘
```
## New Entities
### DatabaseInfo
Information about the current database connection, returned by load operations and queryable separately.
| Field | Type | Required | Description |
|-------|------|----------|-------------|
| db_path | string | Yes | Absolute path to SQLite database file; `:memory:` for in-memory |
| is_persistent | boolean | Yes | True if file-based, false if in-memory |
| source_file | string | No | Path to XER file that was loaded |
| loaded_at | datetime | Yes | When data was loaded |
| schema | SchemaInfo | Yes | Database schema information |
**Validation Rules**:
- db_path must be an absolute path (or `:memory:`)
- loaded_at must be ISO 8601 format
### SchemaInfo
Metadata describing the database structure.
| Field | Type | Required | Description |
|-------|------|----------|-------------|
| tables | list[TableInfo] | Yes | All tables in the database |
| version | string | Yes | Schema version (matches server version) |
### TableInfo
Information about a single database table.
| Field | Type | Required | Description |
|-------|------|----------|-------------|
| name | string | Yes | Table name |
| columns | list[ColumnInfo] | Yes | Column definitions |
| primary_key | list[string] | Yes | Column(s) forming primary key |
| foreign_keys | list[ForeignKeyInfo] | No | Foreign key relationships |
| row_count | integer | Yes | Number of rows in table |
### ColumnInfo
Information about a single column.
| Field | Type | Required | Description |
|-------|------|----------|-------------|
| name | string | Yes | Column name |
| type | string | Yes | SQLite data type (TEXT, INTEGER, REAL, etc.) |
| nullable | boolean | Yes | Whether NULL values are allowed |
| default | string | No | Default value if any |
### ForeignKeyInfo
Foreign key relationship information.
| Field | Type | Required | Description |
|-------|------|----------|-------------|
| column | string | Yes | Column in this table |
| references_table | string | Yes | Referenced table |
| references_column | string | Yes | Referenced column |
## Extended load_xer Response
The existing load_xer tool response is extended with database information:
```json
{
"success": true,
"project": { ... },
"activity_count": 4440,
"relationship_count": 8583,
"database": {
"db_path": "/path/to/schedule.sqlite",
"is_persistent": true,
"source_file": "/path/to/schedule.xer",
"loaded_at": "2026-01-08T14:30:00",
"schema": {
"version": "0.2.0",
"tables": [
{
"name": "activities",
"columns": [
{"name": "task_id", "type": "TEXT", "nullable": false},
{"name": "task_name", "type": "TEXT", "nullable": false},
...
],
"primary_key": ["task_id"],
"foreign_keys": [
{"column": "proj_id", "references_table": "projects", "references_column": "proj_id"}
],
"row_count": 4440
},
...
]
}
}
}
```
## New Tool Input Schema
### load_xer (extended)
New optional parameter:
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| db_path | string | No | Path for persistent database file. If omitted, uses in-memory database. If empty string, auto-generates path from XER filename. |
### get_database_info
No input parameters required. Returns current database information.
## SQLite Schema (Unchanged)
The underlying database schema remains unchanged from feature 001-schedule-tools:
- `projects` - Project metadata
- `activities` - Task/activity data
- `relationships` - Predecessor/successor relationships
- `wbs` - Work breakdown structure
- `calendars` - Calendar definitions
The difference is storage location (file vs memory), not structure.
## Query Examples for Scripts
Once scripts have the database path, they can execute standard SQL:
```python
import sqlite3
# Connect using path from load_xer response
conn = sqlite3.connect("/path/to/schedule.sqlite")
# Query activities
cursor = conn.execute("""
SELECT task_code, task_name, target_start_date, target_end_date
FROM activities
WHERE task_type = 'TT_Mile'
ORDER BY target_start_date
""")
for row in cursor:
print(row)
```
```sql
-- Find critical path activities
SELECT task_code, task_name, total_float_hr_cnt
FROM activities
WHERE driving_path_flag = 1
ORDER BY target_start_date;
-- Join activities with WBS
SELECT a.task_code, a.task_name, w.wbs_name
FROM activities a
JOIN wbs w ON a.wbs_id = w.wbs_id;
```

View File

@@ -0,0 +1,108 @@
# Implementation Plan: Direct Database Access for Scripts
**Branch**: `002-direct-db-access` | **Date**: 2026-01-08 | **Spec**: [spec.md](./spec.md)
**Input**: Feature specification from `/specs/002-direct-db-access/spec.md`
## Summary
Extend the XER MCP Server to support persistent SQLite database files instead of only in-memory databases. The existing `load_xer` tool will gain an optional parameter to write to a file-based database, and the response will include the database path and schema information. A new `get_database_info` tool will allow retrieval of database connection details without reloading. This enables scripts to query schedule data directly via SQL, reducing LLM workload for large data processing.
## Technical Context
**Language/Version**: Python 3.14
**Primary Dependencies**: mcp>=1.0.0 (MCP SDK), sqlite3 (stdlib)
**Storage**: SQLite database file (persistent) in addition to existing in-memory option
**Testing**: pytest>=8.0.0, pytest-asyncio>=0.24.0
**Target Platform**: Local server (Linux/macOS/Windows with file system access)
**Project Type**: Single project (extending existing structure)
**Performance Goals**: Database file creation <1 second; query response <100ms for 10,000+ activities
**Constraints**: File must be accessible by external scripts; atomic writes to prevent corruption
**Scale/Scope**: 2 MCP tools modified/added; extends existing database layer
## Constitution Check
*GATE: Must pass before Phase 0 research. Re-check after Phase 1 design.*
| Principle | Requirement | Status | Notes |
|-----------|-------------|--------|-------|
| **I. Test-First Development** | TDD mandatory; tests fail before implementation | ✅ PASS | Contract tests for modified load_xer and new get_database_info tool |
| **II. Extensibility Architecture** | Core parsing separate from MCP transport; pluggable handlers | ✅ PASS | Extends existing DatabaseManager; no changes to parser or handlers |
| **III. MCP Protocol Compliance** | Complete JSON schemas; MCP error format; compliant transport | ✅ PASS | New tool definitions include JSON schemas; error responses follow MCP format |
| **IV. XER Format Fidelity** | No data loss; preserve precision; handle all standard tables | ✅ PASS | Same data written to file-based DB as in-memory; no parsing changes |
| **V. Semantic Versioning** | SemVer for releases; breaking changes documented | ✅ PASS | Minor version bump (0.2.0); backward compatible - existing behavior unchanged |
| **Technical Standards** | Python 3.14; type hints; ruff formatting | ✅ PASS | Follows existing codebase patterns |
**Gate Result**: PASS - All constitution principles satisfied. Proceed to Phase 0.
## Project Structure
### Documentation (this feature)
```text
specs/002-direct-db-access/
├── spec.md # Feature specification
├── plan.md # This file (/speckit.plan command output)
├── research.md # Phase 0 output (/speckit.plan command)
├── data-model.md # Phase 1 output (/speckit.plan command)
├── quickstart.md # Phase 1 output (/speckit.plan command)
├── contracts/ # Phase 1 output (/speckit.plan command)
└── tasks.md # Phase 2 output (/speckit.tasks command - NOT created by /speckit.plan)
```
### Source Code (repository root)
```text
src/xer_mcp/
├── db/
│ ├── __init__.py # Modify DatabaseManager for file-based DB support
│ ├── schema.py # No changes needed
│ ├── loader.py # No changes needed
│ └── queries.py # Add schema introspection query
└── tools/
├── load_xer.py # Modify to support db_path parameter and return schema
└── get_database_info.py # NEW: Return database path and schema info
tests/
├── contract/
│ ├── test_load_xer.py # Add tests for persistent database functionality
│ └── test_get_database_info.py # NEW: Contract tests for schema retrieval
└── unit/
└── test_db_manager.py # NEW: Unit tests for file-based database operations
```
**Structure Decision**: Extends existing single project structure. Minimal changes to existing modules; adds one new tool file and modifies DatabaseManager to support both in-memory and file-based databases.
## Complexity Tracking
> **Fill ONLY if Constitution Check has violations that must be justified**
No violations. All constitution principles satisfied.
## Post-Design Constitution Re-Check
*Re-evaluation after Phase 1 design artifacts are complete.*
| Principle | Status | Verification |
|-----------|--------|--------------|
| **I. Test-First Development** | ✅ PASS | Contract tests for load_xer db_path parameter; contract tests for get_database_info tool |
| **II. Extensibility Architecture** | ✅ PASS | DatabaseManager extended without breaking existing interface; new tool follows existing patterns |
| **III. MCP Protocol Compliance** | ✅ PASS | Tool schemas defined in contracts/mcp-tools.json; error responses use existing MCP error format |
| **IV. XER Format Fidelity** | ✅ PASS | No changes to parsing; same data fidelity in file-based DB as in-memory |
| **V. Semantic Versioning** | ✅ PASS | Version 0.2.0; new feature, backward compatible |
| **Technical Standards** | ✅ PASS | Type hints; ruff formatting; pytest async tests |
**Post-Design Gate Result**: PASS - Design artifacts align with constitution. Ready for task generation.
## Generated Artifacts
| Artifact | Path | Description |
|----------|------|-------------|
| Research | `specs/002-direct-db-access/research.md` | SQLite file vs in-memory, atomic writes, schema introspection |
| Data Model | `specs/002-direct-db-access/data-model.md` | DatabaseInfo entity, SchemaInfo structure |
| Contracts | `specs/002-direct-db-access/contracts/mcp-tools.json` | Updated load_xer schema, new get_database_info schema |
| Quickstart | `specs/002-direct-db-access/quickstart.md` | Usage examples for direct database access |
| Agent Context | `CLAUDE.md` | No updates needed (same technologies) |
## Next Steps
Run `/speckit.tasks` to generate implementation tasks from this plan.

View File

@@ -0,0 +1,189 @@
# Quickstart: Direct Database Access for Scripts
This guide shows how to use the XER MCP Server's persistent database feature to query schedule data directly from scripts.
## Overview
The XER MCP Server can save parsed schedule data to a SQLite file, allowing your scripts to query the data directly without going through MCP tools. This is ideal for:
- Large-scale data analysis
- Custom reporting
- Integration with other tools
- Reducing LLM token usage for data-heavy operations
## Loading to a Persistent Database
### Option 1: Auto-generated Path
Use an empty string for `db_path` to automatically create a database file alongside the XER file:
```
Use the load_xer tool with file_path="/path/to/schedule.xer" and db_path=""
```
**Response**:
```json
{
"success": true,
"project": {
"proj_id": "P001",
"proj_short_name": "Construction Phase 1"
},
"activity_count": 4440,
"database": {
"db_path": "/path/to/schedule.sqlite",
"is_persistent": true,
"source_file": "/path/to/schedule.xer",
"loaded_at": "2026-01-08T14:30:00",
"schema": {
"version": "0.2.0",
"tables": [
{
"name": "activities",
"columns": [
{"name": "task_id", "type": "TEXT", "nullable": false},
{"name": "task_code", "type": "TEXT", "nullable": false},
{"name": "task_name", "type": "TEXT", "nullable": false},
...
],
"row_count": 4440
},
...
]
}
}
}
```
### Option 2: Specify Custom Path
```
Use the load_xer tool with file_path="/path/to/schedule.xer" and db_path="/data/my-schedule.db"
```
### Option 3: In-Memory Only (Default)
Omit `db_path` to use the original in-memory behavior:
```
Use the load_xer tool with file_path="/path/to/schedule.xer"
```
## Querying the Database Directly
Once you have the database path, use any SQLite client to query the data.
### Python Example
```python
import sqlite3
# Use the db_path from load_xer response
db_path = "/path/to/schedule.sqlite"
conn = sqlite3.connect(db_path)
conn.row_factory = sqlite3.Row
# Query all milestones
cursor = conn.execute("""
SELECT task_code, task_name, target_start_date, milestone_type
FROM activities
WHERE task_type IN ('TT_Mile', 'TT_FinMile')
ORDER BY target_start_date
""")
for row in cursor:
print(f"{row['task_code']}: {row['task_name']} ({row['milestone_type']})")
conn.close()
```
### SQL Examples
**Find critical path activities:**
```sql
SELECT task_code, task_name, target_start_date, target_end_date
FROM activities
WHERE driving_path_flag = 1
ORDER BY target_start_date;
```
**Get activity count by WBS:**
```sql
SELECT w.wbs_name, COUNT(*) as activity_count
FROM activities a
JOIN wbs w ON a.wbs_id = w.wbs_id
GROUP BY w.wbs_id
ORDER BY activity_count DESC;
```
**Find activities with predecessors:**
```sql
SELECT a.task_code, a.task_name,
COUNT(r.pred_task_id) as predecessor_count
FROM activities a
LEFT JOIN relationships r ON a.task_id = r.task_id
GROUP BY a.task_id
HAVING predecessor_count > 0
ORDER BY predecessor_count DESC;
```
**Export milestones to CSV (using sqlite3 CLI):**
```bash
sqlite3 -header -csv schedule.sqlite \
"SELECT task_code, task_name, target_start_date, milestone_type
FROM activities
WHERE task_type IN ('TT_Mile', 'TT_FinMile')" > milestones.csv
```
## Getting Database Info Without Reloading
If you need the database path and schema later:
```
Use the get_database_info tool
```
**Response**:
```json
{
"database": {
"db_path": "/path/to/schedule.sqlite",
"is_persistent": true,
"source_file": "/path/to/schedule.xer",
"loaded_at": "2026-01-08T14:30:00",
"schema": { ... }
}
}
```
## Database Schema Reference
| Table | Description | Key Columns |
|-------|-------------|-------------|
| `projects` | Project metadata | proj_id, proj_short_name, plan_start_date, plan_end_date |
| `activities` | Tasks and milestones | task_id, task_code, task_name, task_type, target_start_date, target_end_date |
| `relationships` | Predecessor/successor links | task_pred_id, task_id, pred_task_id, pred_type, lag_hr_cnt |
| `wbs` | Work breakdown structure | wbs_id, wbs_name, parent_wbs_id |
| `calendars` | Calendar definitions | clndr_id, clndr_name, day_hr_cnt |
## Best Practices
1. **Use persistent database for large schedules**: Schedules with 1000+ activities benefit from direct SQL queries
2. **Close connections when done**: Always close your database connections to avoid lock issues
3. **Read-only access recommended**: The database is designed for reading; modifications may cause inconsistencies with MCP tools
4. **Re-load when XER changes**: If the source XER file is updated, reload to refresh the database
5. **Check schema version**: The schema version in the response indicates compatibility with your queries
## Error Handling
| Error Code | Meaning | Solution |
|------------|---------|----------|
| NO_FILE_LOADED | No XER file has been loaded | Call load_xer first |
| FILE_NOT_WRITABLE | Cannot write database file | Check directory permissions |
| DISK_FULL | Insufficient disk space | Free up disk space |
| DATABASE_ERROR | General database error | Check error message for details |

View File

@@ -0,0 +1,110 @@
# Research: Direct Database Access for Scripts
**Date**: 2026-01-08
**Branch**: `002-direct-db-access`
## Research Topics
### 1. SQLite File-Based vs In-Memory Database
**Decision**: Support both file-based and in-memory databases through the same DatabaseManager interface.
**Rationale**:
- File-based SQLite allows external scripts to query data directly without MCP overhead
- In-memory remains the default for backward compatibility with existing tools
- SQLite's file format is universally readable (Python sqlite3, DBeaver, sqlitebrowser, etc.)
- Single connection string change (`:memory:` vs file path) switches modes
**Alternatives Considered**:
- **Separate database manager for files**: Rejected - unnecessary duplication; SQLite handles both modes identically
- **Export to CSV/JSON**: Rejected - loses relational structure; no query capability
- **Network database (PostgreSQL)**: Rejected - overkill for single-user local access; requires external server
### 2. Database File Location Strategy
**Decision**: Accept user-specified path, or default to a predictable location derived from the XER file path.
**Rationale**:
- User-specified path gives maximum flexibility for script integration
- Default path (`{xer_file_directory}/{xer_basename}.sqlite`) is predictable and colocated with source
- Absolute paths in responses eliminate ambiguity for scripts
**Default Path Algorithm**:
```
Input: /path/to/schedule.xer
Output: /path/to/schedule.sqlite
```
**Alternatives Considered**:
- **Temp directory only**: Rejected - less predictable; may be cleaned up unexpectedly
- **Fixed location (e.g., ~/.xer-mcp/db/)**: Rejected - less convenient; separates DB from source file
- **Always require user to specify**: Rejected - worse developer experience for common case
### 3. Atomic Write Strategy
**Decision**: Use SQLite's built-in transaction support; write to temp file and rename for atomicity.
**Rationale**:
- SQLite transactions ensure data integrity during writes
- Write-then-rename pattern prevents partial/corrupted files if process interrupted
- External scripts won't see incomplete data
**Implementation**:
1. Create database at `{target_path}.tmp`
2. Load all data within a transaction
3. Commit transaction
4. Rename `{target_path}.tmp` to `{target_path}` (atomic on POSIX)
**Alternatives Considered**:
- **Direct write to final path**: Rejected - risk of corruption on interruption
- **Lock file mechanism**: Rejected - SQLite already handles locking; adds complexity
### 4. Schema Introspection Approach
**Decision**: Query SQLite's `sqlite_master` table and `PRAGMA table_info()` for schema information.
**Rationale**:
- Standard SQLite introspection APIs - no custom metadata needed
- Returns actual schema, not just documentation
- Works with any SQLite database, even if created by different tools
**Schema Information Returned**:
- Table names
- Column names and types for each table
- Primary key information
- Foreign key relationships (via `PRAGMA foreign_key_list()`)
**Alternatives Considered**:
- **Hardcoded schema in response**: Rejected - may drift from actual schema; not dynamic
- **Separate metadata table**: Rejected - adds complexity; standard introspection sufficient
### 5. Concurrent Access Handling
**Decision**: Use SQLite WAL (Write-Ahead Logging) mode for concurrent read access.
**Rationale**:
- WAL mode allows multiple readers while one writer operates
- Scripts can query while MCP server operates without blocking
- Minimal configuration change: `PRAGMA journal_mode=WAL`
**Implementation**:
- Enable WAL mode when creating file-based database
- In-memory databases don't need WAL (single connection)
**Alternatives Considered**:
- **Reader/writer locks in application**: Rejected - SQLite handles this natively
- **Copy-on-read**: Rejected - unnecessary with WAL mode
## Technology Decisions Summary
| Decision | Choice | Key Reason |
|----------|--------|------------|
| Database format | SQLite file | Universal compatibility, no server needed |
| Default location | Same directory as XER file | Predictable, colocated |
| Atomicity | Temp file + rename | Prevents corruption |
| Schema info | SQLite introspection APIs | Dynamic, accurate |
| Concurrency | WAL mode | Multiple readers supported |
## Open Questions Resolved
All technical questions have been resolved through research. No clarifications needed.

View File

@@ -0,0 +1,102 @@
# Feature Specification: Direct Database Access for Scripts
**Feature Branch**: `002-direct-db-access`
**Created**: 2026-01-08
**Status**: Draft
**Input**: User description: "Create a new feature that allows for scripts to directly query the schedule loaded into the database. The mcp endpoint should be used to load the xer file to a database. The response should provide the necessary information for a script to then access that database directly to perform queries. The intent is to minimize the costly and time-consuming workload on the LLM for large data processing."
## User Scenarios & Testing *(mandatory)*
### User Story 1 - Load XER to Persistent Database (Priority: P1)
As a developer building schedule analysis scripts, I want to load an XER file into a database that persists beyond the MCP session so that my scripts can query the data directly without going through the LLM.
**Why this priority**: This is the foundation of the feature - without a persistent database, scripts cannot access the data directly. This enables the primary use case of offloading large data processing from the LLM.
**Independent Test**: Can be tested by calling the load endpoint and verifying the database file is created at the returned path with the expected schema and data.
**Acceptance Scenarios**:
1. **Given** a valid XER file path, **When** I call the load-to-database endpoint, **Then** the system creates a SQLite database file at a predictable location and returns the database file path
2. **Given** an XER file is loaded to database, **When** I examine the database file, **Then** it contains all activities, relationships, WBS elements, and project data from the XER file
3. **Given** a database was previously created for an XER file, **When** I load the same XER file again, **Then** the existing database is replaced with fresh data
4. **Given** an invalid or non-existent XER file path, **When** I call the load-to-database endpoint, **Then** I receive a clear error message and no database file is created
---
### User Story 2 - Retrieve Database Connection Information (Priority: P1)
As a developer, I want the load response to include all information needed to connect to and query the database so that I can immediately start writing queries in my scripts.
**Why this priority**: Without connection information, developers cannot use the database even if it exists. This is equally critical to the first story.
**Independent Test**: Can be tested by using the returned connection info to successfully open and query the database from an external script.
**Acceptance Scenarios**:
1. **Given** a successful XER load to database, **When** I receive the response, **Then** it includes the absolute path to the database file
2. **Given** a successful XER load to database, **When** I receive the response, **Then** it includes the database schema description (table names and key columns)
3. **Given** the returned database path, **When** I connect to it from a Python/SQL script, **Then** I can successfully query activities, relationships, and other schedule data
---
### User Story 3 - Query Database Schema Information (Priority: P2)
As a developer unfamiliar with the database structure, I want to retrieve the database schema so that I can write correct SQL queries without guessing table and column names.
**Why this priority**: While developers can explore the database manually, having schema information readily available improves developer experience and reduces errors.
**Independent Test**: Can be tested by calling the schema endpoint and verifying the returned schema matches the actual database structure.
**Acceptance Scenarios**:
1. **Given** a database has been created, **When** I request the schema, **Then** I receive a list of all tables with their columns and data types
2. **Given** a database has been created, **When** I request the schema, **Then** I receive information about relationships between tables (foreign keys)
3. **Given** no database has been created yet, **When** I request the schema, **Then** I receive an informative error indicating no database is available
---
### Edge Cases
- What happens when the disk is full and database cannot be created? Return a clear error message indicating storage issue.
- What happens when the database file path is not writable? Return a clear error message indicating permission issue.
- What happens when a script is querying the database while a new XER file is being loaded? The load operation should complete atomically - either fully succeed or fully fail, preventing partial/corrupted reads.
- What happens when multiple XER files are loaded in sequence? Each load replaces the previous database content; only one project's data is available at a time.
## Requirements *(mandatory)*
### Functional Requirements
- **FR-001**: System MUST provide an MCP tool to load an XER file into a persistent SQLite database file (not just in-memory)
- **FR-002**: System MUST return the absolute file path to the created database in the load response
- **FR-003**: System MUST return a summary of the database schema (tables and key columns) in the load response
- **FR-004**: Database file MUST be stored in a predictable, accessible location that scripts can reach
- **FR-005**: System MUST preserve all data currently stored by the in-memory database (activities, relationships, WBS, calendars, projects)
- **FR-006**: System MUST provide an MCP tool to retrieve the current database path and schema without reloading data
- **FR-007**: System MUST handle concurrent access safely - database remains queryable while MCP tools are used
- **FR-008**: System MUST return clear errors when database operations fail (file not writable, disk full, etc.)
- **FR-009**: Database MUST use standard SQLite format readable by any SQLite client (Python sqlite3, DBeaver, etc.)
### Key Entities
- **Database File**: A persistent SQLite database file containing parsed XER data; has a file path, creation timestamp, and source XER file reference
- **Schema Information**: Metadata describing database structure; includes table names, column names, data types, and foreign key relationships
- **Connection Info**: All information needed to connect to and query the database; includes file path, schema summary, and access instructions
## Success Criteria *(mandatory)*
### Measurable Outcomes
- **SC-001**: Scripts can query loaded schedule data directly via SQL without MCP tool calls after initial load
- **SC-002**: Database file is accessible and queryable by standard SQLite clients within 1 second of load completion
- **SC-003**: Large schedules (10,000+ activities) can be queried directly by scripts in under 100ms per query
- **SC-004**: Developers can write working SQL queries using only the schema information returned by the system
- **SC-005**: 100% of data available through existing MCP tools is also available in the direct database
## Assumptions
- SQLite is an appropriate database format for this use case (widely supported, file-based, no server needed)
- Scripts will primarily use Python, but any language with SQLite support should work
- The database file will be stored in a project-relative or user-accessible directory
- Single-user operation - concurrent writes from multiple sources are not required
- Database persistence is session-based; the file may be cleaned up when the MCP server stops (or may persist based on configuration)

View File

@@ -0,0 +1,737 @@
# Implementation Tasks: Direct Database Access for Scripts
**Branch**: `002-direct-db-access` | **Spec**: [spec.md](./spec.md) | **Plan**: [plan.md](./plan.md)
## Quick Reference
- **Feature**: Direct Database Access for Scripts
- **Version**: 0.2.0
- **Test Command**: `pytest`
- **Lint Command**: `ruff check .`
---
## Phase 1: Setup
### Task 1.1: Create Feature Branch and Documentation Structure [X]
**Type**: Setup
**Why**: Establish isolated workspace for feature development
**Steps**:
1. Verify branch `002-direct-db-access` exists (already created during spec/plan)
2. Verify all design artifacts exist:
- `specs/002-direct-db-access/spec.md`
- `specs/002-direct-db-access/plan.md`
- `specs/002-direct-db-access/research.md`
- `specs/002-direct-db-access/data-model.md`
- `specs/002-direct-db-access/contracts/mcp-tools.json`
- `specs/002-direct-db-access/quickstart.md`
**Verification**: `git branch --show-current` shows `002-direct-db-access`
**Acceptance**: All design artifacts present and branch is active
---
## Phase 2: Foundational - DatabaseManager Extension
### Task 2.1: Add File-Based Database Support to DatabaseManager [X]
**Type**: Implementation
**Why**: Foundation for all persistent database features
**Dependencies**: None
**Contract Reference**: `contracts/mcp-tools.json` - DatabaseInfo schema
**Test First** (TDD):
```python
# tests/unit/test_db_manager.py
def test_initialize_with_memory_by_default():
"""Default initialization uses in-memory database."""
dm = DatabaseManager()
dm.initialize()
assert dm.db_path == ":memory:"
assert dm.is_persistent is False
def test_initialize_with_file_path():
"""Can initialize with explicit file path."""
dm = DatabaseManager()
dm.initialize(db_path="/tmp/test.db")
assert dm.db_path == "/tmp/test.db"
assert dm.is_persistent is True
# Cleanup
os.unlink("/tmp/test.db")
def test_initialize_with_empty_string_auto_generates_path():
"""Empty string db_path with source_file auto-generates path."""
dm = DatabaseManager()
dm.initialize(db_path="", source_file="/path/to/schedule.xer")
assert dm.db_path == "/path/to/schedule.sqlite"
assert dm.is_persistent is True
def test_file_database_persists_after_close():
"""File-based database persists after connection close."""
dm = DatabaseManager()
dm.initialize(db_path="/tmp/persist_test.db")
# Insert test data would go here
dm.close()
assert os.path.exists("/tmp/persist_test.db")
# Cleanup
os.unlink("/tmp/persist_test.db")
```
**Implementation**:
- Modify `src/xer_mcp/db/__init__.py`:
- Add `db_path` property to track current database path
- Add `is_persistent` property (True if file-based, False if in-memory)
- Add `source_file` property to track loaded XER file
- Add `loaded_at` property (datetime when data was loaded)
- Modify `initialize()` to accept optional `db_path` and `source_file` parameters
- If `db_path` is empty string and `source_file` provided, derive path from source file
- Use WAL mode for file-based databases: `PRAGMA journal_mode=WAL`
**Files Changed**:
- `src/xer_mcp/db/__init__.py`
- `tests/unit/test_db_manager.py` (new)
**Verification**: `pytest tests/unit/test_db_manager.py -v`
**Acceptance**: All unit tests pass; DatabaseManager supports both in-memory and file-based modes
---
### Task 2.2: Implement Atomic Write Pattern [X]
**Type**: Implementation
**Why**: Prevents corrupted database files if process interrupted during load
**Dependencies**: Task 2.1
**Contract Reference**: `research.md` - Atomic Write Strategy
**Test First** (TDD):
```python
# tests/unit/test_db_manager.py
def test_atomic_write_creates_temp_file_first():
"""Database is created at .tmp path first, then renamed."""
dm = DatabaseManager()
target = "/tmp/atomic_test.db"
# During initialization, temp file should exist
# After completion, only target should exist
dm.initialize(db_path=target)
assert os.path.exists(target)
assert not os.path.exists(target + ".tmp")
os.unlink(target)
def test_atomic_write_removes_temp_on_failure():
"""Temp file is cleaned up if initialization fails."""
# Test with invalid schema or similar failure scenario
pass
```
**Implementation**:
- In `initialize()` method when `db_path` is not `:memory:`:
1. Create connection to `{db_path}.tmp`
2. Execute schema creation
3. Close connection
4. Rename `{db_path}.tmp` to `{db_path}` (atomic on POSIX)
5. Reopen connection to final path
- Handle cleanup of `.tmp` file on failure
**Files Changed**:
- `src/xer_mcp/db/__init__.py`
- `tests/unit/test_db_manager.py`
**Verification**: `pytest tests/unit/test_db_manager.py -v`
**Acceptance**: Atomic write tests pass; no partial database files created on failure
---
### Task 2.3: Add Schema Introspection Query [X]
**Type**: Implementation
**Why**: Required for returning schema information in responses
**Dependencies**: Task 2.1
**Contract Reference**: `contracts/mcp-tools.json` - SchemaInfo, TableInfo, ColumnInfo schemas
**Test First** (TDD):
```python
# tests/unit/test_db_manager.py
def test_get_schema_info_returns_all_tables():
"""Schema info includes all database tables."""
dm = DatabaseManager()
dm.initialize()
schema = dm.get_schema_info()
assert schema["version"] == "0.2.0"
table_names = [t["name"] for t in schema["tables"]]
assert "projects" in table_names
assert "activities" in table_names
assert "relationships" in table_names
assert "wbs" in table_names
assert "calendars" in table_names
def test_get_schema_info_includes_column_details():
"""Schema info includes column names, types, and nullable."""
dm = DatabaseManager()
dm.initialize()
schema = dm.get_schema_info()
activities_table = next(t for t in schema["tables"] if t["name"] == "activities")
column_names = [c["name"] for c in activities_table["columns"]]
assert "task_id" in column_names
assert "task_name" in column_names
# Check column details
task_id_col = next(c for c in activities_table["columns"] if c["name"] == "task_id")
assert task_id_col["type"] == "TEXT"
assert task_id_col["nullable"] is False
def test_get_schema_info_includes_row_counts():
"""Schema info includes row counts for each table."""
dm = DatabaseManager()
dm.initialize()
schema = dm.get_schema_info()
for table in schema["tables"]:
assert "row_count" in table
assert isinstance(table["row_count"], int)
```
**Implementation**:
- Add `get_schema_info()` method to DatabaseManager:
- Query `sqlite_master` for table names
- Use `PRAGMA table_info(table_name)` for column details
- Use `PRAGMA foreign_key_list(table_name)` for foreign keys
- Query `SELECT COUNT(*) FROM table` for row counts
- Return SchemaInfo structure matching contract
**Files Changed**:
- `src/xer_mcp/db/__init__.py`
- `tests/unit/test_db_manager.py`
**Verification**: `pytest tests/unit/test_db_manager.py -v`
**Acceptance**: Schema introspection returns accurate table/column information
---
## Phase 3: User Story 1 - Load XER to Persistent Database (P1)
### Task 3.1: Extend load_xer Tool with db_path Parameter [X]
**Type**: Implementation
**Why**: Core feature - enables persistent database creation
**Dependencies**: Task 2.1, Task 2.2
**Contract Reference**: `contracts/mcp-tools.json` - load_xer inputSchema
**Test First** (TDD):
```python
# tests/contract/test_load_xer.py
@pytest.mark.asyncio
async def test_load_xer_with_db_path_creates_file(tmp_path, sample_xer_file):
"""load_xer with db_path creates persistent database file."""
db_file = tmp_path / "schedule.db"
result = await load_xer(sample_xer_file, db_path=str(db_file))
assert result["success"] is True
assert db_file.exists()
assert result["database"]["db_path"] == str(db_file)
assert result["database"]["is_persistent"] is True
@pytest.mark.asyncio
async def test_load_xer_with_empty_db_path_auto_generates(sample_xer_file):
"""load_xer with empty db_path generates path from XER filename."""
result = await load_xer(sample_xer_file, db_path="")
assert result["success"] is True
expected_db = sample_xer_file.replace(".xer", ".sqlite")
assert result["database"]["db_path"] == expected_db
assert result["database"]["is_persistent"] is True
# Cleanup
os.unlink(expected_db)
@pytest.mark.asyncio
async def test_load_xer_without_db_path_uses_memory(sample_xer_file):
"""load_xer without db_path uses in-memory database (backward compatible)."""
result = await load_xer(sample_xer_file)
assert result["success"] is True
assert result["database"]["db_path"] == ":memory:"
assert result["database"]["is_persistent"] is False
@pytest.mark.asyncio
async def test_load_xer_database_contains_all_data(tmp_path, sample_xer_file):
"""Persistent database contains all parsed data."""
db_file = tmp_path / "schedule.db"
result = await load_xer(sample_xer_file, db_path=str(db_file))
# Verify data via direct SQL
import sqlite3
conn = sqlite3.connect(str(db_file))
cursor = conn.execute("SELECT COUNT(*) FROM activities")
count = cursor.fetchone()[0]
conn.close()
assert count == result["activity_count"]
```
**Implementation**:
- Modify `src/xer_mcp/tools/load_xer.py`:
- Add `db_path: str | None = None` parameter
- Pass `db_path` and `file_path` (as source_file) to `db.initialize()`
- Include `database` field in response with DatabaseInfo
**Files Changed**:
- `src/xer_mcp/tools/load_xer.py`
- `tests/contract/test_load_xer.py`
**Verification**: `pytest tests/contract/test_load_xer.py -v`
**Acceptance**: load_xer creates persistent database when db_path provided
---
### Task 3.2: Add Database Info to load_xer Response [X]
**Type**: Implementation
**Why**: Response must include all info needed to connect to database
**Dependencies**: Task 3.1, Task 2.3
**Contract Reference**: `contracts/mcp-tools.json` - load_xer outputSchema.database
**Test First** (TDD):
```python
# tests/contract/test_load_xer.py
@pytest.mark.asyncio
async def test_load_xer_response_includes_database_info(tmp_path, sample_xer_file):
"""load_xer response includes complete database info."""
db_file = tmp_path / "schedule.db"
result = await load_xer(sample_xer_file, db_path=str(db_file))
assert "database" in result
db_info = result["database"]
assert "db_path" in db_info
assert "is_persistent" in db_info
assert "source_file" in db_info
assert "loaded_at" in db_info
assert "schema" in db_info
@pytest.mark.asyncio
async def test_load_xer_response_schema_includes_tables(tmp_path, sample_xer_file):
"""load_xer response schema includes table information."""
db_file = tmp_path / "schedule.db"
result = await load_xer(sample_xer_file, db_path=str(db_file))
schema = result["database"]["schema"]
assert "version" in schema
assert "tables" in schema
table_names = [t["name"] for t in schema["tables"]]
assert "activities" in table_names
assert "relationships" in table_names
```
**Implementation**:
- Modify `src/xer_mcp/tools/load_xer.py`:
- After successful load, call `db.get_schema_info()`
- Build DatabaseInfo response structure
- Include in return dictionary
**Files Changed**:
- `src/xer_mcp/tools/load_xer.py`
- `tests/contract/test_load_xer.py`
**Verification**: `pytest tests/contract/test_load_xer.py -v`
**Acceptance**: load_xer response includes complete DatabaseInfo with schema
---
### Task 3.3: Register db_path Parameter with MCP Server [X]
**Type**: Implementation
**Why**: MCP server must expose the new parameter to clients
**Dependencies**: Task 3.1
**Contract Reference**: `contracts/mcp-tools.json` - load_xer inputSchema
**Test First** (TDD):
```python
# tests/contract/test_load_xer.py
def test_load_xer_tool_schema_includes_db_path():
"""MCP tool schema includes db_path parameter."""
from xer_mcp.server import server
tools = server.list_tools()
load_xer_tool = next(t for t in tools if t.name == "load_xer")
props = load_xer_tool.inputSchema["properties"]
assert "db_path" in props
assert props["db_path"]["type"] == "string"
```
**Implementation**:
- Modify MCP tool registration in `src/xer_mcp/server.py`:
- Add `db_path` to load_xer tool inputSchema
- Update tool handler to pass db_path to load_xer function
**Files Changed**:
- `src/xer_mcp/server.py`
- `tests/contract/test_load_xer.py`
**Verification**: `pytest tests/contract/test_load_xer.py -v`
**Acceptance**: MCP server exposes db_path parameter for load_xer tool
---
### Task 3.4: Handle Database Write Errors [X]
**Type**: Implementation
**Why**: Clear error messages for write failures (FR-008)
**Dependencies**: Task 3.1
**Contract Reference**: `contracts/mcp-tools.json` - Error schema
**Test First** (TDD):
```python
# tests/contract/test_load_xer.py
@pytest.mark.asyncio
async def test_load_xer_error_on_unwritable_path(sample_xer_file):
"""load_xer returns error for unwritable path."""
result = await load_xer(sample_xer_file, db_path="/root/forbidden.db")
assert result["success"] is False
assert result["error"]["code"] == "FILE_NOT_WRITABLE"
@pytest.mark.asyncio
async def test_load_xer_error_on_invalid_path(sample_xer_file):
"""load_xer returns error for invalid path."""
result = await load_xer(sample_xer_file, db_path="/nonexistent/dir/file.db")
assert result["success"] is False
assert result["error"]["code"] == "FILE_NOT_WRITABLE"
```
**Implementation**:
- Add error handling in load_xer for database creation failures:
- Catch PermissionError → FILE_NOT_WRITABLE
- Catch OSError with ENOSPC → DISK_FULL
- Catch other sqlite3 errors → DATABASE_ERROR
**Files Changed**:
- `src/xer_mcp/tools/load_xer.py`
- `src/xer_mcp/errors.py` (add new error classes if needed)
- `tests/contract/test_load_xer.py`
**Verification**: `pytest tests/contract/test_load_xer.py -v`
**Acceptance**: Clear error messages returned for all database write failures
---
## Phase 4: User Story 2 - Retrieve Database Connection Information (P1)
### Task 4.1: Create get_database_info Tool [X]
**Type**: Implementation
**Why**: Allows retrieval of database info without reloading
**Dependencies**: Task 2.3
**Contract Reference**: `contracts/mcp-tools.json` - get_database_info
**Test First** (TDD):
```python
# tests/contract/test_get_database_info.py
@pytest.mark.asyncio
async def test_get_database_info_returns_current_database(tmp_path, sample_xer_file):
"""get_database_info returns info about currently loaded database."""
db_file = tmp_path / "schedule.db"
await load_xer(sample_xer_file, db_path=str(db_file))
result = await get_database_info()
assert "database" in result
assert result["database"]["db_path"] == str(db_file)
assert result["database"]["is_persistent"] is True
@pytest.mark.asyncio
async def test_get_database_info_error_when_no_database():
"""get_database_info returns error when no database loaded."""
# Reset database state
from xer_mcp.db import db
db.close()
result = await get_database_info()
assert "error" in result
assert result["error"]["code"] == "NO_FILE_LOADED"
@pytest.mark.asyncio
async def test_get_database_info_includes_schema(tmp_path, sample_xer_file):
"""get_database_info includes schema information."""
db_file = tmp_path / "schedule.db"
await load_xer(sample_xer_file, db_path=str(db_file))
result = await get_database_info()
assert "schema" in result["database"]
assert "tables" in result["database"]["schema"]
```
**Implementation**:
- Create `src/xer_mcp/tools/get_database_info.py`:
- Check if database is initialized
- Return NO_FILE_LOADED error if not
- Return DatabaseInfo structure with schema
**Files Changed**:
- `src/xer_mcp/tools/get_database_info.py` (new)
- `tests/contract/test_get_database_info.py` (new)
**Verification**: `pytest tests/contract/test_get_database_info.py -v`
**Acceptance**: get_database_info returns complete DatabaseInfo or appropriate error
---
### Task 4.2: Register get_database_info with MCP Server [X]
**Type**: Implementation
**Why**: MCP server must expose the new tool to clients
**Dependencies**: Task 4.1
**Contract Reference**: `contracts/mcp-tools.json` - get_database_info
**Test First** (TDD):
```python
# tests/contract/test_get_database_info.py
def test_get_database_info_tool_registered():
"""get_database_info tool is registered with MCP server."""
from xer_mcp.server import server
tools = server.list_tools()
tool_names = [t.name for t in tools]
assert "get_database_info" in tool_names
```
**Implementation**:
- Modify `src/xer_mcp/server.py`:
- Import get_database_info function
- Add tool definition with empty inputSchema
- Add handler for get_database_info calls
**Files Changed**:
- `src/xer_mcp/server.py`
- `tests/contract/test_get_database_info.py`
**Verification**: `pytest tests/contract/test_get_database_info.py -v`
**Acceptance**: get_database_info tool accessible via MCP
---
## Phase 5: User Story 3 - Query Database Schema Information (P2)
### Task 5.1: Add Primary Key Information to Schema [X]
**Type**: Implementation
**Why**: Helps developers understand table structure for queries
**Dependencies**: Task 2.3
**Contract Reference**: `contracts/mcp-tools.json` - TableInfo.primary_key
**Test First** (TDD):
```python
# tests/unit/test_db_manager.py
def test_schema_info_includes_primary_keys():
"""Schema info includes primary key for each table."""
dm = DatabaseManager()
dm.initialize()
schema = dm.get_schema_info()
activities_table = next(t for t in schema["tables"] if t["name"] == "activities")
assert "primary_key" in activities_table
assert "task_id" in activities_table["primary_key"]
```
**Implementation**:
- Enhance `get_schema_info()` in DatabaseManager:
- Use `PRAGMA table_info()` to identify PRIMARY KEY columns
- Add to TableInfo structure
**Files Changed**:
- `src/xer_mcp/db/__init__.py`
- `tests/unit/test_db_manager.py`
**Verification**: `pytest tests/unit/test_db_manager.py -v`
**Acceptance**: Primary key information included in schema response
---
### Task 5.2: Add Foreign Key Information to Schema [X]
**Type**: Implementation
**Why**: Documents table relationships for complex queries
**Dependencies**: Task 5.1
**Contract Reference**: `contracts/mcp-tools.json` - ForeignKeyInfo
**Test First** (TDD):
```python
# tests/unit/test_db_manager.py
def test_schema_info_includes_foreign_keys():
"""Schema info includes foreign key relationships."""
dm = DatabaseManager()
dm.initialize()
schema = dm.get_schema_info()
activities_table = next(t for t in schema["tables"] if t["name"] == "activities")
assert "foreign_keys" in activities_table
# activities.proj_id -> projects.proj_id
fk = next((fk for fk in activities_table["foreign_keys"]
if fk["column"] == "proj_id"), None)
assert fk is not None
assert fk["references_table"] == "projects"
assert fk["references_column"] == "proj_id"
```
**Implementation**:
- Enhance `get_schema_info()` in DatabaseManager:
- Use `PRAGMA foreign_key_list(table_name)` to get FK relationships
- Add to TableInfo structure
**Files Changed**:
- `src/xer_mcp/db/__init__.py`
- `tests/unit/test_db_manager.py`
**Verification**: `pytest tests/unit/test_db_manager.py -v`
**Acceptance**: Foreign key information included in schema response
---
## Phase 6: Polish
### Task 6.1: Integration Test - External Script Access [X]
**Type**: Testing
**Why**: Validates end-to-end workflow matches quickstart documentation
**Dependencies**: All previous tasks
**Contract Reference**: `quickstart.md` - Python Example
**Test**:
```python
# tests/integration/test_direct_db_access.py
@pytest.mark.asyncio
async def test_external_script_can_query_database(tmp_path, sample_xer_file):
"""External script can query database using returned path."""
db_file = tmp_path / "schedule.db"
result = await load_xer(sample_xer_file, db_path=str(db_file))
# Simulate external script access (as shown in quickstart.md)
import sqlite3
db_path = result["database"]["db_path"]
conn = sqlite3.connect(db_path)
conn.row_factory = sqlite3.Row
# Query milestones
cursor = conn.execute("""
SELECT task_code, task_name, target_start_date, milestone_type
FROM activities
WHERE task_type IN ('TT_Mile', 'TT_FinMile')
ORDER BY target_start_date
""")
milestones = cursor.fetchall()
conn.close()
assert len(milestones) > 0
assert all(row["task_code"] for row in milestones)
```
**Files Changed**:
- `tests/integration/test_direct_db_access.py` (new)
**Verification**: `pytest tests/integration/test_direct_db_access.py -v`
**Acceptance**: External script workflow matches quickstart documentation
---
### Task 6.2: Update Version to 0.2.0 [X]
**Type**: Configuration
**Why**: Semantic versioning for new feature release
**Dependencies**: All previous tasks
**Steps**:
1. Update version in `pyproject.toml` to `0.2.0`
2. Update version in schema introspection response to `0.2.0`
3. Update any version references in documentation
**Files Changed**:
- `pyproject.toml`
- `src/xer_mcp/db/__init__.py` (SCHEMA_VERSION constant)
**Verification**: `grep -r "0.2.0" pyproject.toml src/`
**Acceptance**: Version consistently shows 0.2.0 across project
---
### Task 6.3: Run Full Test Suite and Linting [X]
**Type**: Verification
**Why**: Ensure all tests pass and code meets standards
**Dependencies**: All previous tasks
**Steps**:
1. Run `pytest` - all tests must pass
2. Run `ruff check .` - no linting errors
3. Run `ruff format --check .` - code properly formatted
**Verification**:
```bash
pytest
ruff check .
ruff format --check .
```
**Acceptance**: All tests pass, no linting errors, code properly formatted
---
### Task 6.4: Commit and Prepare for Merge [X]
**Type**: Git Operations
**Why**: Prepare feature for merge to main branch
**Dependencies**: Task 6.3
**Steps**:
1. Review all changes with `git diff main`
2. Commit any uncommitted changes with descriptive messages
3. Verify branch is ready for PR/merge
**Verification**: `git status` shows clean working directory
**Acceptance**: All changes committed, branch ready for merge
---
## Summary
| Phase | Tasks | Focus |
|-------|-------|-------|
| Phase 1 | 1 | Setup and verification |
| Phase 2 | 3 | DatabaseManager foundation |
| Phase 3 | 4 | US1 - Load to persistent DB (P1) |
| Phase 4 | 2 | US2 - Retrieve DB info (P1) |
| Phase 5 | 2 | US3 - Schema information (P2) |
| Phase 6 | 4 | Integration, versioning, polish |
**Total Tasks**: 16
**Estimated Test Count**: ~25 new tests

3
src/xer_mcp/__init__.py Normal file
View File

@@ -0,0 +1,3 @@
"""XER MCP Server - MCP tools for querying Primavera P6 XER schedule data."""
__version__ = "0.1.0"

14
src/xer_mcp/__main__.py Normal file
View File

@@ -0,0 +1,14 @@
"""Main entry point for the XER MCP Server."""
import asyncio
from xer_mcp.server import run_server
def main() -> None:
"""Run the XER MCP Server."""
asyncio.run(run_server())
if __name__ == "__main__":
main()

261
src/xer_mcp/db/__init__.py Normal file
View File

@@ -0,0 +1,261 @@
"""Database connection management for XER MCP Server."""
import os
import sqlite3
from collections.abc import Generator
from contextlib import contextmanager
from datetime import datetime
from pathlib import Path
from xer_mcp.db.schema import get_schema
# Schema version for introspection responses
SCHEMA_VERSION = "0.2.0"
class DatabaseManager:
"""Manages SQLite database connections and schema initialization."""
def __init__(self) -> None:
"""Initialize database manager."""
self._connection: sqlite3.Connection | None = None
self._db_path: str = ":memory:"
self._source_file: str | None = None
self._loaded_at: datetime | None = None
def initialize(
self,
db_path: str | None = None,
source_file: str | None = None,
) -> None:
"""Initialize the database with schema.
Args:
db_path: Path for database file. If None or omitted, uses in-memory.
If empty string, auto-generates from source_file.
source_file: Path to the XER file being loaded (for tracking).
"""
self._source_file = source_file
self._loaded_at = datetime.now()
# Determine database path
if db_path is None:
# Default: in-memory database
self._db_path = ":memory:"
elif db_path == "":
# Auto-generate from source file
if source_file:
base = Path(source_file).with_suffix(".sqlite")
self._db_path = str(base)
else:
self._db_path = ":memory:"
else:
# Use provided path
self._db_path = db_path
# Create database
if self._db_path == ":memory:":
self._connection = sqlite3.connect(":memory:", check_same_thread=False)
self._connection.row_factory = sqlite3.Row
self._connection.executescript(get_schema())
else:
# File-based database with atomic write pattern
self._create_file_database()
def clear(self) -> None:
"""Clear all data from the database."""
if self._connection is None:
return
tables = ["relationships", "activities", "wbs", "calendars", "projects"]
for table in tables:
self._connection.execute(f"DELETE FROM {table}") # noqa: S608
self._connection.commit()
@property
def connection(self) -> sqlite3.Connection:
"""Get the database connection."""
if self._connection is None:
raise RuntimeError("Database not initialized. Call initialize() first.")
return self._connection
@contextmanager
def cursor(self) -> Generator[sqlite3.Cursor]:
"""Get a cursor for executing queries."""
cur = self.connection.cursor()
try:
yield cur
finally:
cur.close()
def commit(self) -> None:
"""Commit the current transaction."""
self.connection.commit()
def close(self) -> None:
"""Close the database connection."""
if self._connection is not None:
self._connection.close()
self._connection = None
@property
def is_initialized(self) -> bool:
"""Check if the database is initialized."""
return self._connection is not None
@property
def db_path(self) -> str:
"""Get the database path."""
return self._db_path
@property
def is_persistent(self) -> bool:
"""Check if the database is file-based (persistent)."""
return self._db_path != ":memory:"
@property
def source_file(self) -> str | None:
"""Get the source XER file path."""
return self._source_file
@property
def loaded_at(self) -> datetime | None:
"""Get the timestamp when data was loaded."""
return self._loaded_at
def _create_file_database(self) -> None:
"""Create a file-based database with atomic write pattern."""
temp_path = self._db_path + ".tmp"
try:
# Create database at temp path
conn = sqlite3.connect(temp_path, check_same_thread=False)
conn.row_factory = sqlite3.Row
conn.executescript(get_schema())
conn.commit()
conn.close()
# Atomic rename (POSIX)
if os.path.exists(self._db_path):
os.unlink(self._db_path)
os.rename(temp_path, self._db_path)
# Open final database with WAL mode
self._connection = sqlite3.connect(self._db_path, check_same_thread=False)
self._connection.row_factory = sqlite3.Row
self._connection.execute("PRAGMA journal_mode=WAL")
except Exception:
# Clean up temp file on failure
if os.path.exists(temp_path):
os.unlink(temp_path)
raise
def get_schema_info(self) -> dict:
"""Get database schema information for introspection.
Returns:
Dictionary with schema version and table information.
"""
if self._connection is None:
raise RuntimeError("Database not initialized. Call initialize() first.")
tables = []
# Get all tables (excluding sqlite internal tables)
cursor = self._connection.execute(
"SELECT name FROM sqlite_master WHERE type='table' "
"AND name NOT LIKE 'sqlite_%' ORDER BY name"
)
table_names = [row[0] for row in cursor.fetchall()]
for table_name in table_names:
table_info = self._get_table_info(table_name)
tables.append(table_info)
return {
"version": SCHEMA_VERSION,
"tables": tables,
}
def _get_table_info(self, table_name: str) -> dict:
"""Get detailed information about a table.
Args:
table_name: Name of the table.
Returns:
Dictionary with table name, columns, primary keys, foreign keys, row count.
"""
columns = []
primary_key = []
# Get column info
cursor = self._connection.execute(f"PRAGMA table_info({table_name})") # noqa: S608
for row in cursor.fetchall():
col_name = row[1]
col_type = row[2] or "TEXT"
not_null = bool(row[3])
default_val = row[4]
is_pk = bool(row[5])
col_info: dict = {
"name": col_name,
"type": col_type,
"nullable": not not_null,
}
if default_val is not None:
col_info["default"] = str(default_val)
columns.append(col_info)
if is_pk:
primary_key.append(col_name)
# Get foreign keys
foreign_keys = []
cursor = self._connection.execute(
f"PRAGMA foreign_key_list({table_name})" # noqa: S608
)
for row in cursor.fetchall():
fk_info = {
"column": row[3], # from column
"references_table": row[2], # table
"references_column": row[4], # to column
}
foreign_keys.append(fk_info)
# Get row count
cursor = self._connection.execute(
f"SELECT COUNT(*) FROM {table_name}" # noqa: S608
)
row_count = cursor.fetchone()[0]
return {
"name": table_name,
"columns": columns,
"primary_key": primary_key,
"foreign_keys": foreign_keys,
"row_count": row_count,
}
def get_database_info(self) -> dict:
"""Get complete database information for API responses.
Returns:
Dictionary with database path, persistence status, source file,
loaded timestamp, and schema information.
"""
if not self.is_initialized:
raise RuntimeError("Database not initialized. Call initialize() first.")
return {
"db_path": self._db_path,
"is_persistent": self.is_persistent,
"source_file": self._source_file,
"loaded_at": self._loaded_at.isoformat() if self._loaded_at else None,
"schema": self.get_schema_info(),
}
# Global database manager instance
db = DatabaseManager()

145
src/xer_mcp/db/loader.py Normal file
View File

@@ -0,0 +1,145 @@
"""Database loader for parsed XER data."""
from xer_mcp.db import db
from xer_mcp.parser.xer_parser import ParsedXer
def load_parsed_data(parsed: ParsedXer, project_id: str) -> None:
"""Load parsed XER data into the database.
Only loads data for the specified project.
Args:
parsed: Parsed XER data
project_id: ID of the project to load
"""
# Find the project
project = next((p for p in parsed.projects if p["proj_id"] == project_id), None)
if project is None:
raise ValueError(f"Project {project_id} not found in parsed data")
# Clear existing data
db.clear()
with db.cursor() as cur:
# Insert project
cur.execute(
"""
INSERT INTO projects (proj_id, proj_short_name, plan_start_date, plan_end_date, last_recalc_date)
VALUES (?, ?, ?, ?, ?)
""",
(
project["proj_id"],
project["proj_short_name"],
project["plan_start_date"],
project["plan_end_date"],
project.get("last_recalc_date"),
),
)
# Insert WBS elements for this project
for wbs in parsed.projwbs:
if wbs["proj_id"] == project_id:
cur.execute(
"""
INSERT INTO wbs (wbs_id, proj_id, parent_wbs_id, wbs_short_name, wbs_name)
VALUES (?, ?, ?, ?, ?)
""",
(
wbs["wbs_id"],
wbs["proj_id"],
wbs["parent_wbs_id"] or None,
wbs["wbs_short_name"],
wbs["wbs_name"],
),
)
# Insert calendars (all calendars, they may be shared)
for cal in parsed.calendars:
cur.execute(
"""
INSERT OR IGNORE INTO calendars (clndr_id, clndr_name, day_hr_cnt, week_hr_cnt)
VALUES (?, ?, ?, ?)
""",
(
cal["clndr_id"],
cal["clndr_name"],
cal["day_hr_cnt"],
cal["week_hr_cnt"],
),
)
# Insert activities for this project
for task in parsed.tasks:
if task["proj_id"] == project_id:
cur.execute(
"""
INSERT INTO activities (
task_id, proj_id, wbs_id, task_code, task_name, task_type,
target_start_date, target_end_date, early_start_date, early_end_date,
act_start_date, act_end_date,
total_float_hr_cnt, driving_path_flag, status_code, milestone_type
)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
""",
(
task["task_id"],
task["proj_id"],
task["wbs_id"],
task["task_code"],
task["task_name"],
task["task_type"],
task["target_start_date"],
task["target_end_date"],
task.get("early_start_date"),
task.get("early_end_date"),
task["act_start_date"],
task["act_end_date"],
task["total_float_hr_cnt"],
1 if task["driving_path_flag"] else 0,
task["status_code"],
task.get("milestone_type"),
),
)
# Build set of task IDs in this project
project_task_ids = {t["task_id"] for t in parsed.tasks if t["proj_id"] == project_id}
# Insert relationships where both tasks are in this project
for rel in parsed.taskpreds:
if (
rel.get("proj_id") == project_id
and rel["task_id"] in project_task_ids
and rel["pred_task_id"] in project_task_ids
):
cur.execute(
"""
INSERT INTO relationships (
task_pred_id, task_id, pred_task_id, pred_type, lag_hr_cnt
)
VALUES (?, ?, ?, ?, ?)
""",
(
rel["task_pred_id"],
rel["task_id"],
rel["pred_task_id"],
rel["pred_type"],
rel["lag_hr_cnt"],
),
)
db.commit()
def get_activity_count() -> int:
"""Get the count of activities in the database."""
with db.cursor() as cur:
cur.execute("SELECT COUNT(*) FROM activities")
return cur.fetchone()[0]
def get_relationship_count() -> int:
"""Get the count of relationships in the database."""
with db.cursor() as cur:
cur.execute("SELECT COUNT(*) FROM relationships")
return cur.fetchone()[0]

490
src/xer_mcp/db/queries.py Normal file
View File

@@ -0,0 +1,490 @@
"""Database query functions for XER data."""
from datetime import datetime, timedelta
from xer_mcp.db import db
def is_driving_relationship(
pred_early_end: str | None,
succ_early_start: str | None,
lag_hours: float,
pred_type: str,
) -> bool:
"""Determine if a relationship is driving the successor's early start.
A relationship is "driving" when the predecessor's completion (plus lag)
determines the successor's early start date. This is computed by comparing
dates with a tolerance for overnight gaps and calendar differences.
Args:
pred_early_end: Predecessor's early end date (ISO format)
succ_early_start: Successor's early start date (ISO format)
lag_hours: Lag duration in hours (can be negative)
pred_type: Relationship type (FS, SS, FF, SF)
Returns:
True if the relationship is driving, False otherwise
"""
if pred_early_end is None or succ_early_start is None:
return False
try:
pred_end = datetime.fromisoformat(pred_early_end)
succ_start = datetime.fromisoformat(succ_early_start)
except (ValueError, TypeError):
return False
# For FS (Finish-to-Start): pred_end + lag should equal succ_start
if pred_type == "FS":
expected_start = pred_end + timedelta(hours=lag_hours)
# Allow tolerance of 24 hours for overnight gaps and calendar differences
diff = abs((succ_start - expected_start).total_seconds())
return diff <= 24 * 3600 # 24 hours tolerance
# For SS (Start-to-Start): would need pred_early_start, not implemented
# For FF (Finish-to-Finish): would need succ_early_end, not implemented
# For SF (Start-to-Finish): complex case, not implemented
# Default to False for non-FS relationships for now
return False
def query_activities(
limit: int = 100,
offset: int = 0,
start_date: str | None = None,
end_date: str | None = None,
wbs_id: str | None = None,
activity_type: str | None = None,
) -> tuple[list[dict], int]:
"""Query activities with pagination and filtering.
Args:
limit: Maximum number of results to return
offset: Number of results to skip
start_date: Filter activities starting on or after this date (YYYY-MM-DD)
end_date: Filter activities ending on or before this date (YYYY-MM-DD)
wbs_id: Filter by WBS ID
activity_type: Filter by task type (TT_Task, TT_Mile, etc.)
Returns:
Tuple of (list of activity dicts, total count matching filters)
"""
# Build WHERE clause
conditions = []
params: list = []
if start_date:
conditions.append("target_start_date >= ?")
params.append(f"{start_date}T00:00:00")
if end_date:
conditions.append("target_end_date <= ?")
params.append(f"{end_date}T23:59:59")
if wbs_id:
conditions.append("wbs_id = ?")
params.append(wbs_id)
if activity_type:
conditions.append("task_type = ?")
params.append(activity_type)
where_clause = " AND ".join(conditions) if conditions else "1=1"
# Get total count
with db.cursor() as cur:
cur.execute(f"SELECT COUNT(*) FROM activities WHERE {where_clause}", params) # noqa: S608
total = cur.fetchone()[0]
# Get paginated results
query = f"""
SELECT task_id, task_code, task_name, task_type,
target_start_date, target_end_date, status_code,
driving_path_flag, wbs_id, total_float_hr_cnt
FROM activities
WHERE {where_clause}
ORDER BY target_start_date, task_code
LIMIT ? OFFSET ?
""" # noqa: S608
with db.cursor() as cur:
cur.execute(query, [*params, limit, offset])
rows = cur.fetchall()
activities = [
{
"task_id": row[0],
"task_code": row[1],
"task_name": row[2],
"task_type": row[3],
"target_start_date": row[4],
"target_end_date": row[5],
"status_code": row[6],
"driving_path_flag": bool(row[7]),
}
for row in rows
]
return activities, total
def get_activity_by_id(activity_id: str) -> dict | None:
"""Get a single activity by ID with full details.
Args:
activity_id: The task_id to look up
Returns:
Activity dict with all fields, or None if not found
"""
query = """
SELECT a.task_id, a.task_code, a.task_name, a.task_type,
a.wbs_id, w.wbs_name,
a.target_start_date, a.target_end_date,
a.act_start_date, a.act_end_date,
a.total_float_hr_cnt, a.status_code, a.driving_path_flag
FROM activities a
LEFT JOIN wbs w ON a.wbs_id = w.wbs_id
WHERE a.task_id = ?
"""
with db.cursor() as cur:
cur.execute(query, (activity_id,))
row = cur.fetchone()
if row is None:
return None
# Count predecessors and successors
with db.cursor() as cur:
cur.execute(
"SELECT COUNT(*) FROM relationships WHERE task_id = ?",
(activity_id,),
)
predecessor_count = cur.fetchone()[0]
cur.execute(
"SELECT COUNT(*) FROM relationships WHERE pred_task_id = ?",
(activity_id,),
)
successor_count = cur.fetchone()[0]
return {
"task_id": row[0],
"task_code": row[1],
"task_name": row[2],
"task_type": row[3],
"wbs_id": row[4],
"wbs_name": row[5],
"target_start_date": row[6],
"target_end_date": row[7],
"act_start_date": row[8],
"act_end_date": row[9],
"total_float_hr_cnt": row[10],
"status_code": row[11],
"driving_path_flag": bool(row[12]),
"predecessor_count": predecessor_count,
"successor_count": successor_count,
}
def query_relationships(
limit: int = 100,
offset: int = 0,
) -> tuple[list[dict], int]:
"""Query relationships with pagination.
Args:
limit: Maximum number of results to return
offset: Number of results to skip
Returns:
Tuple of (list of relationship dicts, total count)
"""
# Get total count
with db.cursor() as cur:
cur.execute("SELECT COUNT(*) FROM relationships")
total = cur.fetchone()[0]
# Get paginated results with activity names and early dates for driving computation
query = """
SELECT r.task_pred_id, r.task_id, succ.task_name,
r.pred_task_id, pred.task_name,
r.pred_type, r.lag_hr_cnt,
pred.early_end_date, succ.early_start_date
FROM relationships r
LEFT JOIN activities succ ON r.task_id = succ.task_id
LEFT JOIN activities pred ON r.pred_task_id = pred.task_id
ORDER BY r.task_pred_id
LIMIT ? OFFSET ?
"""
with db.cursor() as cur:
cur.execute(query, (limit, offset))
rows = cur.fetchall()
# Convert pred_type from internal format (PR_FS) to API format (FS)
def format_pred_type(pred_type: str) -> str:
if pred_type.startswith("PR_"):
return pred_type[3:]
return pred_type
relationships = []
for row in rows:
pred_type = format_pred_type(row[5])
driving = is_driving_relationship(
pred_early_end=row[7],
succ_early_start=row[8],
lag_hours=row[6] or 0.0,
pred_type=pred_type,
)
relationships.append(
{
"task_pred_id": row[0],
"task_id": row[1],
"task_name": row[2],
"pred_task_id": row[3],
"pred_task_name": row[4],
"pred_type": pred_type,
"lag_hr_cnt": row[6],
"driving": driving,
}
)
return relationships, total
def get_predecessors(activity_id: str) -> list[dict]:
"""Get predecessor activities for a given activity.
Args:
activity_id: The task_id to find predecessors for
Returns:
List of predecessor activity dicts with relationship info and driving flag
"""
# Get successor's early start for driving calculation
with db.cursor() as cur:
cur.execute(
"SELECT early_start_date FROM activities WHERE task_id = ?",
(activity_id,),
)
succ_row = cur.fetchone()
succ_early_start = succ_row[0] if succ_row else None
query = """
SELECT pred.task_id, pred.task_code, pred.task_name,
r.pred_type, r.lag_hr_cnt, pred.early_end_date
FROM relationships r
JOIN activities pred ON r.pred_task_id = pred.task_id
WHERE r.task_id = ?
ORDER BY pred.task_code
"""
with db.cursor() as cur:
cur.execute(query, (activity_id,))
rows = cur.fetchall()
def format_pred_type(pred_type: str) -> str:
if pred_type.startswith("PR_"):
return pred_type[3:]
return pred_type
result = []
for row in rows:
pred_type = format_pred_type(row[3])
driving = is_driving_relationship(
pred_early_end=row[5],
succ_early_start=succ_early_start,
lag_hours=row[4] or 0.0,
pred_type=pred_type,
)
result.append(
{
"task_id": row[0],
"task_code": row[1],
"task_name": row[2],
"relationship_type": pred_type,
"lag_hr_cnt": row[4],
"driving": driving,
}
)
return result
def get_successors(activity_id: str) -> list[dict]:
"""Get successor activities for a given activity.
Args:
activity_id: The task_id to find successors for
Returns:
List of successor activity dicts with relationship info and driving flag
"""
# Get predecessor's early end for driving calculation
with db.cursor() as cur:
cur.execute(
"SELECT early_end_date FROM activities WHERE task_id = ?",
(activity_id,),
)
pred_row = cur.fetchone()
pred_early_end = pred_row[0] if pred_row else None
query = """
SELECT succ.task_id, succ.task_code, succ.task_name,
r.pred_type, r.lag_hr_cnt, succ.early_start_date
FROM relationships r
JOIN activities succ ON r.task_id = succ.task_id
WHERE r.pred_task_id = ?
ORDER BY succ.task_code
"""
with db.cursor() as cur:
cur.execute(query, (activity_id,))
rows = cur.fetchall()
def format_pred_type(pred_type: str) -> str:
if pred_type.startswith("PR_"):
return pred_type[3:]
return pred_type
result = []
for row in rows:
pred_type = format_pred_type(row[3])
driving = is_driving_relationship(
pred_early_end=pred_early_end,
succ_early_start=row[5],
lag_hours=row[4] or 0.0,
pred_type=pred_type,
)
result.append(
{
"task_id": row[0],
"task_code": row[1],
"task_name": row[2],
"relationship_type": pred_type,
"lag_hr_cnt": row[4],
"driving": driving,
}
)
return result
def get_project_summary(project_id: str) -> dict | None:
"""Get project summary information.
Args:
project_id: The project ID to get summary for
Returns:
Dictionary with project summary or None if not found
"""
# Get project info
with db.cursor() as cur:
cur.execute(
"""
SELECT proj_id, proj_short_name, plan_start_date, plan_end_date, last_recalc_date
FROM projects
WHERE proj_id = ?
""",
(project_id,),
)
project_row = cur.fetchone()
if project_row is None:
return None
# Get activity count
with db.cursor() as cur:
cur.execute("SELECT COUNT(*) FROM activities")
activity_count = cur.fetchone()[0]
# Get milestone count (both start and finish milestones)
with db.cursor() as cur:
cur.execute("SELECT COUNT(*) FROM activities WHERE task_type IN ('TT_Mile', 'TT_FinMile')")
milestone_count = cur.fetchone()[0]
# Get critical activity count
with db.cursor() as cur:
cur.execute("SELECT COUNT(*) FROM activities WHERE driving_path_flag = 1")
critical_count = cur.fetchone()[0]
return {
"project_id": project_row[0],
"project_name": project_row[1],
"data_date": project_row[4],
"plan_start_date": project_row[2],
"plan_end_date": project_row[3],
"activity_count": activity_count,
"milestone_count": milestone_count,
"critical_activity_count": critical_count,
}
def query_milestones() -> list[dict]:
"""Query all milestone activities (both start and finish milestones).
Returns:
List of milestone activity dicts with milestone_type (start/finish)
"""
query = """
SELECT task_id, task_code, task_name,
target_start_date, target_end_date, status_code, milestone_type
FROM activities
WHERE task_type IN ('TT_Mile', 'TT_FinMile')
ORDER BY target_start_date, task_code
"""
with db.cursor() as cur:
cur.execute(query)
rows = cur.fetchall()
return [
{
"task_id": row[0],
"task_code": row[1],
"task_name": row[2],
"target_start_date": row[3],
"target_end_date": row[4],
"status_code": row[5],
"milestone_type": row[6],
}
for row in rows
]
def query_critical_path() -> list[dict]:
"""Query all activities on the critical path.
Returns:
List of critical path activity dicts ordered by start date
"""
query = """
SELECT task_id, task_code, task_name, task_type,
target_start_date, target_end_date,
total_float_hr_cnt, status_code
FROM activities
WHERE driving_path_flag = 1
ORDER BY target_start_date, task_code
"""
with db.cursor() as cur:
cur.execute(query)
rows = cur.fetchall()
return [
{
"task_id": row[0],
"task_code": row[1],
"task_name": row[2],
"task_type": row[3],
"target_start_date": row[4],
"target_end_date": row[5],
"total_float_hr_cnt": row[6],
"status_code": row[7],
}
for row in rows
]

81
src/xer_mcp/db/schema.py Normal file
View File

@@ -0,0 +1,81 @@
"""SQLite database schema for XER MCP Server."""
SCHEMA_SQL = """
-- Projects
CREATE TABLE IF NOT EXISTS projects (
proj_id TEXT PRIMARY KEY,
proj_short_name TEXT NOT NULL,
plan_start_date TEXT,
plan_end_date TEXT,
last_recalc_date TEXT,
loaded_at TEXT NOT NULL DEFAULT (datetime('now'))
);
-- Activities
CREATE TABLE IF NOT EXISTS activities (
task_id TEXT PRIMARY KEY,
proj_id TEXT NOT NULL,
wbs_id TEXT,
task_code TEXT NOT NULL,
task_name TEXT NOT NULL,
task_type TEXT NOT NULL,
target_start_date TEXT,
target_end_date TEXT,
early_start_date TEXT,
early_end_date TEXT,
act_start_date TEXT,
act_end_date TEXT,
total_float_hr_cnt REAL,
driving_path_flag INTEGER DEFAULT 0,
status_code TEXT,
milestone_type TEXT,
FOREIGN KEY (proj_id) REFERENCES projects(proj_id)
);
-- Relationships
CREATE TABLE IF NOT EXISTS relationships (
task_pred_id TEXT PRIMARY KEY,
task_id TEXT NOT NULL,
pred_task_id TEXT NOT NULL,
pred_type TEXT NOT NULL,
lag_hr_cnt REAL DEFAULT 0,
FOREIGN KEY (task_id) REFERENCES activities(task_id),
FOREIGN KEY (pred_task_id) REFERENCES activities(task_id)
);
-- WBS (Work Breakdown Structure)
CREATE TABLE IF NOT EXISTS wbs (
wbs_id TEXT PRIMARY KEY,
proj_id TEXT NOT NULL,
parent_wbs_id TEXT,
wbs_short_name TEXT NOT NULL,
wbs_name TEXT,
FOREIGN KEY (proj_id) REFERENCES projects(proj_id),
FOREIGN KEY (parent_wbs_id) REFERENCES wbs(wbs_id)
);
-- Calendars (internal use only)
CREATE TABLE IF NOT EXISTS calendars (
clndr_id TEXT PRIMARY KEY,
clndr_name TEXT NOT NULL,
day_hr_cnt REAL,
week_hr_cnt REAL
);
-- Indexes for performance
CREATE INDEX IF NOT EXISTS idx_activities_proj ON activities(proj_id);
CREATE INDEX IF NOT EXISTS idx_activities_wbs ON activities(wbs_id);
CREATE INDEX IF NOT EXISTS idx_activities_type ON activities(task_type);
CREATE INDEX IF NOT EXISTS idx_activities_critical ON activities(driving_path_flag)
WHERE driving_path_flag = 1;
CREATE INDEX IF NOT EXISTS idx_activities_dates ON activities(target_start_date, target_end_date);
CREATE INDEX IF NOT EXISTS idx_relationships_task ON relationships(task_id);
CREATE INDEX IF NOT EXISTS idx_relationships_pred ON relationships(pred_task_id);
CREATE INDEX IF NOT EXISTS idx_wbs_parent ON wbs(parent_wbs_id);
CREATE INDEX IF NOT EXISTS idx_wbs_proj ON wbs(proj_id);
"""
def get_schema() -> str:
"""Return the complete SQLite schema."""
return SCHEMA_SQL

85
src/xer_mcp/errors.py Normal file
View File

@@ -0,0 +1,85 @@
"""Error types for XER MCP Server."""
class XerMcpError(Exception):
"""Base exception for XER MCP Server."""
def __init__(self, code: str, message: str) -> None:
self.code = code
self.message = message
super().__init__(f"{code}: {message}")
class FileNotFoundError(XerMcpError):
"""Raised when the specified XER file does not exist."""
def __init__(self, file_path: str) -> None:
super().__init__(
"FILE_NOT_FOUND",
f"XER file not found: {file_path}",
)
class ParseError(XerMcpError):
"""Raised when the XER file cannot be parsed."""
def __init__(self, message: str) -> None:
super().__init__("PARSE_ERROR", message)
class NoFileLoadedError(XerMcpError):
"""Raised when a query is attempted before loading an XER file."""
def __init__(self) -> None:
super().__init__(
"NO_FILE_LOADED",
"No XER file is loaded. Use the load_xer tool first.",
)
class ProjectSelectionRequiredError(XerMcpError):
"""Raised when a multi-project file requires explicit project selection."""
def __init__(self, available_projects: list[dict]) -> None:
self.available_projects = available_projects
super().__init__(
"PROJECT_SELECTION_REQUIRED",
"Multiple projects found. Please specify project_id.",
)
class ActivityNotFoundError(XerMcpError):
"""Raised when the specified activity does not exist."""
def __init__(self, activity_id: str) -> None:
super().__init__(
"ACTIVITY_NOT_FOUND",
f"Activity not found: {activity_id}",
)
class FileNotWritableError(XerMcpError):
"""Raised when the database file path is not writable."""
def __init__(self, path: str, reason: str = "") -> None:
msg = f"Cannot write to database file: {path}"
if reason:
msg = f"{msg} ({reason})"
super().__init__("FILE_NOT_WRITABLE", msg)
class DiskFullError(XerMcpError):
"""Raised when there is insufficient disk space."""
def __init__(self, path: str) -> None:
super().__init__(
"DISK_FULL",
f"Insufficient disk space to create database: {path}",
)
class DatabaseError(XerMcpError):
"""Raised for general database errors."""
def __init__(self, message: str) -> None:
super().__init__("DATABASE_ERROR", message)

View File

@@ -0,0 +1,17 @@
"""Data models for XER MCP Server."""
from xer_mcp.models.activity import Activity
from xer_mcp.models.calendar import Calendar
from xer_mcp.models.pagination import PaginationMetadata
from xer_mcp.models.project import Project
from xer_mcp.models.relationship import Relationship
from xer_mcp.models.wbs import WBS
__all__ = [
"Activity",
"Calendar",
"PaginationMetadata",
"Project",
"Relationship",
"WBS",
]

View File

@@ -0,0 +1,23 @@
"""Activity data model."""
from dataclasses import dataclass
from datetime import datetime
@dataclass
class Activity:
"""A unit of work in the schedule."""
task_id: str
proj_id: str
task_code: str
task_name: str
task_type: str
wbs_id: str | None = None
target_start_date: datetime | None = None
target_end_date: datetime | None = None
act_start_date: datetime | None = None
act_end_date: datetime | None = None
total_float_hr_cnt: float | None = None
driving_path_flag: bool = False
status_code: str | None = None

View File

@@ -0,0 +1,13 @@
"""Calendar data model (internal use only)."""
from dataclasses import dataclass
@dataclass
class Calendar:
"""Work schedule definition. Not exposed via MCP tools."""
clndr_id: str
clndr_name: str
day_hr_cnt: float | None = None
week_hr_cnt: float | None = None

View File

@@ -0,0 +1,13 @@
"""Pagination metadata model."""
from dataclasses import dataclass
@dataclass
class PaginationMetadata:
"""Response wrapper for paginated queries."""
total_count: int
offset: int
limit: int
has_more: bool

View File

@@ -0,0 +1,15 @@
"""Project data model."""
from dataclasses import dataclass
from datetime import datetime
@dataclass
class Project:
"""Top-level container representing a P6 project."""
proj_id: str
proj_short_name: str
plan_start_date: datetime | None = None
plan_end_date: datetime | None = None
loaded_at: datetime | None = None

View File

@@ -0,0 +1,14 @@
"""Relationship data model."""
from dataclasses import dataclass
@dataclass
class Relationship:
"""A dependency link between two activities."""
task_pred_id: str
task_id: str
pred_task_id: str
pred_type: str
lag_hr_cnt: float = 0.0

14
src/xer_mcp/models/wbs.py Normal file
View File

@@ -0,0 +1,14 @@
"""Work Breakdown Structure (WBS) data model."""
from dataclasses import dataclass
@dataclass
class WBS:
"""Hierarchical organization of activities."""
wbs_id: str
proj_id: str
wbs_short_name: str
parent_wbs_id: str | None = None
wbs_name: str | None = None

View File

@@ -0,0 +1 @@
"""XER file parser module."""

View File

@@ -0,0 +1,27 @@
"""XER table handlers module."""
from xer_mcp.parser.table_handlers.base import TableHandler
from xer_mcp.parser.table_handlers.calendar import CalendarHandler
from xer_mcp.parser.table_handlers.project import ProjectHandler
from xer_mcp.parser.table_handlers.projwbs import ProjwbsHandler
from xer_mcp.parser.table_handlers.task import TaskHandler
from xer_mcp.parser.table_handlers.taskpred import TaskpredHandler
# Registry mapping table names to handlers
TABLE_HANDLERS: dict[str, type[TableHandler]] = {
"PROJECT": ProjectHandler,
"TASK": TaskHandler,
"TASKPRED": TaskpredHandler,
"PROJWBS": ProjwbsHandler,
"CALENDAR": CalendarHandler,
}
__all__ = [
"CalendarHandler",
"ProjectHandler",
"ProjwbsHandler",
"TABLE_HANDLERS",
"TableHandler",
"TaskHandler",
"TaskpredHandler",
]

View File

@@ -0,0 +1,30 @@
"""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
"""
...

View File

@@ -0,0 +1,32 @@
"""CALENDAR table handler."""
from xer_mcp.parser.table_handlers.base import TableHandler
class CalendarHandler(TableHandler):
"""Handler for CALENDAR table in XER files."""
@property
def table_name(self) -> str:
return "CALENDAR"
def parse_row(self, fields: list[str], values: list[str]) -> dict | None:
"""Parse a CALENDAR row."""
if len(values) < len(fields):
values = values + [""] * (len(fields) - len(values))
data = dict(zip(fields, values, strict=False))
# Parse numeric fields
day_hr_str = data.get("day_hr_cnt", "")
day_hr = float(day_hr_str) if day_hr_str else None
week_hr_str = data.get("week_hr_cnt", "")
week_hr = float(week_hr_str) if week_hr_str else None
return {
"clndr_id": data.get("clndr_id", ""),
"clndr_name": data.get("clndr_name", ""),
"day_hr_cnt": day_hr,
"week_hr_cnt": week_hr,
}

View File

@@ -0,0 +1,39 @@
"""PROJECT table handler."""
from xer_mcp.parser.table_handlers.base import TableHandler
def convert_date(date_str: str | None) -> str | None:
"""Convert XER date format to ISO8601.
XER format: "YYYY-MM-DD HH:MM"
ISO8601 format: "YYYY-MM-DDTHH:MM:SS"
"""
if not date_str or date_str.strip() == "":
return None
# Replace space with T and add seconds
return date_str.replace(" ", "T") + ":00"
class ProjectHandler(TableHandler):
"""Handler for PROJECT table in XER files."""
@property
def table_name(self) -> str:
return "PROJECT"
def parse_row(self, fields: list[str], values: list[str]) -> dict | None:
"""Parse a PROJECT row."""
if len(values) < len(fields):
# Pad with empty strings if needed
values = values + [""] * (len(fields) - len(values))
data = dict(zip(fields, values, strict=False))
return {
"proj_id": data.get("proj_id", ""),
"proj_short_name": data.get("proj_short_name", ""),
"plan_start_date": convert_date(data.get("plan_start_date")),
"plan_end_date": convert_date(data.get("plan_end_date")),
"last_recalc_date": convert_date(data.get("last_recalc_date")),
}

View File

@@ -0,0 +1,26 @@
"""PROJWBS table handler."""
from xer_mcp.parser.table_handlers.base import TableHandler
class ProjwbsHandler(TableHandler):
"""Handler for PROJWBS (WBS) table in XER files."""
@property
def table_name(self) -> str:
return "PROJWBS"
def parse_row(self, fields: list[str], values: list[str]) -> dict | None:
"""Parse a PROJWBS row."""
if len(values) < len(fields):
values = values + [""] * (len(fields) - len(values))
data = dict(zip(fields, values, strict=False))
return {
"wbs_id": data.get("wbs_id", ""),
"proj_id": data.get("proj_id", ""),
"parent_wbs_id": data.get("parent_wbs_id", ""),
"wbs_short_name": data.get("wbs_short_name", ""),
"wbs_name": data.get("wbs_name") or None,
}

View File

@@ -0,0 +1,62 @@
"""TASK table handler."""
from xer_mcp.parser.table_handlers.base import TableHandler
from xer_mcp.parser.table_handlers.project import convert_date
class TaskHandler(TableHandler):
"""Handler for TASK table in XER files."""
@property
def table_name(self) -> str:
return "TASK"
def parse_row(self, fields: list[str], values: list[str]) -> dict | None:
"""Parse a TASK row."""
if len(values) < len(fields):
values = values + [""] * (len(fields) - len(values))
data = dict(zip(fields, values, strict=False))
# Parse driving_path_flag (Y/N -> bool)
driving_flag = data.get("driving_path_flag", "N")
driving_path = driving_flag.upper() == "Y" if driving_flag else False
# Parse total_float_hr_cnt
float_str = data.get("total_float_hr_cnt", "")
total_float = float(float_str) if float_str else None
# Parse milestone_type
# First check explicit milestone_type field (MS_Start -> 'start', MS_Finish -> 'finish')
# Then derive from task_type (TT_Mile -> 'start', TT_FinMile -> 'finish')
raw_milestone_type = data.get("milestone_type", "")
task_type = data.get("task_type", "")
milestone_type = None
if raw_milestone_type:
if raw_milestone_type == "MS_Start":
milestone_type = "start"
elif raw_milestone_type == "MS_Finish":
milestone_type = "finish"
elif task_type == "TT_Mile":
milestone_type = "start"
elif task_type == "TT_FinMile":
milestone_type = "finish"
return {
"task_id": data.get("task_id", ""),
"proj_id": data.get("proj_id", ""),
"wbs_id": data.get("wbs_id") or None,
"task_code": data.get("task_code", ""),
"task_name": data.get("task_name", ""),
"task_type": data.get("task_type", ""),
"status_code": data.get("status_code") or None,
"target_start_date": convert_date(data.get("target_start_date")),
"target_end_date": convert_date(data.get("target_end_date")),
"early_start_date": convert_date(data.get("early_start_date")),
"early_end_date": convert_date(data.get("early_end_date")),
"act_start_date": convert_date(data.get("act_start_date")),
"act_end_date": convert_date(data.get("act_end_date")),
"total_float_hr_cnt": total_float,
"driving_path_flag": driving_path,
"milestone_type": milestone_type,
}

View File

@@ -0,0 +1,31 @@
"""TASKPRED table handler."""
from xer_mcp.parser.table_handlers.base import TableHandler
class TaskpredHandler(TableHandler):
"""Handler for TASKPRED (relationships) table in XER files."""
@property
def table_name(self) -> str:
return "TASKPRED"
def parse_row(self, fields: list[str], values: list[str]) -> dict | None:
"""Parse a TASKPRED row."""
if len(values) < len(fields):
values = values + [""] * (len(fields) - len(values))
data = dict(zip(fields, values, strict=False))
# Parse lag_hr_cnt
lag_str = data.get("lag_hr_cnt", "0")
lag_hr = float(lag_str) if lag_str else 0.0
return {
"task_pred_id": data.get("task_pred_id", ""),
"task_id": data.get("task_id", ""),
"pred_task_id": data.get("pred_task_id", ""),
"proj_id": data.get("proj_id", ""),
"pred_type": data.get("pred_type", ""),
"lag_hr_cnt": lag_hr,
}

View File

@@ -0,0 +1,127 @@
"""XER file parser."""
from dataclasses import dataclass, field
from pathlib import Path
from xer_mcp.errors import FileNotFoundError, ParseError
from xer_mcp.parser.table_handlers import TABLE_HANDLERS
@dataclass
class ParsedXer:
"""Container for parsed XER data."""
projects: list[dict] = field(default_factory=list)
tasks: list[dict] = field(default_factory=list)
taskpreds: list[dict] = field(default_factory=list)
projwbs: list[dict] = field(default_factory=list)
calendars: list[dict] = field(default_factory=list)
class XerParser:
"""Parser for Primavera P6 XER files.
XER files are tab-delimited with the following structure:
- ERMHDR line: header with version info
- %T lines: table name declarations
- %F lines: field (column) names
- %R lines: data rows
"""
def parse(self, file_path: Path | str) -> ParsedXer:
"""Parse an XER file and return structured data.
Args:
file_path: Path to the XER file
Returns:
ParsedXer containing all parsed tables
Raises:
FileNotFoundError: If file doesn't exist
ParseError: If file is invalid or cannot be parsed
"""
path = Path(file_path)
if not path.exists():
raise FileNotFoundError(str(path))
try:
content = path.read_text(encoding="utf-8", errors="replace")
except OSError as e:
raise ParseError(f"Cannot read file: {e}") from e
return self._parse_content(content)
def _parse_content(self, content: str) -> ParsedXer:
"""Parse XER content string."""
lines = content.split("\n")
if not lines:
raise ParseError("Empty file")
# Check for ERMHDR line
first_line = lines[0].strip()
if not first_line.startswith("ERMHDR"):
raise ParseError("Invalid XER file: missing ERMHDR header")
result = ParsedXer()
current_table: str | None = None
current_fields: list[str] = []
for line in lines[1:]:
line = line.rstrip("\r\n")
if not line:
continue
parts = line.split("\t")
if not parts:
continue
marker = parts[0]
if marker == "%T":
# Table declaration
if len(parts) < 2:
continue
current_table = parts[1]
current_fields = []
elif marker == "%F":
# Field names
current_fields = parts[1:]
elif marker == "%R":
# Data row
if current_table and current_fields:
values = parts[1:]
row_data = self._parse_row(current_table, current_fields, values)
if row_data:
self._add_to_result(result, current_table, row_data)
# Validate we got at least some data
if not result.projects:
raise ParseError("No PROJECT data found in XER file")
return result
def _parse_row(self, table_name: str, fields: list[str], values: list[str]) -> dict | None:
"""Parse a single data row using the appropriate handler."""
handler_class = TABLE_HANDLERS.get(table_name)
if handler_class is None:
# Unknown table, skip
return None
handler = handler_class()
return handler.parse_row(fields, values)
def _add_to_result(self, result: ParsedXer, table_name: str, row_data: dict) -> None:
"""Add parsed row to the appropriate result list."""
if table_name == "PROJECT":
result.projects.append(row_data)
elif table_name == "TASK":
result.tasks.append(row_data)
elif table_name == "TASKPRED":
result.taskpreds.append(row_data)
elif table_name == "PROJWBS":
result.projwbs.append(row_data)
elif table_name == "CALENDAR":
result.calendars.append(row_data)

295
src/xer_mcp/server.py Normal file
View File

@@ -0,0 +1,295 @@
"""MCP Server for XER file analysis."""
from mcp.server import Server
from mcp.server.stdio import stdio_server
from mcp.types import TextContent, Tool
from xer_mcp.db import db
# Create MCP server instance
server = Server("xer-mcp")
# Server state
_file_loaded: bool = False
_current_project_id: str | None = None
def is_file_loaded() -> bool:
"""Check if an XER file has been loaded."""
return _file_loaded
def get_current_project_id() -> str | None:
"""Get the currently selected project ID."""
return _current_project_id
def set_file_loaded(loaded: bool, project_id: str | None = None) -> None:
"""Set the file loaded state."""
global _file_loaded, _current_project_id
_file_loaded = loaded
_current_project_id = project_id
@server.list_tools()
async def list_tools() -> list[Tool]:
"""List available MCP tools."""
return [
Tool(
name="load_xer",
description="Load a Primavera P6 XER file and parse its schedule data. "
"For multi-project files, specify project_id to select a project.",
inputSchema={
"type": "object",
"properties": {
"file_path": {
"type": "string",
"description": "Absolute path to the XER file",
},
"project_id": {
"type": "string",
"description": "Project ID to select (required for multi-project files)",
},
"db_path": {
"type": "string",
"description": "Path for persistent SQLite database file. "
"If omitted, uses in-memory database. "
"If empty string, auto-generates path from XER filename (same directory, .sqlite extension).",
},
},
"required": ["file_path"],
},
),
Tool(
name="list_activities",
description="List activities from the loaded XER file with optional filtering and pagination.",
inputSchema={
"type": "object",
"properties": {
"start_date": {
"type": "string",
"format": "date",
"description": "Filter activities starting on or after this date (YYYY-MM-DD)",
},
"end_date": {
"type": "string",
"format": "date",
"description": "Filter activities ending on or before this date (YYYY-MM-DD)",
},
"wbs_id": {
"type": "string",
"description": "Filter by WBS element ID",
},
"activity_type": {
"type": "string",
"enum": ["TT_Task", "TT_Mile", "TT_LOE", "TT_WBS", "TT_Rsrc"],
"description": "Filter by activity type",
},
"limit": {
"type": "integer",
"default": 100,
"minimum": 1,
"maximum": 1000,
"description": "Maximum number of activities to return",
},
"offset": {
"type": "integer",
"default": 0,
"minimum": 0,
"description": "Number of activities to skip",
},
},
},
),
Tool(
name="get_activity",
description="Get detailed information for a specific activity by ID.",
inputSchema={
"type": "object",
"properties": {
"activity_id": {
"type": "string",
"description": "The task_id of the activity",
},
},
"required": ["activity_id"],
},
),
Tool(
name="list_relationships",
description="List all activity relationships (dependencies) with pagination.",
inputSchema={
"type": "object",
"properties": {
"limit": {
"type": "integer",
"default": 100,
"minimum": 1,
"maximum": 1000,
"description": "Maximum number of relationships to return",
},
"offset": {
"type": "integer",
"default": 0,
"minimum": 0,
"description": "Number of relationships to skip",
},
},
},
),
Tool(
name="get_predecessors",
description="Get all predecessor activities for a given activity.",
inputSchema={
"type": "object",
"properties": {
"activity_id": {
"type": "string",
"description": "The task_id of the activity",
},
},
"required": ["activity_id"],
},
),
Tool(
name="get_successors",
description="Get all successor activities for a given activity.",
inputSchema={
"type": "object",
"properties": {
"activity_id": {
"type": "string",
"description": "The task_id of the activity",
},
},
"required": ["activity_id"],
},
),
Tool(
name="get_project_summary",
description="Get a summary of the loaded project including dates and activity counts.",
inputSchema={
"type": "object",
"properties": {},
},
),
Tool(
name="list_milestones",
description="List all milestone activities in the loaded project.",
inputSchema={
"type": "object",
"properties": {},
},
),
Tool(
name="get_critical_path",
description="Get all activities on the critical path that determine project duration.",
inputSchema={
"type": "object",
"properties": {},
},
),
Tool(
name="get_database_info",
description="Get information about the currently loaded database including file path and schema. "
"Use this to get connection details for direct SQL access.",
inputSchema={
"type": "object",
"properties": {},
},
),
]
@server.call_tool()
async def call_tool(name: str, arguments: dict) -> list[TextContent]:
"""Handle MCP tool calls."""
import json
if name == "load_xer":
from xer_mcp.tools.load_xer import load_xer
result = await load_xer(
file_path=arguments["file_path"],
project_id=arguments.get("project_id"),
db_path=arguments.get("db_path"),
)
return [TextContent(type="text", text=json.dumps(result, indent=2))]
if name == "list_activities":
from xer_mcp.tools.list_activities import list_activities
result = await list_activities(
start_date=arguments.get("start_date"),
end_date=arguments.get("end_date"),
wbs_id=arguments.get("wbs_id"),
activity_type=arguments.get("activity_type"),
limit=arguments.get("limit", 100),
offset=arguments.get("offset", 0),
)
return [TextContent(type="text", text=json.dumps(result, indent=2))]
if name == "get_activity":
from xer_mcp.tools.get_activity import get_activity
result = await get_activity(activity_id=arguments["activity_id"])
return [TextContent(type="text", text=json.dumps(result, indent=2))]
if name == "list_relationships":
from xer_mcp.tools.list_relationships import list_relationships
result = await list_relationships(
limit=arguments.get("limit", 100),
offset=arguments.get("offset", 0),
)
return [TextContent(type="text", text=json.dumps(result, indent=2))]
if name == "get_predecessors":
from xer_mcp.tools.get_predecessors import get_predecessors
result = await get_predecessors(activity_id=arguments["activity_id"])
return [TextContent(type="text", text=json.dumps(result, indent=2))]
if name == "get_successors":
from xer_mcp.tools.get_successors import get_successors
result = await get_successors(activity_id=arguments["activity_id"])
return [TextContent(type="text", text=json.dumps(result, indent=2))]
if name == "get_project_summary":
from xer_mcp.tools.get_project_summary import get_project_summary
result = await get_project_summary()
return [TextContent(type="text", text=json.dumps(result, indent=2))]
if name == "list_milestones":
from xer_mcp.tools.list_milestones import list_milestones
result = await list_milestones()
return [TextContent(type="text", text=json.dumps(result, indent=2))]
if name == "get_critical_path":
from xer_mcp.tools.get_critical_path import get_critical_path
result = await get_critical_path()
return [TextContent(type="text", text=json.dumps(result, indent=2))]
if name == "get_database_info":
from xer_mcp.tools.get_database_info import get_database_info
result = await get_database_info()
return [TextContent(type="text", text=json.dumps(result, indent=2))]
raise ValueError(f"Unknown tool: {name}")
async def run_server() -> None:
"""Run the MCP server with stdio transport."""
db.initialize()
async with stdio_server() as (read_stream, write_stream):
await server.run(
read_stream,
write_stream,
server.create_initialization_options(),
)

View File

@@ -0,0 +1 @@
"""MCP tools for XER file analysis."""

View File

@@ -0,0 +1,34 @@
"""get_activity MCP tool implementation."""
from xer_mcp.db.queries import get_activity_by_id
from xer_mcp.server import is_file_loaded
async def get_activity(activity_id: str) -> dict:
"""Get detailed information for a specific activity by ID.
Args:
activity_id: The task_id of the activity
Returns:
Dictionary with complete activity details or error
"""
if not is_file_loaded():
return {
"error": {
"code": "NO_FILE_LOADED",
"message": "No XER file is loaded. Use the load_xer tool first.",
}
}
activity = get_activity_by_id(activity_id)
if activity is None:
return {
"error": {
"code": "ACTIVITY_NOT_FOUND",
"message": f"Activity not found: {activity_id}",
}
}
return activity

View 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,
}

View File

@@ -0,0 +1,25 @@
"""get_database_info MCP tool implementation."""
from xer_mcp.db import db
async def get_database_info() -> dict:
"""Get information about the currently loaded database.
Returns connection details for direct SQL access including
database path, schema information, and metadata.
Returns:
Dictionary with database info or error if no database loaded
"""
if not db.is_initialized:
return {
"error": {
"code": "NO_FILE_LOADED",
"message": "No XER file is loaded. Use the load_xer tool first.",
}
}
return {
"database": db.get_database_info(),
}

View File

@@ -0,0 +1,29 @@
"""get_predecessors MCP tool implementation."""
from xer_mcp.db.queries import get_predecessors as query_predecessors
from xer_mcp.server import is_file_loaded
async def get_predecessors(activity_id: str) -> dict:
"""Get predecessor activities for a given activity.
Args:
activity_id: The task_id to find predecessors for
Returns:
Dictionary with activity_id and list of predecessor activities
"""
if not is_file_loaded():
return {
"error": {
"code": "NO_FILE_LOADED",
"message": "No XER file is loaded. Use the load_xer tool first.",
}
}
predecessors = query_predecessors(activity_id)
return {
"activity_id": activity_id,
"predecessors": predecessors,
}

View File

@@ -0,0 +1,45 @@
"""get_project_summary MCP tool implementation."""
from xer_mcp.db.queries import get_project_summary as query_project_summary
from xer_mcp.server import get_current_project_id, is_file_loaded
async def get_project_summary() -> dict:
"""Get a summary of the loaded project.
Returns:
Dictionary with project summary information including:
- project_name: Name of the project
- plan_start_date: Planned start date
- plan_end_date: Planned end date
- activity_count: Total number of activities
- milestone_count: Number of milestone activities
- critical_activity_count: Number of activities on critical path
"""
if not is_file_loaded():
return {
"error": {
"code": "NO_FILE_LOADED",
"message": "No XER file is loaded. Use the load_xer tool first.",
}
}
project_id = get_current_project_id()
if project_id is None:
return {
"error": {
"code": "NO_PROJECT_SELECTED",
"message": "No project is selected.",
}
}
summary = query_project_summary(project_id)
if summary is None:
return {
"error": {
"code": "PROJECT_NOT_FOUND",
"message": f"Project with ID {project_id} not found.",
}
}
return summary

View File

@@ -0,0 +1,29 @@
"""get_successors MCP tool implementation."""
from xer_mcp.db.queries import get_successors as query_successors
from xer_mcp.server import is_file_loaded
async def get_successors(activity_id: str) -> dict:
"""Get successor activities for a given activity.
Args:
activity_id: The task_id to find successors for
Returns:
Dictionary with activity_id and list of successor activities
"""
if not is_file_loaded():
return {
"error": {
"code": "NO_FILE_LOADED",
"message": "No XER file is loaded. Use the load_xer tool first.",
}
}
successors = query_successors(activity_id)
return {
"activity_id": activity_id,
"successors": successors,
}

View File

@@ -0,0 +1,55 @@
"""list_activities MCP tool implementation."""
from xer_mcp.db.queries import query_activities
from xer_mcp.server import is_file_loaded
async def list_activities(
start_date: str | None = None,
end_date: str | None = None,
wbs_id: str | None = None,
activity_type: str | None = None,
limit: int = 100,
offset: int = 0,
) -> dict:
"""List activities from the loaded XER file with optional filtering.
Args:
start_date: Filter activities starting on or after this date (YYYY-MM-DD)
end_date: Filter activities ending on or before this date (YYYY-MM-DD)
wbs_id: Filter by WBS element ID
activity_type: Filter by activity type (TT_Task, TT_Mile, etc.)
limit: Maximum number of activities to return (default 100)
offset: Number of activities to skip (default 0)
Returns:
Dictionary with activities list and pagination metadata
"""
if not is_file_loaded():
return {
"error": {
"code": "NO_FILE_LOADED",
"message": "No XER file is loaded. Use the load_xer tool first.",
}
}
activities, total_count = query_activities(
limit=limit,
offset=offset,
start_date=start_date,
end_date=end_date,
wbs_id=wbs_id,
activity_type=activity_type,
)
has_more = (offset + len(activities)) < total_count
return {
"activities": activities,
"pagination": {
"total_count": total_count,
"offset": offset,
"limit": limit,
"has_more": has_more,
},
}

View File

@@ -0,0 +1,34 @@
"""list_milestones MCP tool implementation."""
from xer_mcp.db.queries import query_milestones
from xer_mcp.server import is_file_loaded
async def list_milestones() -> dict:
"""List all milestone activities in the loaded project.
Returns both Start Milestones and Finish Milestones with their milestone_type.
Returns:
Dictionary with list of milestones, each containing:
- task_id: Activity ID
- task_code: Activity code
- task_name: Activity name
- target_start_date: Target start date
- target_end_date: Target end date
- status_code: Activity status
- milestone_type: 'start' for start milestones, 'finish' for finish milestones
"""
if not is_file_loaded():
return {
"error": {
"code": "NO_FILE_LOADED",
"message": "No XER file is loaded. Use the load_xer tool first.",
}
}
milestones = query_milestones()
return {
"milestones": milestones,
}

View File

@@ -0,0 +1,40 @@
"""list_relationships MCP tool implementation."""
from xer_mcp.db.queries import query_relationships
from xer_mcp.server import is_file_loaded
async def list_relationships(
limit: int = 100,
offset: int = 0,
) -> dict:
"""List all relationships (dependencies) with pagination.
Args:
limit: Maximum number of relationships to return (default 100)
offset: Number of relationships to skip (default 0)
Returns:
Dictionary with relationships list and pagination metadata
"""
if not is_file_loaded():
return {
"error": {
"code": "NO_FILE_LOADED",
"message": "No XER file is loaded. Use the load_xer tool first.",
}
}
relationships, total_count = query_relationships(limit=limit, offset=offset)
has_more = (offset + len(relationships)) < total_count
return {
"relationships": relationships,
"pagination": {
"total_count": total_count,
"offset": offset,
"limit": limit,
"has_more": has_more,
},
}

View File

@@ -0,0 +1,130 @@
"""load_xer MCP tool implementation."""
import errno
import os
import sqlite3
from xer_mcp.db import db
from xer_mcp.db.loader import get_activity_count, get_relationship_count, load_parsed_data
from xer_mcp.errors import FileNotFoundError, ParseError
from xer_mcp.parser.xer_parser import XerParser
from xer_mcp.server import set_file_loaded
async def load_xer(
file_path: str,
project_id: str | None = None,
db_path: str | None = None,
) -> dict:
"""Load a Primavera P6 XER file and parse its schedule data.
Args:
file_path: Absolute path to the XER file
project_id: Project ID to select (required for multi-project files)
db_path: Path for persistent database file. If None, uses in-memory.
If empty string, auto-generates from XER filename.
Returns:
Dictionary with success status and project info or error details
"""
# Initialize database with specified path
try:
db.initialize(db_path=db_path, source_file=file_path)
except PermissionError:
target = db_path if db_path else file_path
return {
"success": False,
"error": {"code": "FILE_NOT_WRITABLE", "message": f"Cannot write database: {target}"},
}
except OSError as e:
target = db_path if db_path else file_path
if e.errno == errno.ENOSPC:
return {
"success": False,
"error": {"code": "DISK_FULL", "message": f"Insufficient disk space: {target}"},
}
if e.errno == errno.ENOENT:
return {
"success": False,
"error": {
"code": "FILE_NOT_WRITABLE",
"message": f"Directory does not exist: {os.path.dirname(target)}",
},
}
return {
"success": False,
"error": {"code": "DATABASE_ERROR", "message": str(e)},
}
except sqlite3.Error as e:
return {
"success": False,
"error": {"code": "DATABASE_ERROR", "message": str(e)},
}
parser = XerParser()
try:
parsed = parser.parse(file_path)
except FileNotFoundError as e:
return {
"success": False,
"error": {"code": e.code, "message": e.message},
}
except ParseError as e:
return {
"success": False,
"error": {"code": e.code, "message": e.message},
}
# Handle multi-project files
if len(parsed.projects) > 1 and project_id is None:
available = [
{"proj_id": p["proj_id"], "proj_short_name": p["proj_short_name"]}
for p in parsed.projects
]
return {
"success": False,
"available_projects": available,
"message": "Multiple projects found. Please specify project_id.",
}
# Auto-select if single project
if project_id is None:
project_id = parsed.projects[0]["proj_id"]
# Find the selected project
project = next((p for p in parsed.projects if p["proj_id"] == project_id), None)
if project is None:
return {
"success": False,
"error": {
"code": "PROJECT_NOT_FOUND",
"message": f"Project {project_id} not found in file",
},
}
# Load data into database
load_parsed_data(parsed, project_id)
# Mark file as loaded
set_file_loaded(True, project_id)
# Get counts
activity_count = get_activity_count()
relationship_count = get_relationship_count()
# Get database info
database_info = db.get_database_info()
return {
"success": True,
"project": {
"proj_id": project["proj_id"],
"proj_short_name": project["proj_short_name"],
"plan_start_date": project["plan_start_date"],
"plan_end_date": project["plan_end_date"],
},
"activity_count": activity_count,
"relationship_count": relationship_count,
"database": database_info,
}

1
tests/__init__.py Normal file
View File

@@ -0,0 +1 @@
"""XER MCP Server tests."""

129
tests/conftest.py Normal file
View File

@@ -0,0 +1,129 @@
"""Pytest configuration and fixtures for XER MCP Server tests."""
from pathlib import Path
import pytest
# Sample XER content for testing - minimal but complete
SAMPLE_XER_SINGLE_PROJECT = """\
ERMHDR\t21.12\t2026-01-06\tProject\tADMIN\ttestuser\tdbTest\tProject Management\tUSD
%T\tPROJECT
%F\tproj_id\tfy_start_month_num\trsrc_self_add_flag\tallow_complete_flag\trsrc_multi_assign_flag\tcheckout_flag\tproject_flag\tstep_complete_flag\tcost_qty_recalc_flag\tbatch_sum_flag\tname_sep_char\tdef_complete_pct_type\tproj_short_name\tacct_id\torig_proj_id\tsource_proj_id\tbase_type_id\tclndr_id\tsum_base_proj_id\ttask_code_base\ttask_code_step\tpriority_num\twbs_max_sum_level\tstrgy_priority_num\tlast_checksum\tcritical_drtn_hr_cnt\tdef_cost_per_qty\tlast_recalc_date\tplan_start_date\tplan_end_date\tscd_end_date\tadd_date\tlast_tasksum_date\tfcst_start_date\tdef_duration_type\ttask_code_prefix\tguid\tdef_qty_type\tadd_by_name\tweb_local_root_path\tproj_url\tdef_rate_type\tadd_act_remain_flag\tact_this_per_link_flag\tdef_task_type\tact_pct_link_flag\tcritical_path_type\ttask_code_prefix_flag\tdef_rollup_dates_flag\tuse_project_baseline_flag\trem_target_link_flag\treset_planned_flag\tallow_neg_act_flag\tsum_assign_level\tlast_fin_dates_id\tfintmpl_id\tlast_baseline_update_date\tcr_external_key\tapply_actuals_date\tlocation_id\tloaded_scope_level\texport_flag\tnew_fin_dates_id\tbaselines_to_export\tbaseline_names_to_export\tnext_data_date\tclose_period_flag\tsum_refresh_date\ttrsrcsum_loaded\tsumtask_loaded
%R\t1001\t1\tY\tY\tY\tN\tY\tN\tN\tY\t.\tCP_Drtn\tTest Project\t\t\t\t\t1\t\t1000\t10\t10\t2\t500\t\t0\t0.0000\t2026-01-06 00:00\t2026-01-01 00:00\t2026-06-30 00:00\t2026-06-30 00:00\t2026-01-06 00:00\t\t\tDT_FixedDUR2\tA\ttest-guid-1\tQT_Hour\tADMIN\t\t\tCOST_PER_QTY\tN\tY\tTT_Task\tY\tCT_TotFloat\tY\tY\tY\tY\tN\tN\tSL_Taskrsrc\t\t1\t\t\t\t\t7\tY\t\t\t\t\t\t\t
%T\tCALENDAR
%F\tclndr_id\tdefault_flag\tclndr_name\tproj_id\tbase_clndr_id\tlast_chng_date\tclndr_type\tday_hr_cnt\tweek_hr_cnt\tmonth_hr_cnt\tyear_hr_cnt\trsrc_private\tclndr_data
%R\t1\tY\tStandard 5 Day\t\t\t2026-01-06 00:00\tCA_Base\t8\t40\t160\t2080\tN\t
%T\tPROJWBS
%F\twbs_id\tproj_id\tobs_id\tseq_num\test_wt\tproj_node_flag\tsum_data_flag\tstatus_code\twbs_short_name\twbs_name\tphase_id\tparent_wbs_id\tev_user_pct\tev_etc_user_value\torig_cost\tindep_remain_total_cost\tann_dscnt_rate_pct\tdscnt_period_type\tindep_remain_work_qty\tanticip_start_date\tanticip_end_date\tev_compute_type\tev_etc_compute_type\tguid\ttmpl_guid\tplan_open_state
%R\t100\t1001\t\t1\t1\tY\tN\tWS_Open\tROOT\tTest Project\t\t\t6\t0.88\t0.0000\t0.0000\t\t\t\t\t\tEC_Cmp_pct\tEE_Rem_hr\twbs-guid-1\t\t
%R\t101\t1001\t\t1\t1\tN\tN\tWS_Open\tPH1\tPhase 1\t\t100\t6\t0.88\t0.0000\t0.0000\t\t\t\t\t\tEC_Cmp_pct\tEE_Rem_hr\twbs-guid-2\t\t
%R\t102\t1001\t\t2\t1\tN\tN\tWS_Open\tPH2\tPhase 2\t\t100\t6\t0.88\t0.0000\t0.0000\t\t\t\t\t\tEC_Cmp_pct\tEE_Rem_hr\twbs-guid-3\t\t
%T\tTASK
%F\ttask_id\tproj_id\twbs_id\tclndr_id\tphys_complete_pct\trev_fdbk_flag\test_wt\tlock_plan_flag\tauto_compute_act_flag\tcomplete_pct_type\ttask_type\tduration_type\tstatus_code\ttask_code\ttask_name\trsrc_id\ttotal_float_hr_cnt\tfree_float_hr_cnt\tremain_drtn_hr_cnt\tact_work_qty\tremain_work_qty\ttarget_work_qty\ttarget_drtn_hr_cnt\ttarget_equip_qty\tact_equip_qty\tremain_equip_qty\tcstr_date\tact_start_date\tact_end_date\tlate_start_date\tlate_end_date\texpect_end_date\tearly_start_date\tearly_end_date\trestart_date\treend_date\ttarget_start_date\ttarget_end_date\trem_late_start_date\trem_late_end_date\tcstr_type\tpriority_type\tsuspend_date\tresume_date\tfloat_path\tfloat_path_order\tguid\ttmpl_guid\tcstr_date2\tcstr_type2\tdriving_path_flag\tact_this_per_work_qty\tact_this_per_equip_qty\texternal_early_start_date\texternal_late_end_date\tcreate_date\tupdate_date\tcreate_user\tupdate_user\tlocation_id\tcrt_path_num\tmilestone_type
%R\t2001\t1001\t101\t1\t0\tN\t1\tN\tN\tCP_Drtn\tTT_Mile\tDT_FixedDrtn\tTK_NotStart\tA1000\tProject Start\t\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t\t\t\t2026-01-01 07:00\t2026-01-01 07:00\t\t2026-01-01 07:00\t2026-01-01 07:00\t2026-01-01 07:00\t2026-01-01 07:00\t2026-01-01 07:00\t2026-01-01 07:00\t2026-01-01 07:00\t2026-01-01 07:00\t\tPT_Normal\t\t\t1\t1\ttask-guid-1\t\t\t\tY\t0\t0\t\t\t2026-01-06 00:00\t2026-01-06 00:00\tADMIN\tADMIN\t\t\tMS_Start
%R\t2002\t1001\t101\t1\t0\tN\t1\tN\tN\tCP_Drtn\tTT_Task\tDT_FixedDUR2\tTK_NotStart\tA1010\tSite Preparation\t\t0\t0\t40\t0\t0\t0\t40\t0\t0\t0\t\t\t\t2026-01-02 07:00\t2026-01-08 15:00\t\t2026-01-02 07:00\t2026-01-08 15:00\t2026-01-02 07:00\t2026-01-08 15:00\t2026-01-02 07:00\t2026-01-08 15:00\t2026-01-02 07:00\t2026-01-08 15:00\t\tPT_Normal\t\t\t1\t2\ttask-guid-2\t\t\t\tY\t0\t0\t\t\t2026-01-06 00:00\t2026-01-06 00:00\tADMIN\tADMIN\t\t\t
%R\t2003\t1001\t101\t1\t0\tN\t1\tN\tN\tCP_Drtn\tTT_Task\tDT_FixedDUR2\tTK_NotStart\tA1020\tFoundation Work\t\t80\t0\t80\t0\t0\t0\t80\t0\t0\t0\t\t\t\t2026-01-09 07:00\t2026-01-22 15:00\t\t2026-01-09 07:00\t2026-01-22 15:00\t2026-01-09 07:00\t2026-01-22 15:00\t2026-01-09 07:00\t2026-01-22 15:00\t2026-01-09 07:00\t2026-01-22 15:00\t\tPT_Normal\t\t\t1\t3\ttask-guid-3\t\t\t\tN\t0\t0\t\t\t2026-01-06 00:00\t2026-01-06 00:00\tADMIN\tADMIN\t\t\t
%R\t2004\t1001\t102\t1\t0\tN\t1\tN\tN\tCP_Drtn\tTT_Task\tDT_FixedDUR2\tTK_NotStart\tA1030\tStructural Work\t\t0\t0\t160\t0\t0\t0\t160\t0\t0\t0\t\t\t\t2026-01-23 07:00\t2026-02-19 15:00\t\t2026-01-23 07:00\t2026-02-19 15:00\t2026-01-23 07:00\t2026-02-19 15:00\t2026-01-23 07:00\t2026-02-19 15:00\t2026-01-23 07:00\t2026-02-19 15:00\t\tPT_Normal\t\t\t1\t4\ttask-guid-4\t\t\t\tY\t0\t0\t\t\t2026-01-06 00:00\t2026-01-06 00:00\tADMIN\tADMIN\t\t\t
%R\t2005\t1001\t102\t1\t0\tN\t1\tN\tN\tCP_Drtn\tTT_Mile\tDT_FixedDrtn\tTK_NotStart\tA1040\tProject Complete\t\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t\t\t\t2026-02-20 07:00\t2026-02-20 07:00\t\t2026-02-20 07:00\t2026-02-20 07:00\t2026-02-20 07:00\t2026-02-20 07:00\t2026-02-20 07:00\t2026-02-20 07:00\t2026-02-20 07:00\t2026-02-20 07:00\t\tPT_Normal\t\t\t1\t5\ttask-guid-5\t\t\t\tY\t0\t0\t\t\t2026-01-06 00:00\t2026-01-06 00:00\tADMIN\tADMIN\t\t\tMS_Finish
%T\tTASKPRED
%F\ttask_pred_id\ttask_id\tpred_task_id\tproj_id\tpred_proj_id\tpred_type\tlag_hr_cnt\tcomments\tfloat_path\taref\tarls
%R\t3001\t2002\t2001\t1001\t1001\tPR_FS\t0\t\t\t2026-01-01 07:00\t2026-01-02 07:00
%R\t3002\t2003\t2002\t1001\t1001\tPR_FS\t0\t\t\t2026-01-08 15:00\t2026-01-09 07:00
%R\t3003\t2004\t2003\t1001\t1001\tPR_FS\t0\t\t\t2026-01-22 15:00\t2026-01-23 07:00
%R\t3004\t2005\t2004\t1001\t1001\tPR_FS\t0\t\t\t2026-02-19 15:00\t2026-02-20 07:00
%R\t3005\t2004\t2002\t1001\t1001\tPR_SS\t40\t\t\t2026-01-02 07:00\t2026-01-08 07:00
%T\tEND
"""
SAMPLE_XER_MULTI_PROJECT = """\
ERMHDR\t21.12\t2026-01-06\tProject\tADMIN\ttestuser\tdbTest\tProject Management\tUSD
%T\tPROJECT
%F\tproj_id\tfy_start_month_num\trsrc_self_add_flag\tallow_complete_flag\trsrc_multi_assign_flag\tcheckout_flag\tproject_flag\tstep_complete_flag\tcost_qty_recalc_flag\tbatch_sum_flag\tname_sep_char\tdef_complete_pct_type\tproj_short_name\tacct_id\torig_proj_id\tsource_proj_id\tbase_type_id\tclndr_id\tsum_base_proj_id\ttask_code_base\ttask_code_step\tpriority_num\twbs_max_sum_level\tstrgy_priority_num\tlast_checksum\tcritical_drtn_hr_cnt\tdef_cost_per_qty\tlast_recalc_date\tplan_start_date\tplan_end_date\tscd_end_date\tadd_date\tlast_tasksum_date\tfcst_start_date\tdef_duration_type\ttask_code_prefix\tguid\tdef_qty_type\tadd_by_name\tweb_local_root_path\tproj_url\tdef_rate_type\tadd_act_remain_flag\tact_this_per_link_flag\tdef_task_type\tact_pct_link_flag\tcritical_path_type\ttask_code_prefix_flag\tdef_rollup_dates_flag\tuse_project_baseline_flag\trem_target_link_flag\treset_planned_flag\tallow_neg_act_flag\tsum_assign_level\tlast_fin_dates_id\tfintmpl_id\tlast_baseline_update_date\tcr_external_key\tapply_actuals_date\tlocation_id\tloaded_scope_level\texport_flag\tnew_fin_dates_id\tbaselines_to_export\tbaseline_names_to_export\tnext_data_date\tclose_period_flag\tsum_refresh_date\ttrsrcsum_loaded\tsumtask_loaded
%R\t1001\t1\tY\tY\tY\tN\tY\tN\tN\tY\t.\tCP_Drtn\tProject Alpha\t\t\t\t\t1\t\t1000\t10\t10\t2\t500\t\t0\t0.0000\t2026-01-06 00:00\t2026-01-01 00:00\t2026-03-31 00:00\t2026-03-31 00:00\t2026-01-06 00:00\t\t\tDT_FixedDUR2\tA\ttest-guid-1\tQT_Hour\tADMIN\t\t\tCOST_PER_QTY\tN\tY\tTT_Task\tY\tCT_TotFloat\tY\tY\tY\tY\tN\tN\tSL_Taskrsrc\t\t1\t\t\t\t\t7\tY\t\t\t\t\t\t\t
%R\t1002\t1\tY\tY\tY\tN\tY\tN\tN\tY\t.\tCP_Drtn\tProject Beta\t\t\t\t\t1\t\t1000\t10\t10\t2\t500\t\t0\t0.0000\t2026-01-06 00:00\t2026-04-01 00:00\t2026-06-30 00:00\t2026-06-30 00:00\t2026-01-06 00:00\t\t\tDT_FixedDUR2\tB\ttest-guid-2\tQT_Hour\tADMIN\t\t\tCOST_PER_QTY\tN\tY\tTT_Task\tY\tCT_TotFloat\tY\tY\tY\tY\tN\tN\tSL_Taskrsrc\t\t1\t\t\t\t\t7\tY\t\t\t\t\t\t\t
%T\tCALENDAR
%F\tclndr_id\tdefault_flag\tclndr_name\tproj_id\tbase_clndr_id\tlast_chng_date\tclndr_type\tday_hr_cnt\tweek_hr_cnt\tmonth_hr_cnt\tyear_hr_cnt\trsrc_private\tclndr_data
%R\t1\tY\tStandard 5 Day\t\t\t2026-01-06 00:00\tCA_Base\t8\t40\t160\t2080\tN\t
%T\tPROJWBS
%F\twbs_id\tproj_id\tobs_id\tseq_num\test_wt\tproj_node_flag\tsum_data_flag\tstatus_code\twbs_short_name\twbs_name\tphase_id\tparent_wbs_id\tev_user_pct\tev_etc_user_value\torig_cost\tindep_remain_total_cost\tann_dscnt_rate_pct\tdscnt_period_type\tindep_remain_work_qty\tanticip_start_date\tanticip_end_date\tev_compute_type\tev_etc_compute_type\tguid\ttmpl_guid\tplan_open_state
%R\t100\t1001\t\t1\t1\tY\tN\tWS_Open\tALPHA\tProject Alpha\t\t\t6\t0.88\t0.0000\t0.0000\t\t\t\t\t\tEC_Cmp_pct\tEE_Rem_hr\twbs-guid-1\t\t
%R\t200\t1002\t\t1\t1\tY\tN\tWS_Open\tBETA\tProject Beta\t\t\t6\t0.88\t0.0000\t0.0000\t\t\t\t\t\tEC_Cmp_pct\tEE_Rem_hr\twbs-guid-2\t\t
%T\tTASK
%F\ttask_id\tproj_id\twbs_id\tclndr_id\tphys_complete_pct\trev_fdbk_flag\test_wt\tlock_plan_flag\tauto_compute_act_flag\tcomplete_pct_type\ttask_type\tduration_type\tstatus_code\ttask_code\ttask_name\trsrc_id\ttotal_float_hr_cnt\tfree_float_hr_cnt\tremain_drtn_hr_cnt\tact_work_qty\tremain_work_qty\ttarget_work_qty\ttarget_drtn_hr_cnt\ttarget_equip_qty\tact_equip_qty\tremain_equip_qty\tcstr_date\tact_start_date\tact_end_date\tlate_start_date\tlate_end_date\texpect_end_date\tearly_start_date\tearly_end_date\trestart_date\treend_date\ttarget_start_date\ttarget_end_date\trem_late_start_date\trem_late_end_date\tcstr_type\tpriority_type\tsuspend_date\tresume_date\tfloat_path\tfloat_path_order\tguid\ttmpl_guid\tcstr_date2\tcstr_type2\tdriving_path_flag\tact_this_per_work_qty\tact_this_per_equip_qty\texternal_early_start_date\texternal_late_end_date\tcreate_date\tupdate_date\tcreate_user\tupdate_user\tlocation_id\tcrt_path_num
%R\t2001\t1001\t100\t1\t0\tN\t1\tN\tN\tCP_Drtn\tTT_Task\tDT_FixedDUR2\tTK_NotStart\tA1000\tAlpha Task 1\t\t0\t0\t40\t0\t0\t0\t40\t0\t0\t0\t\t\t\t2026-01-01 07:00\t2026-01-08 15:00\t\t2026-01-01 07:00\t2026-01-08 15:00\t2026-01-01 07:00\t2026-01-08 15:00\t2026-01-01 07:00\t2026-01-08 15:00\t2026-01-01 07:00\t2026-01-08 15:00\t\tPT_Normal\t\t\t\t\ttask-guid-1\t\t\t\tY\t0\t0\t\t\t2026-01-06 00:00\t2026-01-06 00:00\tADMIN\tADMIN\t\t
%R\t2002\t1002\t200\t1\t0\tN\t1\tN\tN\tCP_Drtn\tTT_Task\tDT_FixedDUR2\tTK_NotStart\tB1000\tBeta Task 1\t\t0\t0\t40\t0\t0\t0\t40\t0\t0\t0\t\t\t\t2026-04-01 07:00\t2026-04-08 15:00\t\t2026-04-01 07:00\t2026-04-08 15:00\t2026-04-01 07:00\t2026-04-08 15:00\t2026-04-01 07:00\t2026-04-08 15:00\t2026-04-01 07:00\t2026-04-08 15:00\t\tPT_Normal\t\t\t\t\ttask-guid-2\t\t\t\tY\t0\t0\t\t\t2026-01-06 00:00\t2026-01-06 00:00\tADMIN\tADMIN\t\t
%T\tTASKPRED
%F\ttask_pred_id\ttask_id\tpred_task_id\tproj_id\tpred_proj_id\tpred_type\tlag_hr_cnt\tcomments\tfloat_path\taref\tarls
%T\tEND
"""
SAMPLE_XER_EMPTY = """\
ERMHDR\t21.12\t2026-01-06\tProject\tADMIN\ttestuser\tdbTest\tProject Management\tUSD
%T\tPROJECT
%F\tproj_id\tfy_start_month_num\trsrc_self_add_flag\tallow_complete_flag\trsrc_multi_assign_flag\tcheckout_flag\tproject_flag\tstep_complete_flag\tcost_qty_recalc_flag\tbatch_sum_flag\tname_sep_char\tdef_complete_pct_type\tproj_short_name\tacct_id\torig_proj_id\tsource_proj_id\tbase_type_id\tclndr_id\tsum_base_proj_id\ttask_code_base\ttask_code_step\tpriority_num\twbs_max_sum_level\tstrgy_priority_num\tlast_checksum\tcritical_drtn_hr_cnt\tdef_cost_per_qty\tlast_recalc_date\tplan_start_date\tplan_end_date\tscd_end_date\tadd_date\tlast_tasksum_date\tfcst_start_date\tdef_duration_type\ttask_code_prefix\tguid\tdef_qty_type\tadd_by_name\tweb_local_root_path\tproj_url\tdef_rate_type\tadd_act_remain_flag\tact_this_per_link_flag\tdef_task_type\tact_pct_link_flag\tcritical_path_type\ttask_code_prefix_flag\tdef_rollup_dates_flag\tuse_project_baseline_flag\trem_target_link_flag\treset_planned_flag\tallow_neg_act_flag\tsum_assign_level\tlast_fin_dates_id\tfintmpl_id\tlast_baseline_update_date\tcr_external_key\tapply_actuals_date\tlocation_id\tloaded_scope_level\texport_flag\tnew_fin_dates_id\tbaselines_to_export\tbaseline_names_to_export\tnext_data_date\tclose_period_flag\tsum_refresh_date\ttrsrcsum_loaded\tsumtask_loaded
%R\t1001\t1\tY\tY\tY\tN\tY\tN\tN\tY\t.\tCP_Drtn\tEmpty Project\t\t\t\t\t1\t\t1000\t10\t10\t2\t500\t\t0\t0.0000\t2026-01-06 00:00\t2026-01-01 00:00\t2026-06-30 00:00\t2026-06-30 00:00\t2026-01-06 00:00\t\t\tDT_FixedDUR2\tA\ttest-guid-1\tQT_Hour\tADMIN\t\t\tCOST_PER_QTY\tN\tY\tTT_Task\tY\tCT_TotFloat\tY\tY\tY\tY\tN\tN\tSL_Taskrsrc\t\t1\t\t\t\t\t7\tY\t\t\t\t\t\t\t
%T\tCALENDAR
%F\tclndr_id\tdefault_flag\tclndr_name\tproj_id\tbase_clndr_id\tlast_chng_date\tclndr_type\tday_hr_cnt\tweek_hr_cnt\tmonth_hr_cnt\tyear_hr_cnt\trsrc_private\tclndr_data
%R\t1\tY\tStandard 5 Day\t\t\t2026-01-06 00:00\tCA_Base\t8\t40\t160\t2080\tN\t
%T\tPROJWBS
%F\twbs_id\tproj_id\tobs_id\tseq_num\test_wt\tproj_node_flag\tsum_data_flag\tstatus_code\twbs_short_name\twbs_name\tphase_id\tparent_wbs_id\tev_user_pct\tev_etc_user_value\torig_cost\tindep_remain_total_cost\tann_dscnt_rate_pct\tdscnt_period_type\tindep_remain_work_qty\tanticip_start_date\tanticip_end_date\tev_compute_type\tev_etc_compute_type\tguid\ttmpl_guid\tplan_open_state
%R\t100\t1001\t\t1\t1\tY\tN\tWS_Open\tROOT\tEmpty Project\t\t\t6\t0.88\t0.0000\t0.0000\t\t\t\t\t\tEC_Cmp_pct\tEE_Rem_hr\twbs-guid-1\t\t
%T\tTASK
%F\ttask_id\tproj_id\twbs_id\tclndr_id\tphys_complete_pct\trev_fdbk_flag\test_wt\tlock_plan_flag\tauto_compute_act_flag\tcomplete_pct_type\ttask_type\tduration_type\tstatus_code\ttask_code\ttask_name\trsrc_id\ttotal_float_hr_cnt\tfree_float_hr_cnt\tremain_drtn_hr_cnt\tact_work_qty\tremain_work_qty\ttarget_work_qty\ttarget_drtn_hr_cnt\ttarget_equip_qty\tact_equip_qty\tremain_equip_qty\tcstr_date\tact_start_date\tact_end_date\tlate_start_date\tlate_end_date\texpect_end_date\tearly_start_date\tearly_end_date\trestart_date\treend_date\ttarget_start_date\ttarget_end_date\trem_late_start_date\trem_late_end_date\tcstr_type\tpriority_type\tsuspend_date\tresume_date\tfloat_path\tfloat_path_order\tguid\ttmpl_guid\tcstr_date2\tcstr_type2\tdriving_path_flag\tact_this_per_work_qty\tact_this_per_equip_qty\texternal_early_start_date\texternal_late_end_date\tcreate_date\tupdate_date\tcreate_user\tupdate_user\tlocation_id\tcrt_path_num
%T\tTASKPRED
%F\ttask_pred_id\ttask_id\tpred_task_id\tproj_id\tpred_proj_id\tpred_type\tlag_hr_cnt\tcomments\tfloat_path\taref\tarls
%T\tEND
"""
@pytest.fixture
def sample_xer_single_project(tmp_path: Path) -> Path:
"""Create a temporary XER file with a single project."""
xer_file = tmp_path / "single_project.xer"
xer_file.write_text(SAMPLE_XER_SINGLE_PROJECT)
return xer_file
@pytest.fixture
def sample_xer_multi_project(tmp_path: Path) -> Path:
"""Create a temporary XER file with multiple projects."""
xer_file = tmp_path / "multi_project.xer"
xer_file.write_text(SAMPLE_XER_MULTI_PROJECT)
return xer_file
@pytest.fixture
def sample_xer_empty(tmp_path: Path) -> Path:
"""Create a temporary XER file with no activities."""
xer_file = tmp_path / "empty_project.xer"
xer_file.write_text(SAMPLE_XER_EMPTY)
return xer_file
@pytest.fixture
def nonexistent_xer_path(tmp_path: Path) -> Path:
"""Return a path to a non-existent XER file."""
return tmp_path / "does_not_exist.xer"
@pytest.fixture
def invalid_xer_file(tmp_path: Path) -> Path:
"""Create a temporary file with invalid XER content."""
xer_file = tmp_path / "invalid.xer"
xer_file.write_text("This is not a valid XER file\nJust some random text")
return xer_file
@pytest.fixture
def real_xer_file() -> Path | None:
"""Return the path to the real XER file if it exists.
This fixture provides access to the actual XER file in the repository
for integration testing with real data.
"""
real_file = Path(
"/home/bill/xer-mcp/S48019R - Proposal Schedule - E-J Electric Installation.xer"
)
if real_file.exists():
return real_file
return None

View File

@@ -0,0 +1 @@
"""Contract tests for MCP tool interfaces."""

View File

@@ -0,0 +1,89 @@
"""Contract tests for get_activity MCP tool."""
from pathlib import Path
import pytest
from xer_mcp.db import db
@pytest.fixture(autouse=True)
def setup_db():
"""Initialize and clear database for each test."""
db.initialize()
yield
db.clear()
class TestGetActivityContract:
"""Contract tests verifying get_activity tool interface matches spec."""
async def test_get_activity_returns_details(self, sample_xer_single_project: Path) -> None:
"""get_activity returns complete activity details."""
from xer_mcp.tools.get_activity import get_activity
from xer_mcp.tools.load_xer import load_xer
await load_xer(file_path=str(sample_xer_single_project))
result = await get_activity(activity_id="2002")
assert result["task_id"] == "2002"
assert result["task_code"] == "A1010"
assert result["task_name"] == "Site Preparation"
assert result["task_type"] == "TT_Task"
assert "target_start_date" in result
assert "target_end_date" in result
assert "wbs_id" in result
assert "predecessor_count" in result
assert "successor_count" in result
async def test_get_activity_includes_wbs_name(self, sample_xer_single_project: Path) -> None:
"""get_activity includes WBS name from lookup."""
from xer_mcp.tools.get_activity import get_activity
from xer_mcp.tools.load_xer import load_xer
await load_xer(file_path=str(sample_xer_single_project))
result = await get_activity(activity_id="2002")
assert "wbs_name" in result
async def test_get_activity_includes_relationship_counts(
self, sample_xer_single_project: Path
) -> None:
"""get_activity includes predecessor and successor counts."""
from xer_mcp.tools.get_activity import get_activity
from xer_mcp.tools.load_xer import load_xer
await load_xer(file_path=str(sample_xer_single_project))
# A1010 (2002) has 1 predecessor (A1000) and 2 successors (A1020, A1030)
result = await get_activity(activity_id="2002")
assert result["predecessor_count"] == 1
assert result["successor_count"] == 2
async def test_get_activity_not_found_returns_error(
self, sample_xer_single_project: Path
) -> None:
"""get_activity with invalid ID returns ACTIVITY_NOT_FOUND error."""
from xer_mcp.tools.get_activity import get_activity
from xer_mcp.tools.load_xer import load_xer
await load_xer(file_path=str(sample_xer_single_project))
result = await get_activity(activity_id="nonexistent")
assert "error" in result
assert result["error"]["code"] == "ACTIVITY_NOT_FOUND"
async def test_get_activity_no_file_loaded_returns_error(self) -> None:
"""get_activity without loaded file returns NO_FILE_LOADED error."""
from xer_mcp.server import set_file_loaded
from xer_mcp.tools.get_activity import get_activity
set_file_loaded(False)
result = await get_activity(activity_id="2002")
assert "error" in result
assert result["error"]["code"] == "NO_FILE_LOADED"

View File

@@ -0,0 +1,91 @@
"""Contract tests for get_critical_path MCP tool."""
from pathlib import Path
import pytest
from xer_mcp.db import db
@pytest.fixture(autouse=True)
def setup_db():
"""Initialize and clear database for each test."""
db.initialize()
yield
db.clear()
class TestGetCriticalPathContract:
"""Contract tests verifying get_critical_path tool interface."""
async def test_get_critical_path_returns_critical_activities(
self, sample_xer_single_project: Path
) -> None:
"""get_critical_path returns activities with driving_path_flag set."""
from xer_mcp.tools.get_critical_path import get_critical_path
from xer_mcp.tools.load_xer import load_xer
await load_xer(file_path=str(sample_xer_single_project))
result = await get_critical_path()
assert "critical_activities" in result
assert len(result["critical_activities"]) == 4
async def test_get_critical_path_includes_expected_fields(
self, sample_xer_single_project: Path
) -> None:
"""get_critical_path returns activities with required fields."""
from xer_mcp.tools.get_critical_path import get_critical_path
from xer_mcp.tools.load_xer import load_xer
await load_xer(file_path=str(sample_xer_single_project))
result = await get_critical_path()
activity = result["critical_activities"][0]
assert "task_id" in activity
assert "task_code" in activity
assert "task_name" in activity
assert "target_start_date" in activity
assert "target_end_date" in activity
assert "total_float_hr_cnt" in activity
async def test_get_critical_path_ordered_by_date(self, sample_xer_single_project: Path) -> None:
"""get_critical_path returns activities ordered by start date."""
from xer_mcp.tools.get_critical_path import get_critical_path
from xer_mcp.tools.load_xer import load_xer
await load_xer(file_path=str(sample_xer_single_project))
result = await get_critical_path()
activities = result["critical_activities"]
for i in range(len(activities) - 1):
assert activities[i]["target_start_date"] <= activities[i + 1]["target_start_date"]
async def test_get_critical_path_excludes_non_critical(
self, sample_xer_single_project: Path
) -> None:
"""get_critical_path excludes activities not on critical path."""
from xer_mcp.tools.get_critical_path import get_critical_path
from xer_mcp.tools.load_xer import load_xer
await load_xer(file_path=str(sample_xer_single_project))
result = await get_critical_path()
# A1020 "Foundation Work" has driving_path_flag = N
activity_names = [a["task_name"] for a in result["critical_activities"]]
assert "Foundation Work" not in activity_names
async def test_get_critical_path_no_file_loaded_returns_error(self) -> None:
"""get_critical_path without loaded file returns NO_FILE_LOADED error."""
from xer_mcp.server import set_file_loaded
from xer_mcp.tools.get_critical_path import get_critical_path
set_file_loaded(False)
result = await get_critical_path()
assert "error" in result
assert result["error"]["code"] == "NO_FILE_LOADED"

View File

@@ -0,0 +1,143 @@
"""Contract tests for get_database_info MCP tool."""
from pathlib import Path
import pytest
from xer_mcp.db import db
@pytest.fixture(autouse=True)
def setup_db():
"""Reset database state for each test."""
if db.is_initialized:
db.close()
yield
if db.is_initialized:
db.close()
class TestGetDatabaseInfoContract:
"""Contract tests verifying get_database_info tool interface."""
async def test_get_database_info_returns_current_database(
self, tmp_path: Path, sample_xer_single_project: Path
) -> None:
"""get_database_info returns info about currently loaded database."""
from xer_mcp.tools.get_database_info import get_database_info
from xer_mcp.tools.load_xer import load_xer
db_file = tmp_path / "schedule.db"
await load_xer(
file_path=str(sample_xer_single_project),
db_path=str(db_file),
)
result = await get_database_info()
assert "database" in result
assert result["database"]["db_path"] == str(db_file)
assert result["database"]["is_persistent"] is True
async def test_get_database_info_error_when_no_database(self) -> None:
"""get_database_info returns error when no database loaded."""
from xer_mcp.tools.get_database_info import get_database_info
# Ensure database is not initialized
if db.is_initialized:
db.close()
result = await get_database_info()
assert "error" in result
assert result["error"]["code"] == "NO_FILE_LOADED"
async def test_get_database_info_includes_schema(
self, tmp_path: Path, sample_xer_single_project: Path
) -> None:
"""get_database_info includes schema information."""
from xer_mcp.tools.get_database_info import get_database_info
from xer_mcp.tools.load_xer import load_xer
db_file = tmp_path / "schedule.db"
await load_xer(
file_path=str(sample_xer_single_project),
db_path=str(db_file),
)
result = await get_database_info()
assert "schema" in result["database"]
assert "tables" in result["database"]["schema"]
async def test_get_database_info_includes_loaded_at(
self, tmp_path: Path, sample_xer_single_project: Path
) -> None:
"""get_database_info includes loaded_at timestamp."""
from xer_mcp.tools.get_database_info import get_database_info
from xer_mcp.tools.load_xer import load_xer
db_file = tmp_path / "schedule.db"
await load_xer(
file_path=str(sample_xer_single_project),
db_path=str(db_file),
)
result = await get_database_info()
assert "loaded_at" in result["database"]
# Should be ISO format timestamp
assert "T" in result["database"]["loaded_at"]
async def test_get_database_info_includes_source_file(
self, tmp_path: Path, sample_xer_single_project: Path
) -> None:
"""get_database_info includes source XER file path."""
from xer_mcp.tools.get_database_info import get_database_info
from xer_mcp.tools.load_xer import load_xer
db_file = tmp_path / "schedule.db"
await load_xer(
file_path=str(sample_xer_single_project),
db_path=str(db_file),
)
result = await get_database_info()
assert result["database"]["source_file"] == str(sample_xer_single_project)
async def test_get_database_info_for_memory_database(
self, sample_xer_single_project: Path
) -> None:
"""get_database_info works for in-memory database."""
from xer_mcp.tools.get_database_info import get_database_info
from xer_mcp.tools.load_xer import load_xer
await load_xer(file_path=str(sample_xer_single_project))
result = await get_database_info()
assert "database" in result
assert result["database"]["db_path"] == ":memory:"
assert result["database"]["is_persistent"] is False
class TestGetDatabaseInfoToolSchema:
"""Tests for MCP tool schema."""
async def test_get_database_info_tool_registered(self) -> None:
"""get_database_info tool is registered with MCP server."""
from xer_mcp.server import list_tools
tools = await list_tools()
tool_names = [t.name for t in tools]
assert "get_database_info" in tool_names
async def test_get_database_info_tool_has_empty_input_schema(self) -> None:
"""get_database_info tool has no required inputs."""
from xer_mcp.server import list_tools
tools = await list_tools()
tool = next(t for t in tools if t.name == "get_database_info")
# Should have empty or no required properties
assert "required" not in tool.inputSchema or len(tool.inputSchema.get("required", [])) == 0

View File

@@ -0,0 +1,96 @@
"""Contract tests for get_predecessors MCP tool."""
from pathlib import Path
import pytest
from xer_mcp.db import db
@pytest.fixture(autouse=True)
def setup_db():
"""Initialize and clear database for each test."""
db.initialize()
yield
db.clear()
class TestGetPredecessorsContract:
"""Contract tests verifying get_predecessors tool interface."""
async def test_get_predecessors_returns_list(self, sample_xer_single_project: Path) -> None:
"""get_predecessors returns predecessor activities."""
from xer_mcp.tools.get_predecessors import get_predecessors
from xer_mcp.tools.load_xer import load_xer
await load_xer(file_path=str(sample_xer_single_project))
# A1010 (2002) has one predecessor: A1000 (2001)
result = await get_predecessors(activity_id="2002")
assert "activity_id" in result
assert result["activity_id"] == "2002"
assert "predecessors" in result
assert len(result["predecessors"]) == 1
assert result["predecessors"][0]["task_id"] == "2001"
async def test_get_predecessors_includes_relationship_details(
self, sample_xer_single_project: Path
) -> None:
"""get_predecessors includes relationship type and lag."""
from xer_mcp.tools.get_predecessors import get_predecessors
from xer_mcp.tools.load_xer import load_xer
await load_xer(file_path=str(sample_xer_single_project))
result = await get_predecessors(activity_id="2002")
pred = result["predecessors"][0]
assert "relationship_type" in pred
assert "lag_hr_cnt" in pred
assert pred["relationship_type"] in ["FS", "SS", "FF", "SF"]
async def test_get_predecessors_empty_list_for_no_predecessors(
self, sample_xer_single_project: Path
) -> None:
"""get_predecessors returns empty list when no predecessors exist."""
from xer_mcp.tools.get_predecessors import get_predecessors
from xer_mcp.tools.load_xer import load_xer
await load_xer(file_path=str(sample_xer_single_project))
# A1000 (2001) has no predecessors
result = await get_predecessors(activity_id="2001")
assert "predecessors" in result
assert len(result["predecessors"]) == 0
async def test_get_predecessors_no_file_loaded_returns_error(self) -> None:
"""get_predecessors without loaded file returns NO_FILE_LOADED error."""
from xer_mcp.server import set_file_loaded
from xer_mcp.tools.get_predecessors import get_predecessors
set_file_loaded(False)
result = await get_predecessors(activity_id="2002")
assert "error" in result
assert result["error"]["code"] == "NO_FILE_LOADED"
async def test_get_predecessors_includes_driving_flag(
self, sample_xer_single_project: Path
) -> None:
"""get_predecessors includes driving flag for each predecessor."""
from xer_mcp.tools.get_predecessors import get_predecessors
from xer_mcp.tools.load_xer import load_xer
await load_xer(file_path=str(sample_xer_single_project))
# A1010 (2002) has one predecessor: A1000 (2001)
result = await get_predecessors(activity_id="2002")
assert "predecessors" in result
assert len(result["predecessors"]) >= 1
# All predecessors should have a driving flag
for pred in result["predecessors"]:
assert "driving" in pred
assert isinstance(pred["driving"], bool)

View File

@@ -0,0 +1,89 @@
"""Contract tests for get_project_summary MCP tool."""
from pathlib import Path
import pytest
from xer_mcp.db import db
@pytest.fixture(autouse=True)
def setup_db():
"""Initialize and clear database for each test."""
db.initialize()
yield
db.clear()
class TestGetProjectSummaryContract:
"""Contract tests verifying get_project_summary tool interface."""
async def test_get_project_summary_returns_basic_info(
self, sample_xer_single_project: Path
) -> None:
"""get_project_summary returns project name, dates, and activity count."""
from xer_mcp.tools.get_project_summary import get_project_summary
from xer_mcp.tools.load_xer import load_xer
await load_xer(file_path=str(sample_xer_single_project))
result = await get_project_summary()
assert "project_name" in result
assert "data_date" in result
assert "plan_start_date" in result
assert "plan_end_date" in result
assert "activity_count" in result
async def test_get_project_summary_returns_correct_values(
self, sample_xer_single_project: Path
) -> None:
"""get_project_summary returns correct project values from loaded XER."""
from xer_mcp.tools.get_project_summary import get_project_summary
from xer_mcp.tools.load_xer import load_xer
await load_xer(file_path=str(sample_xer_single_project))
result = await get_project_summary()
assert result["project_name"] == "Test Project"
assert result["activity_count"] == 5
async def test_get_project_summary_includes_milestone_count(
self, sample_xer_single_project: Path
) -> None:
"""get_project_summary includes count of milestones."""
from xer_mcp.tools.get_project_summary import get_project_summary
from xer_mcp.tools.load_xer import load_xer
await load_xer(file_path=str(sample_xer_single_project))
result = await get_project_summary()
assert "milestone_count" in result
assert result["milestone_count"] == 2
async def test_get_project_summary_includes_critical_count(
self, sample_xer_single_project: Path
) -> None:
"""get_project_summary includes count of critical path activities."""
from xer_mcp.tools.get_project_summary import get_project_summary
from xer_mcp.tools.load_xer import load_xer
await load_xer(file_path=str(sample_xer_single_project))
result = await get_project_summary()
assert "critical_activity_count" in result
assert result["critical_activity_count"] == 4
async def test_get_project_summary_no_file_loaded_returns_error(self) -> None:
"""get_project_summary without loaded file returns NO_FILE_LOADED error."""
from xer_mcp.server import set_file_loaded
from xer_mcp.tools.get_project_summary import get_project_summary
set_file_loaded(False)
result = await get_project_summary()
assert "error" in result
assert result["error"]["code"] == "NO_FILE_LOADED"

View File

@@ -0,0 +1,95 @@
"""Contract tests for get_successors MCP tool."""
from pathlib import Path
import pytest
from xer_mcp.db import db
@pytest.fixture(autouse=True)
def setup_db():
"""Initialize and clear database for each test."""
db.initialize()
yield
db.clear()
class TestGetSuccessorsContract:
"""Contract tests verifying get_successors tool interface."""
async def test_get_successors_returns_list(self, sample_xer_single_project: Path) -> None:
"""get_successors returns successor activities."""
from xer_mcp.tools.get_successors import get_successors
from xer_mcp.tools.load_xer import load_xer
await load_xer(file_path=str(sample_xer_single_project))
# A1010 (2002) has two successors: A1020 (2003) and A1030 (2004)
result = await get_successors(activity_id="2002")
assert "activity_id" in result
assert result["activity_id"] == "2002"
assert "successors" in result
assert len(result["successors"]) == 2
async def test_get_successors_includes_relationship_details(
self, sample_xer_single_project: Path
) -> None:
"""get_successors includes relationship type and lag."""
from xer_mcp.tools.get_successors import get_successors
from xer_mcp.tools.load_xer import load_xer
await load_xer(file_path=str(sample_xer_single_project))
result = await get_successors(activity_id="2001")
succ = result["successors"][0]
assert "relationship_type" in succ
assert "lag_hr_cnt" in succ
assert succ["relationship_type"] in ["FS", "SS", "FF", "SF"]
async def test_get_successors_empty_list_for_no_successors(
self, sample_xer_single_project: Path
) -> None:
"""get_successors returns empty list when no successors exist."""
from xer_mcp.tools.get_successors import get_successors
from xer_mcp.tools.load_xer import load_xer
await load_xer(file_path=str(sample_xer_single_project))
# A1040 (2005) has no successors
result = await get_successors(activity_id="2005")
assert "successors" in result
assert len(result["successors"]) == 0
async def test_get_successors_no_file_loaded_returns_error(self) -> None:
"""get_successors without loaded file returns NO_FILE_LOADED error."""
from xer_mcp.server import set_file_loaded
from xer_mcp.tools.get_successors import get_successors
set_file_loaded(False)
result = await get_successors(activity_id="2002")
assert "error" in result
assert result["error"]["code"] == "NO_FILE_LOADED"
async def test_get_successors_includes_driving_flag(
self, sample_xer_single_project: Path
) -> None:
"""get_successors includes driving flag for each successor."""
from xer_mcp.tools.get_successors import get_successors
from xer_mcp.tools.load_xer import load_xer
await load_xer(file_path=str(sample_xer_single_project))
# A1000 (2001) has one successor: A1010 (2002)
result = await get_successors(activity_id="2001")
assert "successors" in result
assert len(result["successors"]) >= 1
# All successors should have a driving flag
for succ in result["successors"]:
assert "driving" in succ
assert isinstance(succ["driving"], bool)

View File

@@ -0,0 +1,138 @@
"""Contract tests for list_activities MCP tool."""
from pathlib import Path
import pytest
from xer_mcp.db import db
@pytest.fixture(autouse=True)
def setup_db():
"""Initialize and clear database for each test."""
db.initialize()
yield
db.clear()
class TestListActivitiesContract:
"""Contract tests verifying list_activities tool interface matches spec."""
async def test_list_activities_returns_paginated_results(
self, sample_xer_single_project: Path
) -> None:
"""list_activities returns activities with pagination metadata."""
from xer_mcp.tools.list_activities import list_activities
from xer_mcp.tools.load_xer import load_xer
await load_xer(file_path=str(sample_xer_single_project))
result = await list_activities()
assert "activities" in result
assert "pagination" in result
assert len(result["activities"]) == 5
assert result["pagination"]["total_count"] == 5
assert result["pagination"]["offset"] == 0
assert result["pagination"]["limit"] == 100
assert result["pagination"]["has_more"] is False
async def test_list_activities_with_limit(self, sample_xer_single_project: Path) -> None:
"""list_activities respects limit parameter."""
from xer_mcp.tools.list_activities import list_activities
from xer_mcp.tools.load_xer import load_xer
await load_xer(file_path=str(sample_xer_single_project))
result = await list_activities(limit=2)
assert len(result["activities"]) == 2
assert result["pagination"]["limit"] == 2
assert result["pagination"]["has_more"] is True
async def test_list_activities_with_offset(self, sample_xer_single_project: Path) -> None:
"""list_activities respects offset parameter."""
from xer_mcp.tools.list_activities import list_activities
from xer_mcp.tools.load_xer import load_xer
await load_xer(file_path=str(sample_xer_single_project))
result = await list_activities(offset=2, limit=2)
assert len(result["activities"]) == 2
assert result["pagination"]["offset"] == 2
async def test_list_activities_filter_by_date_range(
self, sample_xer_single_project: Path
) -> None:
"""list_activities filters by date range."""
from xer_mcp.tools.list_activities import list_activities
from xer_mcp.tools.load_xer import load_xer
await load_xer(file_path=str(sample_xer_single_project))
# Filter to January only
result = await list_activities(start_date="2026-01-01", end_date="2026-01-31")
# Should include activities in January
for activity in result["activities"]:
assert "2026-01" in activity["target_start_date"]
async def test_list_activities_filter_by_activity_type(
self, sample_xer_single_project: Path
) -> None:
"""list_activities filters by activity type."""
from xer_mcp.tools.list_activities import list_activities
from xer_mcp.tools.load_xer import load_xer
await load_xer(file_path=str(sample_xer_single_project))
result = await list_activities(activity_type="TT_Mile")
assert len(result["activities"]) == 2
for activity in result["activities"]:
assert activity["task_type"] == "TT_Mile"
async def test_list_activities_filter_by_wbs(self, sample_xer_single_project: Path) -> None:
"""list_activities filters by WBS ID."""
from xer_mcp.tools.list_activities import list_activities
from xer_mcp.tools.load_xer import load_xer
await load_xer(file_path=str(sample_xer_single_project))
result = await list_activities(wbs_id="101")
# WBS 101 has 3 activities in the fixture
assert len(result["activities"]) == 3
async def test_list_activities_no_file_loaded_returns_error(self) -> None:
"""list_activities without loaded file returns NO_FILE_LOADED error."""
from xer_mcp.server import set_file_loaded
from xer_mcp.tools.list_activities import list_activities
set_file_loaded(False)
result = await list_activities()
assert "error" in result
assert result["error"]["code"] == "NO_FILE_LOADED"
async def test_list_activities_returns_expected_fields(
self, sample_xer_single_project: Path
) -> None:
"""list_activities returns activities with all expected fields."""
from xer_mcp.tools.list_activities import list_activities
from xer_mcp.tools.load_xer import load_xer
await load_xer(file_path=str(sample_xer_single_project))
result = await list_activities()
activity = result["activities"][0]
assert "task_id" in activity
assert "task_code" in activity
assert "task_name" in activity
assert "task_type" in activity
assert "target_start_date" in activity
assert "target_end_date" in activity
assert "status_code" in activity
assert "driving_path_flag" in activity

View File

@@ -0,0 +1,124 @@
"""Contract tests for list_milestones MCP tool."""
from pathlib import Path
import pytest
from xer_mcp.db import db
@pytest.fixture(autouse=True)
def setup_db():
"""Initialize and clear database for each test."""
db.initialize()
yield
db.clear()
class TestListMilestonesContract:
"""Contract tests verifying list_milestones tool interface."""
async def test_list_milestones_returns_milestone_activities(
self, sample_xer_single_project: Path
) -> None:
"""list_milestones returns only milestone type activities."""
from xer_mcp.tools.list_milestones import list_milestones
from xer_mcp.tools.load_xer import load_xer
await load_xer(file_path=str(sample_xer_single_project))
result = await list_milestones()
assert "milestones" in result
assert len(result["milestones"]) == 2
async def test_list_milestones_includes_expected_fields(
self, sample_xer_single_project: Path
) -> None:
"""list_milestones returns milestones with required fields."""
from xer_mcp.tools.list_milestones import list_milestones
from xer_mcp.tools.load_xer import load_xer
await load_xer(file_path=str(sample_xer_single_project))
result = await list_milestones()
milestone = result["milestones"][0]
assert "task_id" in milestone
assert "task_code" in milestone
assert "task_name" in milestone
assert "target_start_date" in milestone
assert "target_end_date" in milestone
async def test_list_milestones_returns_correct_activities(
self, sample_xer_single_project: Path
) -> None:
"""list_milestones returns the expected milestone activities."""
from xer_mcp.tools.list_milestones import list_milestones
from xer_mcp.tools.load_xer import load_xer
await load_xer(file_path=str(sample_xer_single_project))
result = await list_milestones()
milestone_names = [m["task_name"] for m in result["milestones"]]
assert "Project Start" in milestone_names
assert "Project Complete" in milestone_names
async def test_list_milestones_empty_when_no_milestones(self, sample_xer_empty: Path) -> None:
"""list_milestones returns empty list when no milestones exist."""
from xer_mcp.tools.list_milestones import list_milestones
from xer_mcp.tools.load_xer import load_xer
await load_xer(file_path=str(sample_xer_empty))
result = await list_milestones()
assert "milestones" in result
assert len(result["milestones"]) == 0
async def test_list_milestones_no_file_loaded_returns_error(self) -> None:
"""list_milestones without loaded file returns NO_FILE_LOADED error."""
from xer_mcp.server import set_file_loaded
from xer_mcp.tools.list_milestones import list_milestones
set_file_loaded(False)
result = await list_milestones()
assert "error" in result
assert result["error"]["code"] == "NO_FILE_LOADED"
async def test_list_milestones_includes_milestone_type_field(
self, sample_xer_single_project: Path
) -> None:
"""list_milestones returns milestones with milestone_type field."""
from xer_mcp.tools.list_milestones import list_milestones
from xer_mcp.tools.load_xer import load_xer
await load_xer(file_path=str(sample_xer_single_project))
result = await list_milestones()
# All milestones should have milestone_type field
for milestone in result["milestones"]:
assert "milestone_type" in milestone
async def test_list_milestones_returns_start_and_finish_types(
self, sample_xer_single_project: Path
) -> None:
"""list_milestones returns milestones with correct start/finish types."""
from xer_mcp.tools.list_milestones import list_milestones
from xer_mcp.tools.load_xer import load_xer
await load_xer(file_path=str(sample_xer_single_project))
result = await list_milestones()
# Find milestones by name and verify their types
milestones_by_name = {m["task_name"]: m for m in result["milestones"]}
# "Project Start" should be a start milestone
assert milestones_by_name["Project Start"]["milestone_type"] == "start"
# "Project Complete" should be a finish milestone
assert milestones_by_name["Project Complete"]["milestone_type"] == "finish"

View File

@@ -0,0 +1,96 @@
"""Contract tests for list_relationships MCP tool."""
from pathlib import Path
import pytest
from xer_mcp.db import db
@pytest.fixture(autouse=True)
def setup_db():
"""Initialize and clear database for each test."""
db.initialize()
yield
db.clear()
class TestListRelationshipsContract:
"""Contract tests verifying list_relationships tool interface."""
async def test_list_relationships_returns_paginated_results(
self, sample_xer_single_project: Path
) -> None:
"""list_relationships returns relationships with pagination metadata."""
from xer_mcp.tools.list_relationships import list_relationships
from xer_mcp.tools.load_xer import load_xer
await load_xer(file_path=str(sample_xer_single_project))
result = await list_relationships()
assert "relationships" in result
assert "pagination" in result
assert len(result["relationships"]) == 5
assert result["pagination"]["total_count"] == 5
async def test_list_relationships_with_pagination(
self, sample_xer_single_project: Path
) -> None:
"""list_relationships respects limit and offset parameters."""
from xer_mcp.tools.list_relationships import list_relationships
from xer_mcp.tools.load_xer import load_xer
await load_xer(file_path=str(sample_xer_single_project))
result = await list_relationships(limit=2, offset=0)
assert len(result["relationships"]) == 2
assert result["pagination"]["has_more"] is True
async def test_list_relationships_includes_expected_fields(
self, sample_xer_single_project: Path
) -> None:
"""list_relationships returns relationships with all expected fields."""
from xer_mcp.tools.list_relationships import list_relationships
from xer_mcp.tools.load_xer import load_xer
await load_xer(file_path=str(sample_xer_single_project))
result = await list_relationships()
rel = result["relationships"][0]
assert "task_pred_id" in rel
assert "task_id" in rel
assert "pred_task_id" in rel
assert "pred_type" in rel
assert "lag_hr_cnt" in rel
async def test_list_relationships_no_file_loaded_returns_error(self) -> None:
"""list_relationships without loaded file returns NO_FILE_LOADED error."""
from xer_mcp.server import set_file_loaded
from xer_mcp.tools.list_relationships import list_relationships
set_file_loaded(False)
result = await list_relationships()
assert "error" in result
assert result["error"]["code"] == "NO_FILE_LOADED"
async def test_list_relationships_includes_driving_flag(
self, sample_xer_single_project: Path
) -> None:
"""list_relationships returns relationships with driving flag."""
from xer_mcp.tools.list_relationships import list_relationships
from xer_mcp.tools.load_xer import load_xer
await load_xer(file_path=str(sample_xer_single_project))
result = await list_relationships()
assert "relationships" in result
assert len(result["relationships"]) > 0
# All relationships should have a driving flag
for rel in result["relationships"]:
assert "driving" in rel
assert isinstance(rel["driving"], bool)

View File

@@ -0,0 +1,250 @@
"""Contract tests for load_xer MCP tool."""
import sqlite3
from pathlib import Path
import pytest
from xer_mcp.db import db
@pytest.fixture(autouse=True)
def setup_db():
"""Reset database state for each test."""
# Close any existing connection
if db.is_initialized:
db.close()
yield
# Cleanup after test
if db.is_initialized:
db.close()
class TestLoadXerContract:
"""Contract tests verifying load_xer tool interface matches spec."""
async def test_load_single_project_returns_success(
self, sample_xer_single_project: Path
) -> None:
"""load_xer with single-project file returns success and project info."""
from xer_mcp.tools.load_xer import load_xer
result = await load_xer(file_path=str(sample_xer_single_project))
assert result["success"] is True
assert "project" in result
assert result["project"]["proj_id"] == "1001"
assert result["project"]["proj_short_name"] == "Test Project"
assert "activity_count" in result
assert result["activity_count"] == 5
assert "relationship_count" in result
assert result["relationship_count"] == 5
async def test_load_multi_project_without_selection_returns_list(
self, sample_xer_multi_project: Path
) -> None:
"""load_xer with multi-project file without project_id returns available projects."""
from xer_mcp.tools.load_xer import load_xer
result = await load_xer(file_path=str(sample_xer_multi_project))
assert result["success"] is False
assert "available_projects" in result
assert len(result["available_projects"]) == 2
assert "message" in result
assert "project_id" in result["message"].lower()
async def test_load_multi_project_with_selection_returns_success(
self, sample_xer_multi_project: Path
) -> None:
"""load_xer with multi-project file and project_id returns selected project."""
from xer_mcp.tools.load_xer import load_xer
result = await load_xer(file_path=str(sample_xer_multi_project), project_id="1001")
assert result["success"] is True
assert result["project"]["proj_id"] == "1001"
assert result["project"]["proj_short_name"] == "Project Alpha"
async def test_load_nonexistent_file_returns_error(self, nonexistent_xer_path: Path) -> None:
"""load_xer with missing file returns FILE_NOT_FOUND error."""
from xer_mcp.tools.load_xer import load_xer
result = await load_xer(file_path=str(nonexistent_xer_path))
assert result["success"] is False
assert "error" in result
assert result["error"]["code"] == "FILE_NOT_FOUND"
async def test_load_invalid_file_returns_error(self, invalid_xer_file: Path) -> None:
"""load_xer with invalid file returns PARSE_ERROR error."""
from xer_mcp.tools.load_xer import load_xer
result = await load_xer(file_path=str(invalid_xer_file))
assert result["success"] is False
assert "error" in result
assert result["error"]["code"] == "PARSE_ERROR"
async def test_load_replaces_previous_file(
self, sample_xer_single_project: Path, sample_xer_empty: Path
) -> None:
"""Loading a new file replaces the previous file's data."""
from xer_mcp.tools.load_xer import load_xer
# Load first file
result1 = await load_xer(file_path=str(sample_xer_single_project))
assert result1["activity_count"] == 5
# Load second file (empty)
result2 = await load_xer(file_path=str(sample_xer_empty))
assert result2["activity_count"] == 0
async def test_load_returns_plan_dates(self, sample_xer_single_project: Path) -> None:
"""load_xer returns project plan start and end dates."""
from xer_mcp.tools.load_xer import load_xer
result = await load_xer(file_path=str(sample_xer_single_project))
assert "plan_start_date" in result["project"]
assert "plan_end_date" in result["project"]
# Dates should be ISO8601 format
assert "T" in result["project"]["plan_start_date"]
class TestLoadXerPersistentDatabase:
"""Contract tests for persistent database functionality."""
async def test_load_xer_with_db_path_creates_file(
self, tmp_path: Path, sample_xer_single_project: Path
) -> None:
"""load_xer with db_path creates persistent database file."""
from xer_mcp.tools.load_xer import load_xer
db_file = tmp_path / "schedule.db"
result = await load_xer(
file_path=str(sample_xer_single_project),
db_path=str(db_file),
)
assert result["success"] is True
assert db_file.exists()
assert result["database"]["db_path"] == str(db_file)
assert result["database"]["is_persistent"] is True
async def test_load_xer_with_empty_db_path_auto_generates(self, tmp_path: Path) -> None:
"""load_xer with empty db_path generates path from XER filename."""
from xer_mcp.tools.load_xer import load_xer
# Create XER file in tmp_path
xer_file = tmp_path / "my_schedule.xer"
from tests.conftest import SAMPLE_XER_SINGLE_PROJECT
xer_file.write_text(SAMPLE_XER_SINGLE_PROJECT)
result = await load_xer(file_path=str(xer_file), db_path="")
assert result["success"] is True
expected_db = str(tmp_path / "my_schedule.sqlite")
assert result["database"]["db_path"] == expected_db
assert result["database"]["is_persistent"] is True
assert Path(expected_db).exists()
async def test_load_xer_without_db_path_uses_memory(
self, sample_xer_single_project: Path
) -> None:
"""load_xer without db_path uses in-memory database (backward compatible)."""
from xer_mcp.tools.load_xer import load_xer
result = await load_xer(file_path=str(sample_xer_single_project))
assert result["success"] is True
assert result["database"]["db_path"] == ":memory:"
assert result["database"]["is_persistent"] is False
async def test_load_xer_database_contains_all_data(
self, tmp_path: Path, sample_xer_single_project: Path
) -> None:
"""Persistent database contains all parsed data."""
from xer_mcp.tools.load_xer import load_xer
db_file = tmp_path / "schedule.db"
result = await load_xer(
file_path=str(sample_xer_single_project),
db_path=str(db_file),
)
# Verify data via direct SQL
conn = sqlite3.connect(str(db_file))
cursor = conn.execute("SELECT COUNT(*) FROM activities")
count = cursor.fetchone()[0]
conn.close()
assert count == result["activity_count"]
async def test_load_xer_response_includes_database_info(
self, tmp_path: Path, sample_xer_single_project: Path
) -> None:
"""load_xer response includes complete database info."""
from xer_mcp.tools.load_xer import load_xer
db_file = tmp_path / "schedule.db"
result = await load_xer(
file_path=str(sample_xer_single_project),
db_path=str(db_file),
)
assert "database" in result
db_info = result["database"]
assert "db_path" in db_info
assert "is_persistent" in db_info
assert "source_file" in db_info
assert "loaded_at" in db_info
assert "schema" in db_info
async def test_load_xer_response_schema_includes_tables(
self, tmp_path: Path, sample_xer_single_project: Path
) -> None:
"""load_xer response schema includes table information."""
from xer_mcp.tools.load_xer import load_xer
db_file = tmp_path / "schedule.db"
result = await load_xer(
file_path=str(sample_xer_single_project),
db_path=str(db_file),
)
schema = result["database"]["schema"]
assert "version" in schema
assert "tables" in schema
table_names = [t["name"] for t in schema["tables"]]
assert "activities" in table_names
assert "relationships" in table_names
async def test_load_xer_error_on_invalid_path(self, sample_xer_single_project: Path) -> None:
"""load_xer returns error for invalid path."""
from xer_mcp.tools.load_xer import load_xer
result = await load_xer(
file_path=str(sample_xer_single_project),
db_path="/nonexistent/dir/file.db",
)
assert result["success"] is False
# Either FILE_NOT_WRITABLE or DATABASE_ERROR is acceptable
# depending on how SQLite reports the error
assert result["error"]["code"] in ("FILE_NOT_WRITABLE", "DATABASE_ERROR")
class TestLoadXerToolSchema:
"""Tests for MCP tool schema."""
async def test_load_xer_tool_schema_includes_db_path(self) -> None:
"""MCP tool schema includes db_path parameter."""
from xer_mcp.server import list_tools
tools = await list_tools()
load_xer_tool = next(t for t in tools if t.name == "load_xer")
props = load_xer_tool.inputSchema["properties"]
assert "db_path" in props
assert props["db_path"]["type"] == "string"

View File

@@ -0,0 +1 @@
"""Integration tests for XER MCP Server."""

View File

@@ -0,0 +1,185 @@
"""Integration tests for direct database access feature."""
import sqlite3
from pathlib import Path
import pytest
from xer_mcp.db import db
@pytest.fixture(autouse=True)
def setup_db():
"""Reset database state for each test."""
if db.is_initialized:
db.close()
yield
if db.is_initialized:
db.close()
class TestDirectDatabaseAccess:
"""Integration tests verifying external script can access database."""
async def test_external_script_can_query_database(
self, tmp_path: Path, sample_xer_single_project: Path
) -> None:
"""External script can query database using returned path."""
from xer_mcp.tools.load_xer import load_xer
db_file = tmp_path / "schedule.db"
result = await load_xer(
file_path=str(sample_xer_single_project),
db_path=str(db_file),
)
# Simulate external script access (as shown in quickstart.md)
db_path = result["database"]["db_path"]
conn = sqlite3.connect(db_path)
conn.row_factory = sqlite3.Row
# Query milestones
cursor = conn.execute("""
SELECT task_code, task_name, target_start_date, milestone_type
FROM activities
WHERE task_type IN ('TT_Mile', 'TT_FinMile')
ORDER BY target_start_date
""")
milestones = cursor.fetchall()
conn.close()
assert len(milestones) > 0
assert all(row["task_code"] for row in milestones)
async def test_external_script_can_query_critical_path(
self, tmp_path: Path, sample_xer_single_project: Path
) -> None:
"""External script can query critical path activities."""
from xer_mcp.tools.load_xer import load_xer
db_file = tmp_path / "schedule.db"
result = await load_xer(
file_path=str(sample_xer_single_project),
db_path=str(db_file),
)
db_path = result["database"]["db_path"]
conn = sqlite3.connect(db_path)
cursor = conn.execute("""
SELECT task_code, task_name, target_start_date, target_end_date
FROM activities
WHERE driving_path_flag = 1
ORDER BY target_start_date
""")
critical_activities = cursor.fetchall()
conn.close()
assert len(critical_activities) > 0
async def test_external_script_can_join_tables(
self, tmp_path: Path, sample_xer_single_project: Path
) -> None:
"""External script can join activities with WBS."""
from xer_mcp.tools.load_xer import load_xer
db_file = tmp_path / "schedule.db"
result = await load_xer(
file_path=str(sample_xer_single_project),
db_path=str(db_file),
)
db_path = result["database"]["db_path"]
conn = sqlite3.connect(db_path)
cursor = conn.execute("""
SELECT a.task_code, a.task_name, w.wbs_name
FROM activities a
JOIN wbs w ON a.wbs_id = w.wbs_id
LIMIT 10
""")
joined_rows = cursor.fetchall()
conn.close()
assert len(joined_rows) > 0
async def test_database_accessible_after_mcp_load(
self, tmp_path: Path, sample_xer_single_project: Path
) -> None:
"""Database remains accessible while MCP tools are active."""
from xer_mcp.tools.load_xer import load_xer
db_file = tmp_path / "schedule.db"
result = await load_xer(
file_path=str(sample_xer_single_project),
db_path=str(db_file),
)
loaded_count = result["activity_count"]
# External script queries database
conn = sqlite3.connect(str(db_file))
cursor = conn.execute("SELECT COUNT(*) FROM activities")
external_count = cursor.fetchone()[0]
conn.close()
# Both should match
assert external_count == loaded_count
async def test_schema_info_matches_actual_database(
self, tmp_path: Path, sample_xer_single_project: Path
) -> None:
"""Returned schema info matches actual database structure."""
from xer_mcp.tools.load_xer import load_xer
db_file = tmp_path / "schedule.db"
result = await load_xer(
file_path=str(sample_xer_single_project),
db_path=str(db_file),
)
schema = result["database"]["schema"]
db_path = result["database"]["db_path"]
# Verify tables exist in actual database
conn = sqlite3.connect(db_path)
cursor = conn.execute(
"SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%'"
)
actual_tables = {row[0] for row in cursor.fetchall()}
conn.close()
schema_tables = {t["name"] for t in schema["tables"]}
assert schema_tables == actual_tables
async def test_row_counts_match_actual_data(
self, tmp_path: Path, sample_xer_single_project: Path
) -> None:
"""Schema row counts match actual database row counts."""
from xer_mcp.tools.load_xer import load_xer
db_file = tmp_path / "schedule.db"
result = await load_xer(
file_path=str(sample_xer_single_project),
db_path=str(db_file),
)
schema = result["database"]["schema"]
db_path = result["database"]["db_path"]
conn = sqlite3.connect(db_path)
for table_info in schema["tables"]:
cursor = conn.execute(
f"SELECT COUNT(*) FROM {table_info['name']}" # noqa: S608
)
actual_count = cursor.fetchone()[0]
assert table_info["row_count"] == actual_count, (
f"Table {table_info['name']}: expected {table_info['row_count']}, "
f"got {actual_count}"
)
conn.close()

View File

@@ -0,0 +1,154 @@
"""Integration tests for XER parsing and database loading."""
from pathlib import Path
import pytest
from xer_mcp.db import db
@pytest.fixture(autouse=True)
def setup_db():
"""Initialize and clear database for each test."""
db.initialize()
yield
db.clear()
class TestXerParsing:
"""Integration tests for parsing XER files and loading into database."""
def test_load_single_project_xer(self, sample_xer_single_project: Path) -> None:
"""Should parse XER and load data into SQLite database."""
from xer_mcp.db.loader import load_parsed_data
from xer_mcp.parser.xer_parser import XerParser
parser = XerParser()
parsed = parser.parse(sample_xer_single_project)
# Load all data for the single project
load_parsed_data(parsed, project_id="1001")
# Verify data in database
with db.cursor() as cur:
cur.execute("SELECT COUNT(*) FROM projects")
assert cur.fetchone()[0] == 1
cur.execute("SELECT COUNT(*) FROM activities")
assert cur.fetchone()[0] == 5
cur.execute("SELECT COUNT(*) FROM relationships")
assert cur.fetchone()[0] == 5
cur.execute("SELECT COUNT(*) FROM wbs")
assert cur.fetchone()[0] == 3
def test_load_preserves_date_precision(self, sample_xer_single_project: Path) -> None:
"""Should preserve date/time precision from XER file."""
from xer_mcp.db.loader import load_parsed_data
from xer_mcp.parser.xer_parser import XerParser
parser = XerParser()
parsed = parser.parse(sample_xer_single_project)
load_parsed_data(parsed, project_id="1001")
with db.cursor() as cur:
cur.execute("SELECT target_start_date FROM activities WHERE task_code = ?", ("A1010",))
date_str = cur.fetchone()[0]
# Should be ISO8601 with time component
assert "T" in date_str
assert "07:00" in date_str
def test_load_activities_indexed_by_type(self, sample_xer_single_project: Path) -> None:
"""Should be able to efficiently query activities by type."""
from xer_mcp.db.loader import load_parsed_data
from xer_mcp.parser.xer_parser import XerParser
parser = XerParser()
parsed = parser.parse(sample_xer_single_project)
load_parsed_data(parsed, project_id="1001")
with db.cursor() as cur:
# Query milestones
cur.execute("SELECT COUNT(*) FROM activities WHERE task_type = ?", ("TT_Mile",))
milestone_count = cur.fetchone()[0]
assert milestone_count == 2
# Query tasks
cur.execute("SELECT COUNT(*) FROM activities WHERE task_type = ?", ("TT_Task",))
task_count = cur.fetchone()[0]
assert task_count == 3
def test_load_critical_path_activities(self, sample_xer_single_project: Path) -> None:
"""Should be able to query critical path activities via index."""
from xer_mcp.db.loader import load_parsed_data
from xer_mcp.parser.xer_parser import XerParser
parser = XerParser()
parsed = parser.parse(sample_xer_single_project)
load_parsed_data(parsed, project_id="1001")
with db.cursor() as cur:
cur.execute("SELECT COUNT(*) FROM activities WHERE driving_path_flag = 1")
critical_count = cur.fetchone()[0]
# Activities A1000, A1010, A1030, A1040 are on critical path
assert critical_count == 4
def test_load_replaces_previous_data(self, sample_xer_single_project: Path) -> None:
"""Loading a new file should replace previous data."""
from xer_mcp.db.loader import load_parsed_data
from xer_mcp.parser.xer_parser import XerParser
parser = XerParser()
parsed = parser.parse(sample_xer_single_project)
# Load first time
load_parsed_data(parsed, project_id="1001")
with db.cursor() as cur:
cur.execute("SELECT COUNT(*) FROM activities")
first_count = cur.fetchone()[0]
# Clear and load again
db.clear()
load_parsed_data(parsed, project_id="1001")
with db.cursor() as cur:
cur.execute("SELECT COUNT(*) FROM activities")
second_count = cur.fetchone()[0]
assert first_count == second_count
class TestMultiProjectHandling:
"""Integration tests for multi-project XER file handling."""
def test_load_selected_project_from_multi(self, sample_xer_multi_project: Path) -> None:
"""Should load only the selected project from multi-project file."""
from xer_mcp.db.loader import load_parsed_data
from xer_mcp.parser.xer_parser import XerParser
parser = XerParser()
parsed = parser.parse(sample_xer_multi_project)
# Load only Project Alpha
load_parsed_data(parsed, project_id="1001")
with db.cursor() as cur:
cur.execute("SELECT proj_short_name FROM projects")
names = [row[0] for row in cur.fetchall()]
assert names == ["Project Alpha"]
cur.execute("SELECT COUNT(*) FROM activities WHERE proj_id = ?", ("1001",))
assert cur.fetchone()[0] == 1
def test_multi_project_list_available(self, sample_xer_multi_project: Path) -> None:
"""Parser should report all available projects."""
from xer_mcp.parser.xer_parser import XerParser
parser = XerParser()
parsed = parser.parse(sample_xer_multi_project)
assert len(parsed.projects) == 2
proj_ids = {p["proj_id"] for p in parsed.projects}
assert proj_ids == {"1001", "1002"}

1
tests/unit/__init__.py Normal file
View File

@@ -0,0 +1 @@
"""Unit tests for XER MCP Server."""

View File

@@ -0,0 +1,234 @@
"""Unit tests for DatabaseManager file-based database support."""
import sqlite3
from datetime import datetime
from pathlib import Path
from xer_mcp.db import DatabaseManager
class TestDatabaseManagerInitialization:
"""Tests for DatabaseManager initialization modes."""
def test_initialize_with_memory_by_default(self) -> None:
"""Default initialization uses in-memory database."""
dm = DatabaseManager()
dm.initialize()
assert dm.db_path == ":memory:"
assert dm.is_persistent is False
dm.close()
def test_initialize_with_file_path(self, tmp_path: Path) -> None:
"""Can initialize with explicit file path."""
db_file = tmp_path / "test.db"
dm = DatabaseManager()
dm.initialize(db_path=str(db_file))
assert dm.db_path == str(db_file)
assert dm.is_persistent is True
assert db_file.exists()
dm.close()
def test_initialize_with_empty_string_auto_generates_path(self, tmp_path: Path) -> None:
"""Empty string db_path with source_file auto-generates path."""
xer_file = tmp_path / "schedule.xer"
xer_file.write_text("dummy content")
dm = DatabaseManager()
dm.initialize(db_path="", source_file=str(xer_file))
expected_db = str(tmp_path / "schedule.sqlite")
assert dm.db_path == expected_db
assert dm.is_persistent is True
assert Path(expected_db).exists()
dm.close()
def test_file_database_persists_after_close(self, tmp_path: Path) -> None:
"""File-based database persists after connection close."""
db_file = tmp_path / "persist_test.db"
dm = DatabaseManager()
dm.initialize(db_path=str(db_file))
# Insert test data
with dm.cursor() as cur:
cur.execute(
"INSERT INTO projects (proj_id, proj_short_name, loaded_at) "
"VALUES ('P1', 'Test', datetime('now'))"
)
dm.commit()
dm.close()
# Verify file exists and has data
assert db_file.exists()
conn = sqlite3.connect(str(db_file))
cursor = conn.execute("SELECT proj_id FROM projects")
rows = cursor.fetchall()
conn.close()
assert len(rows) == 1
assert rows[0][0] == "P1"
def test_source_file_tracked(self, tmp_path: Path) -> None:
"""Source file path is tracked when provided."""
db_file = tmp_path / "test.db"
xer_file = tmp_path / "schedule.xer"
xer_file.write_text("dummy")
dm = DatabaseManager()
dm.initialize(db_path=str(db_file), source_file=str(xer_file))
assert dm.source_file == str(xer_file)
dm.close()
def test_loaded_at_timestamp(self, tmp_path: Path) -> None:
"""Loaded_at timestamp is recorded."""
db_file = tmp_path / "test.db"
dm = DatabaseManager()
before = datetime.now()
dm.initialize(db_path=str(db_file))
after = datetime.now()
loaded_at = dm.loaded_at
assert loaded_at is not None
assert before <= loaded_at <= after
dm.close()
def test_memory_database_not_persistent(self) -> None:
"""In-memory database is not persistent."""
dm = DatabaseManager()
dm.initialize()
assert dm.is_persistent is False
assert dm.db_path == ":memory:"
dm.close()
class TestDatabaseManagerWalMode:
"""Tests for WAL mode in file-based databases."""
def test_file_database_uses_wal_mode(self, tmp_path: Path) -> None:
"""File-based database uses WAL mode for concurrent access."""
db_file = tmp_path / "wal_test.db"
dm = DatabaseManager()
dm.initialize(db_path=str(db_file))
with dm.cursor() as cur:
cur.execute("PRAGMA journal_mode")
mode = cur.fetchone()[0]
assert mode.lower() == "wal"
dm.close()
def test_memory_database_does_not_use_wal(self) -> None:
"""In-memory database doesn't use WAL mode (not applicable)."""
dm = DatabaseManager()
dm.initialize()
with dm.cursor() as cur:
cur.execute("PRAGMA journal_mode")
mode = cur.fetchone()[0]
# Memory databases use 'memory' journal mode
assert mode.lower() == "memory"
dm.close()
class TestAtomicWrite:
"""Tests for atomic write pattern."""
def test_atomic_write_creates_final_file(self, tmp_path: Path) -> None:
"""Database is created at final path after initialization."""
target = tmp_path / "atomic_test.db"
dm = DatabaseManager()
dm.initialize(db_path=str(target))
assert target.exists()
assert not Path(str(target) + ".tmp").exists()
dm.close()
def test_atomic_write_no_temp_file_remains(self, tmp_path: Path) -> None:
"""No .tmp file remains after successful initialization."""
target = tmp_path / "atomic_clean.db"
dm = DatabaseManager()
dm.initialize(db_path=str(target))
dm.close()
# Check no temp files remain
temp_files = list(tmp_path.glob("*.tmp"))
assert len(temp_files) == 0
class TestSchemaIntrospection:
"""Tests for database schema introspection."""
def test_get_schema_info_returns_all_tables(self) -> None:
"""Schema info includes all database tables."""
dm = DatabaseManager()
dm.initialize()
schema = dm.get_schema_info()
assert schema["version"] == "0.2.0"
table_names = [t["name"] for t in schema["tables"]]
assert "projects" in table_names
assert "activities" in table_names
assert "relationships" in table_names
assert "wbs" in table_names
assert "calendars" in table_names
dm.close()
def test_get_schema_info_includes_column_details(self) -> None:
"""Schema info includes column names, types, and nullable."""
dm = DatabaseManager()
dm.initialize()
schema = dm.get_schema_info()
activities_table = next(t for t in schema["tables"] if t["name"] == "activities")
column_names = [c["name"] for c in activities_table["columns"]]
assert "task_id" in column_names
assert "task_name" in column_names
# Check column details
task_id_col = next(c for c in activities_table["columns"] if c["name"] == "task_id")
assert task_id_col["type"] == "TEXT"
# Note: SQLite reports PRIMARY KEY TEXT columns as nullable
# but the PRIMARY KEY constraint still applies
assert "nullable" in task_id_col
# Check a NOT NULL column
task_name_col = next(c for c in activities_table["columns"] if c["name"] == "task_name")
assert task_name_col["nullable"] is False
dm.close()
def test_get_schema_info_includes_row_counts(self) -> None:
"""Schema info includes row counts for each table."""
dm = DatabaseManager()
dm.initialize()
schema = dm.get_schema_info()
for table in schema["tables"]:
assert "row_count" in table
assert isinstance(table["row_count"], int)
assert table["row_count"] >= 0
dm.close()
def test_schema_info_includes_primary_keys(self) -> None:
"""Schema info includes primary key for each table."""
dm = DatabaseManager()
dm.initialize()
schema = dm.get_schema_info()
activities_table = next(t for t in schema["tables"] if t["name"] == "activities")
assert "primary_key" in activities_table
assert "task_id" in activities_table["primary_key"]
dm.close()
def test_schema_info_includes_foreign_keys(self) -> None:
"""Schema info includes foreign key relationships."""
dm = DatabaseManager()
dm.initialize()
schema = dm.get_schema_info()
activities_table = next(t for t in schema["tables"] if t["name"] == "activities")
assert "foreign_keys" in activities_table
# activities.proj_id -> projects.proj_id
fk = next(
(fk for fk in activities_table["foreign_keys"] if fk["column"] == "proj_id"),
None,
)
assert fk is not None
assert fk["references_table"] == "projects"
assert fk["references_column"] == "proj_id"
dm.close()

View File

@@ -0,0 +1,176 @@
"""Unit tests for database query functions."""
from pathlib import Path
import pytest
from xer_mcp.db import db
@pytest.fixture(autouse=True)
def setup_db():
"""Initialize and clear database for each test."""
db.initialize()
yield
db.clear()
class TestActivityQueries:
"""Tests for activity query functions."""
def test_query_activities_with_pagination(self, sample_xer_single_project: Path) -> None:
"""Should return paginated activity results."""
from xer_mcp.db.loader import load_parsed_data
from xer_mcp.db.queries import query_activities
from xer_mcp.parser.xer_parser import XerParser
parser = XerParser()
parsed = parser.parse(sample_xer_single_project)
load_parsed_data(parsed, project_id="1001")
activities, total = query_activities(limit=2, offset=0)
assert len(activities) == 2
assert total == 5
def test_query_activities_filter_by_type(self, sample_xer_single_project: Path) -> None:
"""Should filter activities by task type."""
from xer_mcp.db.loader import load_parsed_data
from xer_mcp.db.queries import query_activities
from xer_mcp.parser.xer_parser import XerParser
parser = XerParser()
parsed = parser.parse(sample_xer_single_project)
load_parsed_data(parsed, project_id="1001")
activities, total = query_activities(activity_type="TT_Mile")
assert total == 2
for act in activities:
assert act["task_type"] == "TT_Mile"
def test_query_activities_filter_by_date_range(self, sample_xer_single_project: Path) -> None:
"""Should filter activities by date range."""
from xer_mcp.db.loader import load_parsed_data
from xer_mcp.db.queries import query_activities
from xer_mcp.parser.xer_parser import XerParser
parser = XerParser()
parsed = parser.parse(sample_xer_single_project)
load_parsed_data(parsed, project_id="1001")
# Filter to very narrow range
activities, total = query_activities(start_date="2026-01-01", end_date="2026-01-01")
# Only activities starting on 2026-01-01
for act in activities:
assert "2026-01-01" in act["target_start_date"]
def test_query_activities_filter_by_wbs(self, sample_xer_single_project: Path) -> None:
"""Should filter activities by WBS ID."""
from xer_mcp.db.loader import load_parsed_data
from xer_mcp.db.queries import query_activities
from xer_mcp.parser.xer_parser import XerParser
parser = XerParser()
parsed = parser.parse(sample_xer_single_project)
load_parsed_data(parsed, project_id="1001")
activities, total = query_activities(wbs_id="102")
# WBS 102 has 2 activities
assert total == 2
def test_get_activity_by_id(self, sample_xer_single_project: Path) -> None:
"""Should return single activity by ID."""
from xer_mcp.db.loader import load_parsed_data
from xer_mcp.db.queries import get_activity_by_id
from xer_mcp.parser.xer_parser import XerParser
parser = XerParser()
parsed = parser.parse(sample_xer_single_project)
load_parsed_data(parsed, project_id="1001")
activity = get_activity_by_id("2002")
assert activity is not None
assert activity["task_code"] == "A1010"
def test_get_activity_by_id_not_found(self, sample_xer_single_project: Path) -> None:
"""Should return None for non-existent activity."""
from xer_mcp.db.loader import load_parsed_data
from xer_mcp.db.queries import get_activity_by_id
from xer_mcp.parser.xer_parser import XerParser
parser = XerParser()
parsed = parser.parse(sample_xer_single_project)
load_parsed_data(parsed, project_id="1001")
activity = get_activity_by_id("nonexistent")
assert activity is None
class TestDrivingRelationship:
"""Tests for driving relationship computation."""
def test_is_driving_relationship_fs_driving(self) -> None:
"""FS relationship is driving when pred_end + lag = succ_start."""
from xer_mcp.db.queries import is_driving_relationship
# Pred ends at 2026-01-08T15:00, succ starts at 2026-01-09T07:00
# With 0 lag and overnight gap, this is driving
result = is_driving_relationship(
pred_early_end="2026-01-08T15:00:00",
succ_early_start="2026-01-09T07:00:00",
lag_hours=0.0,
pred_type="FS",
)
assert result is True
def test_is_driving_relationship_fs_not_driving(self) -> None:
"""FS relationship is not driving when there's float."""
from xer_mcp.db.queries import is_driving_relationship
# Pred ends much earlier than succ starts (has float)
result = is_driving_relationship(
pred_early_end="2026-01-01T15:00:00",
succ_early_start="2026-01-10T07:00:00",
lag_hours=0.0,
pred_type="FS",
)
assert result is False
def test_is_driving_relationship_with_lag(self) -> None:
"""FS relationship with lag is driving when pred_end + lag = succ_start."""
from xer_mcp.db.queries import is_driving_relationship
# Pred ends at 2026-01-08T15:00, 16hr lag, succ starts at 2026-01-09T07:00
# 15:00 + 16hrs = next day 07:00 (exactly matches)
result = is_driving_relationship(
pred_early_end="2026-01-08T15:00:00",
succ_early_start="2026-01-09T07:00:00",
lag_hours=16.0,
pred_type="FS",
)
assert result is True
def test_is_driving_relationship_missing_dates(self) -> None:
"""Relationship is not driving when dates are missing."""
from xer_mcp.db.queries import is_driving_relationship
result = is_driving_relationship(
pred_early_end=None,
succ_early_start="2026-01-09T07:00:00",
lag_hours=0.0,
pred_type="FS",
)
assert result is False
result = is_driving_relationship(
pred_early_end="2026-01-08T15:00:00",
succ_early_start=None,
lag_hours=0.0,
pred_type="FS",
)
assert result is False

146
tests/unit/test_parser.py Normal file
View File

@@ -0,0 +1,146 @@
"""Unit tests for XER parser."""
from pathlib import Path
import pytest
class TestXerParser:
"""Tests for the XER file parser."""
def test_parse_single_project_file(self, sample_xer_single_project: Path) -> None:
"""Parser should extract project data from single-project XER file."""
from xer_mcp.parser.xer_parser import XerParser
parser = XerParser()
result = parser.parse(sample_xer_single_project)
assert len(result.projects) == 1
assert result.projects[0]["proj_id"] == "1001"
assert result.projects[0]["proj_short_name"] == "Test Project"
def test_parse_multi_project_file(self, sample_xer_multi_project: Path) -> None:
"""Parser should extract all projects from multi-project XER file."""
from xer_mcp.parser.xer_parser import XerParser
parser = XerParser()
result = parser.parse(sample_xer_multi_project)
assert len(result.projects) == 2
project_names = {p["proj_short_name"] for p in result.projects}
assert project_names == {"Project Alpha", "Project Beta"}
def test_parse_activities(self, sample_xer_single_project: Path) -> None:
"""Parser should extract activities from XER file."""
from xer_mcp.parser.xer_parser import XerParser
parser = XerParser()
result = parser.parse(sample_xer_single_project)
# Single project fixture has 5 activities
assert len(result.tasks) == 5
# Check first milestone
milestone = next(t for t in result.tasks if t["task_code"] == "A1000")
assert milestone["task_name"] == "Project Start"
assert milestone["task_type"] == "TT_Mile"
def test_parse_relationships(self, sample_xer_single_project: Path) -> None:
"""Parser should extract relationships from XER file."""
from xer_mcp.parser.xer_parser import XerParser
parser = XerParser()
result = parser.parse(sample_xer_single_project)
# Single project fixture has 5 relationships
assert len(result.taskpreds) == 5
# Check a FS relationship
fs_rel = next(r for r in result.taskpreds if r["pred_type"] == "PR_FS")
assert fs_rel["lag_hr_cnt"] == 0
# Check a SS relationship
ss_rel = next(r for r in result.taskpreds if r["pred_type"] == "PR_SS")
assert ss_rel["lag_hr_cnt"] == 40
def test_parse_wbs(self, sample_xer_single_project: Path) -> None:
"""Parser should extract WBS hierarchy from XER file."""
from xer_mcp.parser.xer_parser import XerParser
parser = XerParser()
result = parser.parse(sample_xer_single_project)
# Single project fixture has 3 WBS elements
assert len(result.projwbs) == 3
# Check root WBS
root = next(w for w in result.projwbs if w["wbs_short_name"] == "ROOT")
assert root["parent_wbs_id"] is None or root["parent_wbs_id"] == ""
def test_parse_calendars(self, sample_xer_single_project: Path) -> None:
"""Parser should extract calendars from XER file."""
from xer_mcp.parser.xer_parser import XerParser
parser = XerParser()
result = parser.parse(sample_xer_single_project)
# Single project fixture has 1 calendar
assert len(result.calendars) == 1
cal = result.calendars[0]
assert cal["clndr_name"] == "Standard 5 Day"
assert cal["day_hr_cnt"] == 8
def test_parse_empty_project(self, sample_xer_empty: Path) -> None:
"""Parser should handle XER file with no activities."""
from xer_mcp.parser.xer_parser import XerParser
parser = XerParser()
result = parser.parse(sample_xer_empty)
assert len(result.projects) == 1
assert len(result.tasks) == 0
assert len(result.taskpreds) == 0
def test_parse_invalid_file_raises_error(self, invalid_xer_file: Path) -> None:
"""Parser should raise ParseError for invalid XER content."""
from xer_mcp.errors import ParseError
from xer_mcp.parser.xer_parser import XerParser
parser = XerParser()
with pytest.raises(ParseError):
parser.parse(invalid_xer_file)
def test_parse_nonexistent_file_raises_error(self, nonexistent_xer_path: Path) -> None:
"""Parser should raise FileNotFoundError for missing file."""
from xer_mcp.errors import FileNotFoundError
from xer_mcp.parser.xer_parser import XerParser
parser = XerParser()
with pytest.raises(FileNotFoundError):
parser.parse(nonexistent_xer_path)
def test_parse_dates_converted_to_iso8601(self, sample_xer_single_project: Path) -> None:
"""Parser should convert XER dates to ISO8601 format."""
from xer_mcp.parser.xer_parser import XerParser
parser = XerParser()
result = parser.parse(sample_xer_single_project)
# Check date conversion (XER: "2026-01-01 07:00" -> ISO: "2026-01-01T07:00:00")
task = next(t for t in result.tasks if t["task_code"] == "A1000")
assert "T" in task["target_start_date"]
def test_parse_driving_path_flag(self, sample_xer_single_project: Path) -> None:
"""Parser should correctly parse driving_path_flag as boolean."""
from xer_mcp.parser.xer_parser import XerParser
parser = XerParser()
result = parser.parse(sample_xer_single_project)
# A1000 has driving_path_flag = Y
critical_task = next(t for t in result.tasks if t["task_code"] == "A1000")
assert critical_task["driving_path_flag"] is True
# A1020 has driving_path_flag = N
non_critical = next(t for t in result.tasks if t["task_code"] == "A1020")
assert non_critical["driving_path_flag"] is False

View File

@@ -0,0 +1,403 @@
"""Unit tests for XER table handlers."""
class TestProjectHandler:
"""Tests for PROJECT table handler."""
def test_parse_project_row(self) -> None:
"""Handler should parse PROJECT row correctly."""
from xer_mcp.parser.table_handlers.project import ProjectHandler
handler = ProjectHandler()
# Minimal PROJECT fields
fields = [
"proj_id",
"proj_short_name",
"plan_start_date",
"plan_end_date",
]
values = ["1001", "Test Project", "2026-01-01 00:00", "2026-06-30 00:00"]
result = handler.parse_row(fields, values)
assert result is not None
assert result["proj_id"] == "1001"
assert result["proj_short_name"] == "Test Project"
assert result["plan_start_date"] == "2026-01-01T00:00:00"
assert result["plan_end_date"] == "2026-06-30T00:00:00"
def test_table_name(self) -> None:
"""Handler should report correct table name."""
from xer_mcp.parser.table_handlers.project import ProjectHandler
handler = ProjectHandler()
assert handler.table_name == "PROJECT"
class TestTaskHandler:
"""Tests for TASK table handler."""
def test_parse_task_row(self) -> None:
"""Handler should parse TASK row correctly."""
from xer_mcp.parser.table_handlers.task import TaskHandler
handler = TaskHandler()
fields = [
"task_id",
"proj_id",
"wbs_id",
"task_code",
"task_name",
"task_type",
"status_code",
"target_start_date",
"target_end_date",
"total_float_hr_cnt",
"driving_path_flag",
]
values = [
"2001",
"1001",
"100",
"A1000",
"Site Prep",
"TT_Task",
"TK_NotStart",
"2026-01-02 07:00",
"2026-01-08 15:00",
"0",
"Y",
]
result = handler.parse_row(fields, values)
assert result is not None
assert result["task_id"] == "2001"
assert result["task_code"] == "A1000"
assert result["task_type"] == "TT_Task"
assert result["driving_path_flag"] is True
assert result["total_float_hr_cnt"] == 0.0
def test_table_name(self) -> None:
"""Handler should report correct table name."""
from xer_mcp.parser.table_handlers.task import TaskHandler
handler = TaskHandler()
assert handler.table_name == "TASK"
def test_parse_early_dates(self) -> None:
"""Handler should parse early_start_date and early_end_date from TASK row."""
from xer_mcp.parser.table_handlers.task import TaskHandler
handler = TaskHandler()
fields = [
"task_id",
"proj_id",
"wbs_id",
"task_code",
"task_name",
"task_type",
"status_code",
"target_start_date",
"target_end_date",
"early_start_date",
"early_end_date",
"total_float_hr_cnt",
"driving_path_flag",
]
values = [
"2001",
"1001",
"100",
"A1000",
"Site Prep",
"TT_Task",
"TK_NotStart",
"2026-01-02 07:00",
"2026-01-08 15:00",
"2026-01-02 07:00",
"2026-01-08 15:00",
"0",
"Y",
]
result = handler.parse_row(fields, values)
assert result is not None
assert result["early_start_date"] == "2026-01-02T07:00:00"
assert result["early_end_date"] == "2026-01-08T15:00:00"
def test_parse_missing_early_dates(self) -> None:
"""Handler should handle missing early dates gracefully."""
from xer_mcp.parser.table_handlers.task import TaskHandler
handler = TaskHandler()
fields = [
"task_id",
"proj_id",
"task_code",
"task_name",
"task_type",
]
values = [
"2001",
"1001",
"A1000",
"Site Prep",
"TT_Task",
]
result = handler.parse_row(fields, values)
assert result is not None
assert result["early_start_date"] is None
assert result["early_end_date"] is None
def test_parse_milestone_type_start(self) -> None:
"""Handler should parse milestone_type='start' for start milestones."""
from xer_mcp.parser.table_handlers.task import TaskHandler
handler = TaskHandler()
fields = [
"task_id",
"proj_id",
"task_code",
"task_name",
"task_type",
"milestone_type",
]
values = [
"2001",
"1001",
"MS-START",
"Project Start",
"TT_Mile",
"MS_Start",
]
result = handler.parse_row(fields, values)
assert result is not None
assert result["task_type"] == "TT_Mile"
assert result["milestone_type"] == "start"
def test_parse_milestone_type_finish(self) -> None:
"""Handler should parse milestone_type='finish' for finish milestones."""
from xer_mcp.parser.table_handlers.task import TaskHandler
handler = TaskHandler()
fields = [
"task_id",
"proj_id",
"task_code",
"task_name",
"task_type",
"milestone_type",
]
values = [
"2002",
"1001",
"MS-END",
"Project Complete",
"TT_Mile",
"MS_Finish",
]
result = handler.parse_row(fields, values)
assert result is not None
assert result["task_type"] == "TT_Mile"
assert result["milestone_type"] == "finish"
def test_parse_milestone_type_null_for_non_milestones(self) -> None:
"""Handler should return None for milestone_type on non-milestone activities."""
from xer_mcp.parser.table_handlers.task import TaskHandler
handler = TaskHandler()
fields = [
"task_id",
"proj_id",
"task_code",
"task_name",
"task_type",
]
values = [
"2003",
"1001",
"A1000",
"Regular Task",
"TT_Task",
]
result = handler.parse_row(fields, values)
assert result is not None
assert result["task_type"] == "TT_Task"
assert result["milestone_type"] is None
def test_parse_milestone_type_derived_from_tt_mile(self) -> None:
"""Handler should derive milestone_type='start' from task_type TT_Mile."""
from xer_mcp.parser.table_handlers.task import TaskHandler
handler = TaskHandler()
# No explicit milestone_type field - derive from task_type
fields = [
"task_id",
"proj_id",
"task_code",
"task_name",
"task_type",
]
values = [
"2001",
"1001",
"MS-START",
"Project Start",
"TT_Mile",
]
result = handler.parse_row(fields, values)
assert result is not None
assert result["task_type"] == "TT_Mile"
assert result["milestone_type"] == "start"
def test_parse_milestone_type_derived_from_tt_finmile(self) -> None:
"""Handler should derive milestone_type='finish' from task_type TT_FinMile."""
from xer_mcp.parser.table_handlers.task import TaskHandler
handler = TaskHandler()
# TT_FinMile is a finish milestone
fields = [
"task_id",
"proj_id",
"task_code",
"task_name",
"task_type",
]
values = [
"2002",
"1001",
"MS-END",
"Project Complete",
"TT_FinMile",
]
result = handler.parse_row(fields, values)
assert result is not None
assert result["task_type"] == "TT_FinMile"
assert result["milestone_type"] == "finish"
class TestTaskpredHandler:
"""Tests for TASKPRED table handler."""
def test_parse_relationship_row(self) -> None:
"""Handler should parse TASKPRED row correctly."""
from xer_mcp.parser.table_handlers.taskpred import TaskpredHandler
handler = TaskpredHandler()
fields = [
"task_pred_id",
"task_id",
"pred_task_id",
"proj_id",
"pred_proj_id",
"pred_type",
"lag_hr_cnt",
]
values = ["3001", "2002", "2001", "1001", "1001", "PR_FS", "8"]
result = handler.parse_row(fields, values)
assert result is not None
assert result["task_pred_id"] == "3001"
assert result["task_id"] == "2002"
assert result["pred_task_id"] == "2001"
assert result["pred_type"] == "PR_FS"
assert result["lag_hr_cnt"] == 8.0
def test_table_name(self) -> None:
"""Handler should report correct table name."""
from xer_mcp.parser.table_handlers.taskpred import TaskpredHandler
handler = TaskpredHandler()
assert handler.table_name == "TASKPRED"
class TestProjwbsHandler:
"""Tests for PROJWBS table handler."""
def test_parse_wbs_row(self) -> None:
"""Handler should parse PROJWBS row correctly."""
from xer_mcp.parser.table_handlers.projwbs import ProjwbsHandler
handler = ProjwbsHandler()
fields = [
"wbs_id",
"proj_id",
"parent_wbs_id",
"wbs_short_name",
"wbs_name",
]
values = ["100", "1001", "", "ROOT", "Project Root"]
result = handler.parse_row(fields, values)
assert result is not None
assert result["wbs_id"] == "100"
assert result["proj_id"] == "1001"
assert result["parent_wbs_id"] == ""
assert result["wbs_short_name"] == "ROOT"
def test_table_name(self) -> None:
"""Handler should report correct table name."""
from xer_mcp.parser.table_handlers.projwbs import ProjwbsHandler
handler = ProjwbsHandler()
assert handler.table_name == "PROJWBS"
class TestCalendarHandler:
"""Tests for CALENDAR table handler."""
def test_parse_calendar_row(self) -> None:
"""Handler should parse CALENDAR row correctly."""
from xer_mcp.parser.table_handlers.calendar import CalendarHandler
handler = CalendarHandler()
fields = [
"clndr_id",
"clndr_name",
"day_hr_cnt",
"week_hr_cnt",
]
values = ["1", "Standard 5 Day", "8", "40"]
result = handler.parse_row(fields, values)
assert result is not None
assert result["clndr_id"] == "1"
assert result["clndr_name"] == "Standard 5 Day"
assert result["day_hr_cnt"] == 8.0
assert result["week_hr_cnt"] == 40.0
def test_table_name(self) -> None:
"""Handler should report correct table name."""
from xer_mcp.parser.table_handlers.calendar import CalendarHandler
handler = CalendarHandler()
assert handler.table_name == "CALENDAR"

601
uv.lock generated Normal file
View File

@@ -0,0 +1,601 @@
version = 1
revision = 3
requires-python = ">=3.14"
[[package]]
name = "annotated-types"
version = "0.7.0"
source = { registry = "https://pypi.org/simple" }
sdist = { url = "https://files.pythonhosted.org/packages/ee/67/531ea369ba64dcff5ec9c3402f9f51bf748cec26dde048a2f973a4eea7f5/annotated_types-0.7.0.tar.gz", hash = "sha256:aff07c09a53a08bc8cfccb9c85b05f1aa9a2a6f23728d790723543408344ce89", size = 16081, upload-time = "2024-05-20T21:33:25.928Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/78/b6/6307fbef88d9b5ee7421e68d78a9f162e0da4900bc5f5793f6d3d0e34fb8/annotated_types-0.7.0-py3-none-any.whl", hash = "sha256:1f02e8b43a8fbbc3f3e0d4f0f4bfc8131bcb4eebe8849b8e5c773f3a1c582a53", size = 13643, upload-time = "2024-05-20T21:33:24.1Z" },
]
[[package]]
name = "anyio"
version = "4.12.1"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "idna" },
]
sdist = { url = "https://files.pythonhosted.org/packages/96/f0/5eb65b2bb0d09ac6776f2eb54adee6abe8228ea05b20a5ad0e4945de8aac/anyio-4.12.1.tar.gz", hash = "sha256:41cfcc3a4c85d3f05c932da7c26d0201ac36f72abd4435ba90d0464a3ffed703", size = 228685, upload-time = "2026-01-06T11:45:21.246Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/38/0e/27be9fdef66e72d64c0cdc3cc2823101b80585f8119b5c112c2e8f5f7dab/anyio-4.12.1-py3-none-any.whl", hash = "sha256:d405828884fc140aa80a3c667b8beed277f1dfedec42ba031bd6ac3db606ab6c", size = 113592, upload-time = "2026-01-06T11:45:19.497Z" },
]
[[package]]
name = "attrs"
version = "25.4.0"
source = { registry = "https://pypi.org/simple" }
sdist = { url = "https://files.pythonhosted.org/packages/6b/5c/685e6633917e101e5dcb62b9dd76946cbb57c26e133bae9e0cd36033c0a9/attrs-25.4.0.tar.gz", hash = "sha256:16d5969b87f0859ef33a48b35d55ac1be6e42ae49d5e853b597db70c35c57e11", size = 934251, upload-time = "2025-10-06T13:54:44.725Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/3a/2a/7cc015f5b9f5db42b7d48157e23356022889fc354a2813c15934b7cb5c0e/attrs-25.4.0-py3-none-any.whl", hash = "sha256:adcf7e2a1fb3b36ac48d97835bb6d8ade15b8dcce26aba8bf1d14847b57a3373", size = 67615, upload-time = "2025-10-06T13:54:43.17Z" },
]
[[package]]
name = "certifi"
version = "2026.1.4"
source = { registry = "https://pypi.org/simple" }
sdist = { url = "https://files.pythonhosted.org/packages/e0/2d/a891ca51311197f6ad14a7ef42e2399f36cf2f9bd44752b3dc4eab60fdc5/certifi-2026.1.4.tar.gz", hash = "sha256:ac726dd470482006e014ad384921ed6438c457018f4b3d204aea4281258b2120", size = 154268, upload-time = "2026-01-04T02:42:41.825Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/e6/ad/3cc14f097111b4de0040c83a525973216457bbeeb63739ef1ed275c1c021/certifi-2026.1.4-py3-none-any.whl", hash = "sha256:9943707519e4add1115f44c2bc244f782c0249876bf51b6599fee1ffbedd685c", size = 152900, upload-time = "2026-01-04T02:42:40.15Z" },
]
[[package]]
name = "cffi"
version = "2.0.0"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "pycparser", marker = "implementation_name != 'PyPy'" },
]
sdist = { url = "https://files.pythonhosted.org/packages/eb/56/b1ba7935a17738ae8453301356628e8147c79dbb825bcbc73dc7401f9846/cffi-2.0.0.tar.gz", hash = "sha256:44d1b5909021139fe36001ae048dbdde8214afa20200eda0f64c068cac5d5529", size = 523588, upload-time = "2025-09-08T23:24:04.541Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/92/c4/3ce07396253a83250ee98564f8d7e9789fab8e58858f35d07a9a2c78de9f/cffi-2.0.0-cp314-cp314-macosx_10_13_x86_64.whl", hash = "sha256:fc33c5141b55ed366cfaad382df24fe7dcbc686de5be719b207bb248e3053dc5", size = 185320, upload-time = "2025-09-08T23:23:18.087Z" },
{ url = "https://files.pythonhosted.org/packages/59/dd/27e9fa567a23931c838c6b02d0764611c62290062a6d4e8ff7863daf9730/cffi-2.0.0-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:c654de545946e0db659b3400168c9ad31b5d29593291482c43e3564effbcee13", size = 181487, upload-time = "2025-09-08T23:23:19.622Z" },
{ url = "https://files.pythonhosted.org/packages/d6/43/0e822876f87ea8a4ef95442c3d766a06a51fc5298823f884ef87aaad168c/cffi-2.0.0-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:24b6f81f1983e6df8db3adc38562c83f7d4a0c36162885ec7f7b77c7dcbec97b", size = 220049, upload-time = "2025-09-08T23:23:20.853Z" },
{ url = "https://files.pythonhosted.org/packages/b4/89/76799151d9c2d2d1ead63c2429da9ea9d7aac304603de0c6e8764e6e8e70/cffi-2.0.0-cp314-cp314-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:12873ca6cb9b0f0d3a0da705d6086fe911591737a59f28b7936bdfed27c0d47c", size = 207793, upload-time = "2025-09-08T23:23:22.08Z" },
{ url = "https://files.pythonhosted.org/packages/bb/dd/3465b14bb9e24ee24cb88c9e3730f6de63111fffe513492bf8c808a3547e/cffi-2.0.0-cp314-cp314-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:d9b97165e8aed9272a6bb17c01e3cc5871a594a446ebedc996e2397a1c1ea8ef", size = 206300, upload-time = "2025-09-08T23:23:23.314Z" },
{ url = "https://files.pythonhosted.org/packages/47/d9/d83e293854571c877a92da46fdec39158f8d7e68da75bf73581225d28e90/cffi-2.0.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:afb8db5439b81cf9c9d0c80404b60c3cc9c3add93e114dcae767f1477cb53775", size = 219244, upload-time = "2025-09-08T23:23:24.541Z" },
{ url = "https://files.pythonhosted.org/packages/2b/0f/1f177e3683aead2bb00f7679a16451d302c436b5cbf2505f0ea8146ef59e/cffi-2.0.0-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:737fe7d37e1a1bffe70bd5754ea763a62a066dc5913ca57e957824b72a85e205", size = 222828, upload-time = "2025-09-08T23:23:26.143Z" },
{ url = "https://files.pythonhosted.org/packages/c6/0f/cafacebd4b040e3119dcb32fed8bdef8dfe94da653155f9d0b9dc660166e/cffi-2.0.0-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:38100abb9d1b1435bc4cc340bb4489635dc2f0da7456590877030c9b3d40b0c1", size = 220926, upload-time = "2025-09-08T23:23:27.873Z" },
{ url = "https://files.pythonhosted.org/packages/3e/aa/df335faa45b395396fcbc03de2dfcab242cd61a9900e914fe682a59170b1/cffi-2.0.0-cp314-cp314-win32.whl", hash = "sha256:087067fa8953339c723661eda6b54bc98c5625757ea62e95eb4898ad5e776e9f", size = 175328, upload-time = "2025-09-08T23:23:44.61Z" },
{ url = "https://files.pythonhosted.org/packages/bb/92/882c2d30831744296ce713f0feb4c1cd30f346ef747b530b5318715cc367/cffi-2.0.0-cp314-cp314-win_amd64.whl", hash = "sha256:203a48d1fb583fc7d78a4c6655692963b860a417c0528492a6bc21f1aaefab25", size = 185650, upload-time = "2025-09-08T23:23:45.848Z" },
{ url = "https://files.pythonhosted.org/packages/9f/2c/98ece204b9d35a7366b5b2c6539c350313ca13932143e79dc133ba757104/cffi-2.0.0-cp314-cp314-win_arm64.whl", hash = "sha256:dbd5c7a25a7cb98f5ca55d258b103a2054f859a46ae11aaf23134f9cc0d356ad", size = 180687, upload-time = "2025-09-08T23:23:47.105Z" },
{ url = "https://files.pythonhosted.org/packages/3e/61/c768e4d548bfa607abcda77423448df8c471f25dbe64fb2ef6d555eae006/cffi-2.0.0-cp314-cp314t-macosx_10_13_x86_64.whl", hash = "sha256:9a67fc9e8eb39039280526379fb3a70023d77caec1852002b4da7e8b270c4dd9", size = 188773, upload-time = "2025-09-08T23:23:29.347Z" },
{ url = "https://files.pythonhosted.org/packages/2c/ea/5f76bce7cf6fcd0ab1a1058b5af899bfbef198bea4d5686da88471ea0336/cffi-2.0.0-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:7a66c7204d8869299919db4d5069a82f1561581af12b11b3c9f48c584eb8743d", size = 185013, upload-time = "2025-09-08T23:23:30.63Z" },
{ url = "https://files.pythonhosted.org/packages/be/b4/c56878d0d1755cf9caa54ba71e5d049479c52f9e4afc230f06822162ab2f/cffi-2.0.0-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:7cc09976e8b56f8cebd752f7113ad07752461f48a58cbba644139015ac24954c", size = 221593, upload-time = "2025-09-08T23:23:31.91Z" },
{ url = "https://files.pythonhosted.org/packages/e0/0d/eb704606dfe8033e7128df5e90fee946bbcb64a04fcdaa97321309004000/cffi-2.0.0-cp314-cp314t-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:92b68146a71df78564e4ef48af17551a5ddd142e5190cdf2c5624d0c3ff5b2e8", size = 209354, upload-time = "2025-09-08T23:23:33.214Z" },
{ url = "https://files.pythonhosted.org/packages/d8/19/3c435d727b368ca475fb8742ab97c9cb13a0de600ce86f62eab7fa3eea60/cffi-2.0.0-cp314-cp314t-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:b1e74d11748e7e98e2f426ab176d4ed720a64412b6a15054378afdb71e0f37dc", size = 208480, upload-time = "2025-09-08T23:23:34.495Z" },
{ url = "https://files.pythonhosted.org/packages/d0/44/681604464ed9541673e486521497406fadcc15b5217c3e326b061696899a/cffi-2.0.0-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:28a3a209b96630bca57cce802da70c266eb08c6e97e5afd61a75611ee6c64592", size = 221584, upload-time = "2025-09-08T23:23:36.096Z" },
{ url = "https://files.pythonhosted.org/packages/25/8e/342a504ff018a2825d395d44d63a767dd8ebc927ebda557fecdaca3ac33a/cffi-2.0.0-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:7553fb2090d71822f02c629afe6042c299edf91ba1bf94951165613553984512", size = 224443, upload-time = "2025-09-08T23:23:37.328Z" },
{ url = "https://files.pythonhosted.org/packages/e1/5e/b666bacbbc60fbf415ba9988324a132c9a7a0448a9a8f125074671c0f2c3/cffi-2.0.0-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:6c6c373cfc5c83a975506110d17457138c8c63016b563cc9ed6e056a82f13ce4", size = 223437, upload-time = "2025-09-08T23:23:38.945Z" },
{ url = "https://files.pythonhosted.org/packages/a0/1d/ec1a60bd1a10daa292d3cd6bb0b359a81607154fb8165f3ec95fe003b85c/cffi-2.0.0-cp314-cp314t-win32.whl", hash = "sha256:1fc9ea04857caf665289b7a75923f2c6ed559b8298a1b8c49e59f7dd95c8481e", size = 180487, upload-time = "2025-09-08T23:23:40.423Z" },
{ url = "https://files.pythonhosted.org/packages/bf/41/4c1168c74fac325c0c8156f04b6749c8b6a8f405bbf91413ba088359f60d/cffi-2.0.0-cp314-cp314t-win_amd64.whl", hash = "sha256:d68b6cef7827e8641e8ef16f4494edda8b36104d79773a334beaa1e3521430f6", size = 191726, upload-time = "2025-09-08T23:23:41.742Z" },
{ url = "https://files.pythonhosted.org/packages/ae/3a/dbeec9d1ee0844c679f6bb5d6ad4e9f198b1224f4e7a32825f47f6192b0c/cffi-2.0.0-cp314-cp314t-win_arm64.whl", hash = "sha256:0a1527a803f0a659de1af2e1fd700213caba79377e27e4693648c2923da066f9", size = 184195, upload-time = "2025-09-08T23:23:43.004Z" },
]
[[package]]
name = "click"
version = "8.3.1"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "colorama", marker = "sys_platform == 'win32'" },
]
sdist = { url = "https://files.pythonhosted.org/packages/3d/fa/656b739db8587d7b5dfa22e22ed02566950fbfbcdc20311993483657a5c0/click-8.3.1.tar.gz", hash = "sha256:12ff4785d337a1bb490bb7e9c2b1ee5da3112e94a8622f26a6c77f5d2fc6842a", size = 295065, upload-time = "2025-11-15T20:45:42.706Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/98/78/01c019cdb5d6498122777c1a43056ebb3ebfeef2076d9d026bfe15583b2b/click-8.3.1-py3-none-any.whl", hash = "sha256:981153a64e25f12d547d3426c367a4857371575ee7ad18df2a6183ab0545b2a6", size = 108274, upload-time = "2025-11-15T20:45:41.139Z" },
]
[[package]]
name = "colorama"
version = "0.4.6"
source = { registry = "https://pypi.org/simple" }
sdist = { url = "https://files.pythonhosted.org/packages/d8/53/6f443c9a4a8358a93a6792e2acffb9d9d5cb0a5cfd8802644b7b1c9a02e4/colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44", size = 27697, upload-time = "2022-10-25T02:36:22.414Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6", size = 25335, upload-time = "2022-10-25T02:36:20.889Z" },
]
[[package]]
name = "cryptography"
version = "46.0.3"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "cffi", marker = "platform_python_implementation != 'PyPy'" },
]
sdist = { url = "https://files.pythonhosted.org/packages/9f/33/c00162f49c0e2fe8064a62cb92b93e50c74a72bc370ab92f86112b33ff62/cryptography-46.0.3.tar.gz", hash = "sha256:a8b17438104fed022ce745b362294d9ce35b4c2e45c1d958ad4a4b019285f4a1", size = 749258, upload-time = "2025-10-15T23:18:31.74Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/1d/42/9c391dd801d6cf0d561b5890549d4b27bafcc53b39c31a817e69d87c625b/cryptography-46.0.3-cp311-abi3-macosx_10_9_universal2.whl", hash = "sha256:109d4ddfadf17e8e7779c39f9b18111a09efb969a301a31e987416a0191ed93a", size = 7225004, upload-time = "2025-10-15T23:16:52.239Z" },
{ url = "https://files.pythonhosted.org/packages/1c/67/38769ca6b65f07461eb200e85fc1639b438bdc667be02cf7f2cd6a64601c/cryptography-46.0.3-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:09859af8466b69bc3c27bdf4f5d84a665e0f7ab5088412e9e2ec49758eca5cbc", size = 4296667, upload-time = "2025-10-15T23:16:54.369Z" },
{ url = "https://files.pythonhosted.org/packages/5c/49/498c86566a1d80e978b42f0d702795f69887005548c041636df6ae1ca64c/cryptography-46.0.3-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:01ca9ff2885f3acc98c29f1860552e37f6d7c7d013d7334ff2a9de43a449315d", size = 4450807, upload-time = "2025-10-15T23:16:56.414Z" },
{ url = "https://files.pythonhosted.org/packages/4b/0a/863a3604112174c8624a2ac3c038662d9e59970c7f926acdcfaed8d61142/cryptography-46.0.3-cp311-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:6eae65d4c3d33da080cff9c4ab1f711b15c1d9760809dad6ea763f3812d254cb", size = 4299615, upload-time = "2025-10-15T23:16:58.442Z" },
{ url = "https://files.pythonhosted.org/packages/64/02/b73a533f6b64a69f3cd3872acb6ebc12aef924d8d103133bb3ea750dc703/cryptography-46.0.3-cp311-abi3-manylinux_2_28_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:e5bf0ed4490068a2e72ac03d786693adeb909981cc596425d09032d372bcc849", size = 4016800, upload-time = "2025-10-15T23:17:00.378Z" },
{ url = "https://files.pythonhosted.org/packages/25/d5/16e41afbfa450cde85a3b7ec599bebefaef16b5c6ba4ec49a3532336ed72/cryptography-46.0.3-cp311-abi3-manylinux_2_28_ppc64le.whl", hash = "sha256:5ecfccd2329e37e9b7112a888e76d9feca2347f12f37918facbb893d7bb88ee8", size = 4984707, upload-time = "2025-10-15T23:17:01.98Z" },
{ url = "https://files.pythonhosted.org/packages/c9/56/e7e69b427c3878352c2fb9b450bd0e19ed552753491d39d7d0a2f5226d41/cryptography-46.0.3-cp311-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:a2c0cd47381a3229c403062f764160d57d4d175e022c1df84e168c6251a22eec", size = 4482541, upload-time = "2025-10-15T23:17:04.078Z" },
{ url = "https://files.pythonhosted.org/packages/78/f6/50736d40d97e8483172f1bb6e698895b92a223dba513b0ca6f06b2365339/cryptography-46.0.3-cp311-abi3-manylinux_2_34_aarch64.whl", hash = "sha256:549e234ff32571b1f4076ac269fcce7a808d3bf98b76c8dd560e42dbc66d7d91", size = 4299464, upload-time = "2025-10-15T23:17:05.483Z" },
{ url = "https://files.pythonhosted.org/packages/00/de/d8e26b1a855f19d9994a19c702fa2e93b0456beccbcfe437eda00e0701f2/cryptography-46.0.3-cp311-abi3-manylinux_2_34_ppc64le.whl", hash = "sha256:c0a7bb1a68a5d3471880e264621346c48665b3bf1c3759d682fc0864c540bd9e", size = 4950838, upload-time = "2025-10-15T23:17:07.425Z" },
{ url = "https://files.pythonhosted.org/packages/8f/29/798fc4ec461a1c9e9f735f2fc58741b0daae30688f41b2497dcbc9ed1355/cryptography-46.0.3-cp311-abi3-manylinux_2_34_x86_64.whl", hash = "sha256:10b01676fc208c3e6feeb25a8b83d81767e8059e1fe86e1dc62d10a3018fa926", size = 4481596, upload-time = "2025-10-15T23:17:09.343Z" },
{ url = "https://files.pythonhosted.org/packages/15/8d/03cd48b20a573adfff7652b76271078e3045b9f49387920e7f1f631d125e/cryptography-46.0.3-cp311-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:0abf1ffd6e57c67e92af68330d05760b7b7efb243aab8377e583284dbab72c71", size = 4426782, upload-time = "2025-10-15T23:17:11.22Z" },
{ url = "https://files.pythonhosted.org/packages/fa/b1/ebacbfe53317d55cf33165bda24c86523497a6881f339f9aae5c2e13e57b/cryptography-46.0.3-cp311-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:a04bee9ab6a4da801eb9b51f1b708a1b5b5c9eb48c03f74198464c66f0d344ac", size = 4698381, upload-time = "2025-10-15T23:17:12.829Z" },
{ url = "https://files.pythonhosted.org/packages/96/92/8a6a9525893325fc057a01f654d7efc2c64b9de90413adcf605a85744ff4/cryptography-46.0.3-cp311-abi3-win32.whl", hash = "sha256:f260d0d41e9b4da1ed1e0f1ce571f97fe370b152ab18778e9e8f67d6af432018", size = 3055988, upload-time = "2025-10-15T23:17:14.65Z" },
{ url = "https://files.pythonhosted.org/packages/7e/bf/80fbf45253ea585a1e492a6a17efcb93467701fa79e71550a430c5e60df0/cryptography-46.0.3-cp311-abi3-win_amd64.whl", hash = "sha256:a9a3008438615669153eb86b26b61e09993921ebdd75385ddd748702c5adfddb", size = 3514451, upload-time = "2025-10-15T23:17:16.142Z" },
{ url = "https://files.pythonhosted.org/packages/2e/af/9b302da4c87b0beb9db4e756386a7c6c5b8003cd0e742277888d352ae91d/cryptography-46.0.3-cp311-abi3-win_arm64.whl", hash = "sha256:5d7f93296ee28f68447397bf5198428c9aeeab45705a55d53a6343455dcb2c3c", size = 2928007, upload-time = "2025-10-15T23:17:18.04Z" },
{ url = "https://files.pythonhosted.org/packages/f5/e2/a510aa736755bffa9d2f75029c229111a1d02f8ecd5de03078f4c18d91a3/cryptography-46.0.3-cp314-cp314t-macosx_10_9_universal2.whl", hash = "sha256:00a5e7e87938e5ff9ff5447ab086a5706a957137e6e433841e9d24f38a065217", size = 7158012, upload-time = "2025-10-15T23:17:19.982Z" },
{ url = "https://files.pythonhosted.org/packages/73/dc/9aa866fbdbb95b02e7f9d086f1fccfeebf8953509b87e3f28fff927ff8a0/cryptography-46.0.3-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:c8daeb2d2174beb4575b77482320303f3d39b8e81153da4f0fb08eb5fe86a6c5", size = 4288728, upload-time = "2025-10-15T23:17:21.527Z" },
{ url = "https://files.pythonhosted.org/packages/c5/fd/bc1daf8230eaa075184cbbf5f8cd00ba9db4fd32d63fb83da4671b72ed8a/cryptography-46.0.3-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:39b6755623145ad5eff1dab323f4eae2a32a77a7abef2c5089a04a3d04366715", size = 4435078, upload-time = "2025-10-15T23:17:23.042Z" },
{ url = "https://files.pythonhosted.org/packages/82/98/d3bd5407ce4c60017f8ff9e63ffee4200ab3e23fe05b765cab805a7db008/cryptography-46.0.3-cp314-cp314t-manylinux_2_28_aarch64.whl", hash = "sha256:db391fa7c66df6762ee3f00c95a89e6d428f4d60e7abc8328f4fe155b5ac6e54", size = 4293460, upload-time = "2025-10-15T23:17:24.885Z" },
{ url = "https://files.pythonhosted.org/packages/26/e9/e23e7900983c2b8af7a08098db406cf989d7f09caea7897e347598d4cd5b/cryptography-46.0.3-cp314-cp314t-manylinux_2_28_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:78a97cf6a8839a48c49271cdcbd5cf37ca2c1d6b7fdd86cc864f302b5e9bf459", size = 3995237, upload-time = "2025-10-15T23:17:26.449Z" },
{ url = "https://files.pythonhosted.org/packages/91/15/af68c509d4a138cfe299d0d7ddb14afba15233223ebd933b4bbdbc7155d3/cryptography-46.0.3-cp314-cp314t-manylinux_2_28_ppc64le.whl", hash = "sha256:dfb781ff7eaa91a6f7fd41776ec37c5853c795d3b358d4896fdbb5df168af422", size = 4967344, upload-time = "2025-10-15T23:17:28.06Z" },
{ url = "https://files.pythonhosted.org/packages/ca/e3/8643d077c53868b681af077edf6b3cb58288b5423610f21c62aadcbe99f4/cryptography-46.0.3-cp314-cp314t-manylinux_2_28_x86_64.whl", hash = "sha256:6f61efb26e76c45c4a227835ddeae96d83624fb0d29eb5df5b96e14ed1a0afb7", size = 4466564, upload-time = "2025-10-15T23:17:29.665Z" },
{ url = "https://files.pythonhosted.org/packages/0e/43/c1e8726fa59c236ff477ff2b5dc071e54b21e5a1e51aa2cee1676f1c986f/cryptography-46.0.3-cp314-cp314t-manylinux_2_34_aarch64.whl", hash = "sha256:23b1a8f26e43f47ceb6d6a43115f33a5a37d57df4ea0ca295b780ae8546e8044", size = 4292415, upload-time = "2025-10-15T23:17:31.686Z" },
{ url = "https://files.pythonhosted.org/packages/42/f9/2f8fefdb1aee8a8e3256a0568cffc4e6d517b256a2fe97a029b3f1b9fe7e/cryptography-46.0.3-cp314-cp314t-manylinux_2_34_ppc64le.whl", hash = "sha256:b419ae593c86b87014b9be7396b385491ad7f320bde96826d0dd174459e54665", size = 4931457, upload-time = "2025-10-15T23:17:33.478Z" },
{ url = "https://files.pythonhosted.org/packages/79/30/9b54127a9a778ccd6d27c3da7563e9f2d341826075ceab89ae3b41bf5be2/cryptography-46.0.3-cp314-cp314t-manylinux_2_34_x86_64.whl", hash = "sha256:50fc3343ac490c6b08c0cf0d704e881d0d660be923fd3076db3e932007e726e3", size = 4466074, upload-time = "2025-10-15T23:17:35.158Z" },
{ url = "https://files.pythonhosted.org/packages/ac/68/b4f4a10928e26c941b1b6a179143af9f4d27d88fe84a6a3c53592d2e76bf/cryptography-46.0.3-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:22d7e97932f511d6b0b04f2bfd818d73dcd5928db509460aaf48384778eb6d20", size = 4420569, upload-time = "2025-10-15T23:17:37.188Z" },
{ url = "https://files.pythonhosted.org/packages/a3/49/3746dab4c0d1979888f125226357d3262a6dd40e114ac29e3d2abdf1ec55/cryptography-46.0.3-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:d55f3dffadd674514ad19451161118fd010988540cee43d8bc20675e775925de", size = 4681941, upload-time = "2025-10-15T23:17:39.236Z" },
{ url = "https://files.pythonhosted.org/packages/fd/30/27654c1dbaf7e4a3531fa1fc77986d04aefa4d6d78259a62c9dc13d7ad36/cryptography-46.0.3-cp314-cp314t-win32.whl", hash = "sha256:8a6e050cb6164d3f830453754094c086ff2d0b2f3a897a1d9820f6139a1f0914", size = 3022339, upload-time = "2025-10-15T23:17:40.888Z" },
{ url = "https://files.pythonhosted.org/packages/f6/30/640f34ccd4d2a1bc88367b54b926b781b5a018d65f404d409aba76a84b1c/cryptography-46.0.3-cp314-cp314t-win_amd64.whl", hash = "sha256:760f83faa07f8b64e9c33fc963d790a2edb24efb479e3520c14a45741cd9b2db", size = 3494315, upload-time = "2025-10-15T23:17:42.769Z" },
{ url = "https://files.pythonhosted.org/packages/ba/8b/88cc7e3bd0a8e7b861f26981f7b820e1f46aa9d26cc482d0feba0ecb4919/cryptography-46.0.3-cp314-cp314t-win_arm64.whl", hash = "sha256:516ea134e703e9fe26bcd1277a4b59ad30586ea90c365a87781d7887a646fe21", size = 2919331, upload-time = "2025-10-15T23:17:44.468Z" },
{ url = "https://files.pythonhosted.org/packages/fd/23/45fe7f376a7df8daf6da3556603b36f53475a99ce4faacb6ba2cf3d82021/cryptography-46.0.3-cp38-abi3-macosx_10_9_universal2.whl", hash = "sha256:cb3d760a6117f621261d662bccc8ef5bc32ca673e037c83fbe565324f5c46936", size = 7218248, upload-time = "2025-10-15T23:17:46.294Z" },
{ url = "https://files.pythonhosted.org/packages/27/32/b68d27471372737054cbd34c84981f9edbc24fe67ca225d389799614e27f/cryptography-46.0.3-cp38-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:4b7387121ac7d15e550f5cb4a43aef2559ed759c35df7336c402bb8275ac9683", size = 4294089, upload-time = "2025-10-15T23:17:48.269Z" },
{ url = "https://files.pythonhosted.org/packages/26/42/fa8389d4478368743e24e61eea78846a0006caffaf72ea24a15159215a14/cryptography-46.0.3-cp38-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:15ab9b093e8f09daab0f2159bb7e47532596075139dd74365da52ecc9cb46c5d", size = 4440029, upload-time = "2025-10-15T23:17:49.837Z" },
{ url = "https://files.pythonhosted.org/packages/5f/eb/f483db0ec5ac040824f269e93dd2bd8a21ecd1027e77ad7bdf6914f2fd80/cryptography-46.0.3-cp38-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:46acf53b40ea38f9c6c229599a4a13f0d46a6c3fa9ef19fc1a124d62e338dfa0", size = 4297222, upload-time = "2025-10-15T23:17:51.357Z" },
{ url = "https://files.pythonhosted.org/packages/fd/cf/da9502c4e1912cb1da3807ea3618a6829bee8207456fbbeebc361ec38ba3/cryptography-46.0.3-cp38-abi3-manylinux_2_28_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:10ca84c4668d066a9878890047f03546f3ae0a6b8b39b697457b7757aaf18dbc", size = 4012280, upload-time = "2025-10-15T23:17:52.964Z" },
{ url = "https://files.pythonhosted.org/packages/6b/8f/9adb86b93330e0df8b3dcf03eae67c33ba89958fc2e03862ef1ac2b42465/cryptography-46.0.3-cp38-abi3-manylinux_2_28_ppc64le.whl", hash = "sha256:36e627112085bb3b81b19fed209c05ce2a52ee8b15d161b7c643a7d5a88491f3", size = 4978958, upload-time = "2025-10-15T23:17:54.965Z" },
{ url = "https://files.pythonhosted.org/packages/d1/a0/5fa77988289c34bdb9f913f5606ecc9ada1adb5ae870bd0d1054a7021cc4/cryptography-46.0.3-cp38-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:1000713389b75c449a6e979ffc7dcc8ac90b437048766cef052d4d30b8220971", size = 4473714, upload-time = "2025-10-15T23:17:56.754Z" },
{ url = "https://files.pythonhosted.org/packages/14/e5/fc82d72a58d41c393697aa18c9abe5ae1214ff6f2a5c18ac470f92777895/cryptography-46.0.3-cp38-abi3-manylinux_2_34_aarch64.whl", hash = "sha256:b02cf04496f6576afffef5ddd04a0cb7d49cf6be16a9059d793a30b035f6b6ac", size = 4296970, upload-time = "2025-10-15T23:17:58.588Z" },
{ url = "https://files.pythonhosted.org/packages/78/06/5663ed35438d0b09056973994f1aec467492b33bd31da36e468b01ec1097/cryptography-46.0.3-cp38-abi3-manylinux_2_34_ppc64le.whl", hash = "sha256:71e842ec9bc7abf543b47cf86b9a743baa95f4677d22baa4c7d5c69e49e9bc04", size = 4940236, upload-time = "2025-10-15T23:18:00.897Z" },
{ url = "https://files.pythonhosted.org/packages/fc/59/873633f3f2dcd8a053b8dd1d38f783043b5fce589c0f6988bf55ef57e43e/cryptography-46.0.3-cp38-abi3-manylinux_2_34_x86_64.whl", hash = "sha256:402b58fc32614f00980b66d6e56a5b4118e6cb362ae8f3fda141ba4689bd4506", size = 4472642, upload-time = "2025-10-15T23:18:02.749Z" },
{ url = "https://files.pythonhosted.org/packages/3d/39/8e71f3930e40f6877737d6f69248cf74d4e34b886a3967d32f919cc50d3b/cryptography-46.0.3-cp38-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:ef639cb3372f69ec44915fafcd6698b6cc78fbe0c2ea41be867f6ed612811963", size = 4423126, upload-time = "2025-10-15T23:18:04.85Z" },
{ url = "https://files.pythonhosted.org/packages/cd/c7/f65027c2810e14c3e7268353b1681932b87e5a48e65505d8cc17c99e36ae/cryptography-46.0.3-cp38-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:3b51b8ca4f1c6453d8829e1eb7299499ca7f313900dd4d89a24b8b87c0a780d4", size = 4686573, upload-time = "2025-10-15T23:18:06.908Z" },
{ url = "https://files.pythonhosted.org/packages/0a/6e/1c8331ddf91ca4730ab3086a0f1be19c65510a33b5a441cb334e7a2d2560/cryptography-46.0.3-cp38-abi3-win32.whl", hash = "sha256:6276eb85ef938dc035d59b87c8a7dc559a232f954962520137529d77b18ff1df", size = 3036695, upload-time = "2025-10-15T23:18:08.672Z" },
{ url = "https://files.pythonhosted.org/packages/90/45/b0d691df20633eff80955a0fc7695ff9051ffce8b69741444bd9ed7bd0db/cryptography-46.0.3-cp38-abi3-win_amd64.whl", hash = "sha256:416260257577718c05135c55958b674000baef9a1c7d9e8f306ec60d71db850f", size = 3501720, upload-time = "2025-10-15T23:18:10.632Z" },
{ url = "https://files.pythonhosted.org/packages/e8/cb/2da4cc83f5edb9c3257d09e1e7ab7b23f049c7962cae8d842bbef0a9cec9/cryptography-46.0.3-cp38-abi3-win_arm64.whl", hash = "sha256:d89c3468de4cdc4f08a57e214384d0471911a3830fcdaf7a8cc587e42a866372", size = 2918740, upload-time = "2025-10-15T23:18:12.277Z" },
]
[[package]]
name = "h11"
version = "0.16.0"
source = { registry = "https://pypi.org/simple" }
sdist = { url = "https://files.pythonhosted.org/packages/01/ee/02a2c011bdab74c6fb3c75474d40b3052059d95df7e73351460c8588d963/h11-0.16.0.tar.gz", hash = "sha256:4e35b956cf45792e4caa5885e69fba00bdbc6ffafbfa020300e549b208ee5ff1", size = 101250, upload-time = "2025-04-24T03:35:25.427Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/04/4b/29cac41a4d98d144bf5f6d33995617b185d14b22401f75ca86f384e87ff1/h11-0.16.0-py3-none-any.whl", hash = "sha256:63cf8bbe7522de3bf65932fda1d9c2772064ffb3dae62d55932da54b31cb6c86", size = 37515, upload-time = "2025-04-24T03:35:24.344Z" },
]
[[package]]
name = "httpcore"
version = "1.0.9"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "certifi" },
{ name = "h11" },
]
sdist = { url = "https://files.pythonhosted.org/packages/06/94/82699a10bca87a5556c9c59b5963f2d039dbd239f25bc2a63907a05a14cb/httpcore-1.0.9.tar.gz", hash = "sha256:6e34463af53fd2ab5d807f399a9b45ea31c3dfa2276f15a2c3f00afff6e176e8", size = 85484, upload-time = "2025-04-24T22:06:22.219Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/7e/f5/f66802a942d491edb555dd61e3a9961140fd64c90bce1eafd741609d334d/httpcore-1.0.9-py3-none-any.whl", hash = "sha256:2d400746a40668fc9dec9810239072b40b4484b640a8c38fd654a024c7a1bf55", size = 78784, upload-time = "2025-04-24T22:06:20.566Z" },
]
[[package]]
name = "httpx"
version = "0.28.1"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "anyio" },
{ name = "certifi" },
{ name = "httpcore" },
{ name = "idna" },
]
sdist = { url = "https://files.pythonhosted.org/packages/b1/df/48c586a5fe32a0f01324ee087459e112ebb7224f646c0b5023f5e79e9956/httpx-0.28.1.tar.gz", hash = "sha256:75e98c5f16b0f35b567856f597f06ff2270a374470a5c2392242528e3e3e42fc", size = 141406, upload-time = "2024-12-06T15:37:23.222Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/2a/39/e50c7c3a983047577ee07d2a9e53faf5a69493943ec3f6a384bdc792deb2/httpx-0.28.1-py3-none-any.whl", hash = "sha256:d909fcccc110f8c7faf814ca82a9a4d816bc5a6dbfea25d6591d6985b8ba59ad", size = 73517, upload-time = "2024-12-06T15:37:21.509Z" },
]
[[package]]
name = "httpx-sse"
version = "0.4.3"
source = { registry = "https://pypi.org/simple" }
sdist = { url = "https://files.pythonhosted.org/packages/0f/4c/751061ffa58615a32c31b2d82e8482be8dd4a89154f003147acee90f2be9/httpx_sse-0.4.3.tar.gz", hash = "sha256:9b1ed0127459a66014aec3c56bebd93da3c1bc8bb6618c8082039a44889a755d", size = 15943, upload-time = "2025-10-10T21:48:22.271Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/d2/fd/6668e5aec43ab844de6fc74927e155a3b37bf40d7c3790e49fc0406b6578/httpx_sse-0.4.3-py3-none-any.whl", hash = "sha256:0ac1c9fe3c0afad2e0ebb25a934a59f4c7823b60792691f779fad2c5568830fc", size = 8960, upload-time = "2025-10-10T21:48:21.158Z" },
]
[[package]]
name = "idna"
version = "3.11"
source = { registry = "https://pypi.org/simple" }
sdist = { url = "https://files.pythonhosted.org/packages/6f/6d/0703ccc57f3a7233505399edb88de3cbd678da106337b9fcde432b65ed60/idna-3.11.tar.gz", hash = "sha256:795dafcc9c04ed0c1fb032c2aa73654d8e8c5023a7df64a53f39190ada629902", size = 194582, upload-time = "2025-10-12T14:55:20.501Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/0e/61/66938bbb5fc52dbdf84594873d5b51fb1f7c7794e9c0f5bd885f30bc507b/idna-3.11-py3-none-any.whl", hash = "sha256:771a87f49d9defaf64091e6e6fe9c18d4833f140bd19464795bc32d966ca37ea", size = 71008, upload-time = "2025-10-12T14:55:18.883Z" },
]
[[package]]
name = "iniconfig"
version = "2.3.0"
source = { registry = "https://pypi.org/simple" }
sdist = { url = "https://files.pythonhosted.org/packages/72/34/14ca021ce8e5dfedc35312d08ba8bf51fdd999c576889fc2c24cb97f4f10/iniconfig-2.3.0.tar.gz", hash = "sha256:c76315c77db068650d49c5b56314774a7804df16fee4402c1f19d6d15d8c4730", size = 20503, upload-time = "2025-10-18T21:55:43.219Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/cb/b1/3846dd7f199d53cb17f49cba7e651e9ce294d8497c8c150530ed11865bb8/iniconfig-2.3.0-py3-none-any.whl", hash = "sha256:f631c04d2c48c52b84d0d0549c99ff3859c98df65b3101406327ecc7d53fbf12", size = 7484, upload-time = "2025-10-18T21:55:41.639Z" },
]
[[package]]
name = "jsonschema"
version = "4.25.1"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "attrs" },
{ name = "jsonschema-specifications" },
{ name = "referencing" },
{ name = "rpds-py" },
]
sdist = { url = "https://files.pythonhosted.org/packages/74/69/f7185de793a29082a9f3c7728268ffb31cb5095131a9c139a74078e27336/jsonschema-4.25.1.tar.gz", hash = "sha256:e4a9655ce0da0c0b67a085847e00a3a51449e1157f4f75e9fb5aa545e122eb85", size = 357342, upload-time = "2025-08-18T17:03:50.038Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/bf/9c/8c95d856233c1f82500c2450b8c68576b4cf1c871db3afac5c34ff84e6fd/jsonschema-4.25.1-py3-none-any.whl", hash = "sha256:3fba0169e345c7175110351d456342c364814cfcf3b964ba4587f22915230a63", size = 90040, upload-time = "2025-08-18T17:03:48.373Z" },
]
[[package]]
name = "jsonschema-specifications"
version = "2025.9.1"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "referencing" },
]
sdist = { url = "https://files.pythonhosted.org/packages/19/74/a633ee74eb36c44aa6d1095e7cc5569bebf04342ee146178e2d36600708b/jsonschema_specifications-2025.9.1.tar.gz", hash = "sha256:b540987f239e745613c7a9176f3edb72b832a4ac465cf02712288397832b5e8d", size = 32855, upload-time = "2025-09-08T01:34:59.186Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/41/45/1a4ed80516f02155c51f51e8cedb3c1902296743db0bbc66608a0db2814f/jsonschema_specifications-2025.9.1-py3-none-any.whl", hash = "sha256:98802fee3a11ee76ecaca44429fda8a41bff98b00a0f2838151b113f210cc6fe", size = 18437, upload-time = "2025-09-08T01:34:57.871Z" },
]
[[package]]
name = "mcp"
version = "1.25.0"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "anyio" },
{ name = "httpx" },
{ name = "httpx-sse" },
{ name = "jsonschema" },
{ name = "pydantic" },
{ name = "pydantic-settings" },
{ name = "pyjwt", extra = ["crypto"] },
{ name = "python-multipart" },
{ name = "pywin32", marker = "sys_platform == 'win32'" },
{ name = "sse-starlette" },
{ name = "starlette" },
{ name = "typing-extensions" },
{ name = "typing-inspection" },
{ name = "uvicorn", marker = "sys_platform != 'emscripten'" },
]
sdist = { url = "https://files.pythonhosted.org/packages/d5/2d/649d80a0ecf6a1f82632ca44bec21c0461a9d9fc8934d38cb5b319f2db5e/mcp-1.25.0.tar.gz", hash = "sha256:56310361ebf0364e2d438e5b45f7668cbb124e158bb358333cd06e49e83a6802", size = 605387, upload-time = "2025-12-19T10:19:56.985Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/e2/fc/6dc7659c2ae5ddf280477011f4213a74f806862856b796ef08f028e664bf/mcp-1.25.0-py3-none-any.whl", hash = "sha256:b37c38144a666add0862614cc79ec276e97d72aa8ca26d622818d4e278b9721a", size = 233076, upload-time = "2025-12-19T10:19:55.416Z" },
]
[[package]]
name = "packaging"
version = "25.0"
source = { registry = "https://pypi.org/simple" }
sdist = { url = "https://files.pythonhosted.org/packages/a1/d4/1fc4078c65507b51b96ca8f8c3ba19e6a61c8253c72794544580a7b6c24d/packaging-25.0.tar.gz", hash = "sha256:d443872c98d677bf60f6a1f2f8c1cb748e8fe762d2bf9d3148b5599295b0fc4f", size = 165727, upload-time = "2025-04-19T11:48:59.673Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/20/12/38679034af332785aac8774540895e234f4d07f7545804097de4b666afd8/packaging-25.0-py3-none-any.whl", hash = "sha256:29572ef2b1f17581046b3a2227d5c611fb25ec70ca1ba8554b24b0e69331a484", size = 66469, upload-time = "2025-04-19T11:48:57.875Z" },
]
[[package]]
name = "pluggy"
version = "1.6.0"
source = { registry = "https://pypi.org/simple" }
sdist = { url = "https://files.pythonhosted.org/packages/f9/e2/3e91f31a7d2b083fe6ef3fa267035b518369d9511ffab804f839851d2779/pluggy-1.6.0.tar.gz", hash = "sha256:7dcc130b76258d33b90f61b658791dede3486c3e6bfb003ee5c9bfb396dd22f3", size = 69412, upload-time = "2025-05-15T12:30:07.975Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/54/20/4d324d65cc6d9205fabedc306948156824eb9f0ee1633355a8f7ec5c66bf/pluggy-1.6.0-py3-none-any.whl", hash = "sha256:e920276dd6813095e9377c0bc5566d94c932c33b27a3e3945d8389c374dd4746", size = 20538, upload-time = "2025-05-15T12:30:06.134Z" },
]
[[package]]
name = "pycparser"
version = "2.23"
source = { registry = "https://pypi.org/simple" }
sdist = { url = "https://files.pythonhosted.org/packages/fe/cf/d2d3b9f5699fb1e4615c8e32ff220203e43b248e1dfcc6736ad9057731ca/pycparser-2.23.tar.gz", hash = "sha256:78816d4f24add8f10a06d6f05b4d424ad9e96cfebf68a4ddc99c65c0720d00c2", size = 173734, upload-time = "2025-09-09T13:23:47.91Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/a0/e3/59cd50310fc9b59512193629e1984c1f95e5c8ae6e5d8c69532ccc65a7fe/pycparser-2.23-py3-none-any.whl", hash = "sha256:e5c6e8d3fbad53479cab09ac03729e0a9faf2bee3db8208a550daf5af81a5934", size = 118140, upload-time = "2025-09-09T13:23:46.651Z" },
]
[[package]]
name = "pydantic"
version = "2.12.5"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "annotated-types" },
{ name = "pydantic-core" },
{ name = "typing-extensions" },
{ name = "typing-inspection" },
]
sdist = { url = "https://files.pythonhosted.org/packages/69/44/36f1a6e523abc58ae5f928898e4aca2e0ea509b5aa6f6f392a5d882be928/pydantic-2.12.5.tar.gz", hash = "sha256:4d351024c75c0f085a9febbb665ce8c0c6ec5d30e903bdb6394b7ede26aebb49", size = 821591, upload-time = "2025-11-26T15:11:46.471Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/5a/87/b70ad306ebb6f9b585f114d0ac2137d792b48be34d732d60e597c2f8465a/pydantic-2.12.5-py3-none-any.whl", hash = "sha256:e561593fccf61e8a20fc46dfc2dfe075b8be7d0188df33f221ad1f0139180f9d", size = 463580, upload-time = "2025-11-26T15:11:44.605Z" },
]
[[package]]
name = "pydantic-core"
version = "2.41.5"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "typing-extensions" },
]
sdist = { url = "https://files.pythonhosted.org/packages/71/70/23b021c950c2addd24ec408e9ab05d59b035b39d97cdc1130e1bce647bb6/pydantic_core-2.41.5.tar.gz", hash = "sha256:08daa51ea16ad373ffd5e7606252cc32f07bc72b28284b6bc9c6df804816476e", size = 460952, upload-time = "2025-11-04T13:43:49.098Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/ea/28/46b7c5c9635ae96ea0fbb779e271a38129df2550f763937659ee6c5dbc65/pydantic_core-2.41.5-cp314-cp314-macosx_10_12_x86_64.whl", hash = "sha256:3f37a19d7ebcdd20b96485056ba9e8b304e27d9904d233d7b1015db320e51f0a", size = 2119622, upload-time = "2025-11-04T13:40:56.68Z" },
{ url = "https://files.pythonhosted.org/packages/74/1a/145646e5687e8d9a1e8d09acb278c8535ebe9e972e1f162ed338a622f193/pydantic_core-2.41.5-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:1d1d9764366c73f996edd17abb6d9d7649a7eb690006ab6adbda117717099b14", size = 1891725, upload-time = "2025-11-04T13:40:58.807Z" },
{ url = "https://files.pythonhosted.org/packages/23/04/e89c29e267b8060b40dca97bfc64a19b2a3cf99018167ea1677d96368273/pydantic_core-2.41.5-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:25e1c2af0fce638d5f1988b686f3b3ea8cd7de5f244ca147c777769e798a9cd1", size = 1915040, upload-time = "2025-11-04T13:41:00.853Z" },
{ url = "https://files.pythonhosted.org/packages/84/a3/15a82ac7bd97992a82257f777b3583d3e84bdb06ba6858f745daa2ec8a85/pydantic_core-2.41.5-cp314-cp314-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:506d766a8727beef16b7adaeb8ee6217c64fc813646b424d0804d67c16eddb66", size = 2063691, upload-time = "2025-11-04T13:41:03.504Z" },
{ url = "https://files.pythonhosted.org/packages/74/9b/0046701313c6ef08c0c1cf0e028c67c770a4e1275ca73131563c5f2a310a/pydantic_core-2.41.5-cp314-cp314-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:4819fa52133c9aa3c387b3328f25c1facc356491e6135b459f1de698ff64d869", size = 2213897, upload-time = "2025-11-04T13:41:05.804Z" },
{ url = "https://files.pythonhosted.org/packages/8a/cd/6bac76ecd1b27e75a95ca3a9a559c643b3afcd2dd62086d4b7a32a18b169/pydantic_core-2.41.5-cp314-cp314-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:2b761d210c9ea91feda40d25b4efe82a1707da2ef62901466a42492c028553a2", size = 2333302, upload-time = "2025-11-04T13:41:07.809Z" },
{ url = "https://files.pythonhosted.org/packages/4c/d2/ef2074dc020dd6e109611a8be4449b98cd25e1b9b8a303c2f0fca2f2bcf7/pydantic_core-2.41.5-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:22f0fb8c1c583a3b6f24df2470833b40207e907b90c928cc8d3594b76f874375", size = 2064877, upload-time = "2025-11-04T13:41:09.827Z" },
{ url = "https://files.pythonhosted.org/packages/18/66/e9db17a9a763d72f03de903883c057b2592c09509ccfe468187f2a2eef29/pydantic_core-2.41.5-cp314-cp314-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:2782c870e99878c634505236d81e5443092fba820f0373997ff75f90f68cd553", size = 2180680, upload-time = "2025-11-04T13:41:12.379Z" },
{ url = "https://files.pythonhosted.org/packages/d3/9e/3ce66cebb929f3ced22be85d4c2399b8e85b622db77dad36b73c5387f8f8/pydantic_core-2.41.5-cp314-cp314-musllinux_1_1_aarch64.whl", hash = "sha256:0177272f88ab8312479336e1d777f6b124537d47f2123f89cb37e0accea97f90", size = 2138960, upload-time = "2025-11-04T13:41:14.627Z" },
{ url = "https://files.pythonhosted.org/packages/a6/62/205a998f4327d2079326b01abee48e502ea739d174f0a89295c481a2272e/pydantic_core-2.41.5-cp314-cp314-musllinux_1_1_armv7l.whl", hash = "sha256:63510af5e38f8955b8ee5687740d6ebf7c2a0886d15a6d65c32814613681bc07", size = 2339102, upload-time = "2025-11-04T13:41:16.868Z" },
{ url = "https://files.pythonhosted.org/packages/3c/0d/f05e79471e889d74d3d88f5bd20d0ed189ad94c2423d81ff8d0000aab4ff/pydantic_core-2.41.5-cp314-cp314-musllinux_1_1_x86_64.whl", hash = "sha256:e56ba91f47764cc14f1daacd723e3e82d1a89d783f0f5afe9c364b8bb491ccdb", size = 2326039, upload-time = "2025-11-04T13:41:18.934Z" },
{ url = "https://files.pythonhosted.org/packages/ec/e1/e08a6208bb100da7e0c4b288eed624a703f4d129bde2da475721a80cab32/pydantic_core-2.41.5-cp314-cp314-win32.whl", hash = "sha256:aec5cf2fd867b4ff45b9959f8b20ea3993fc93e63c7363fe6851424c8a7e7c23", size = 1995126, upload-time = "2025-11-04T13:41:21.418Z" },
{ url = "https://files.pythonhosted.org/packages/48/5d/56ba7b24e9557f99c9237e29f5c09913c81eeb2f3217e40e922353668092/pydantic_core-2.41.5-cp314-cp314-win_amd64.whl", hash = "sha256:8e7c86f27c585ef37c35e56a96363ab8de4e549a95512445b85c96d3e2f7c1bf", size = 2015489, upload-time = "2025-11-04T13:41:24.076Z" },
{ url = "https://files.pythonhosted.org/packages/4e/bb/f7a190991ec9e3e0ba22e4993d8755bbc4a32925c0b5b42775c03e8148f9/pydantic_core-2.41.5-cp314-cp314-win_arm64.whl", hash = "sha256:e672ba74fbc2dc8eea59fb6d4aed6845e6905fc2a8afe93175d94a83ba2a01a0", size = 1977288, upload-time = "2025-11-04T13:41:26.33Z" },
{ url = "https://files.pythonhosted.org/packages/92/ed/77542d0c51538e32e15afe7899d79efce4b81eee631d99850edc2f5e9349/pydantic_core-2.41.5-cp314-cp314t-macosx_10_12_x86_64.whl", hash = "sha256:8566def80554c3faa0e65ac30ab0932b9e3a5cd7f8323764303d468e5c37595a", size = 2120255, upload-time = "2025-11-04T13:41:28.569Z" },
{ url = "https://files.pythonhosted.org/packages/bb/3d/6913dde84d5be21e284439676168b28d8bbba5600d838b9dca99de0fad71/pydantic_core-2.41.5-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:b80aa5095cd3109962a298ce14110ae16b8c1aece8b72f9dafe81cf597ad80b3", size = 1863760, upload-time = "2025-11-04T13:41:31.055Z" },
{ url = "https://files.pythonhosted.org/packages/5a/f0/e5e6b99d4191da102f2b0eb9687aaa7f5bea5d9964071a84effc3e40f997/pydantic_core-2.41.5-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3006c3dd9ba34b0c094c544c6006cc79e87d8612999f1a5d43b769b89181f23c", size = 1878092, upload-time = "2025-11-04T13:41:33.21Z" },
{ url = "https://files.pythonhosted.org/packages/71/48/36fb760642d568925953bcc8116455513d6e34c4beaa37544118c36aba6d/pydantic_core-2.41.5-cp314-cp314t-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:72f6c8b11857a856bcfa48c86f5368439f74453563f951e473514579d44aa612", size = 2053385, upload-time = "2025-11-04T13:41:35.508Z" },
{ url = "https://files.pythonhosted.org/packages/20/25/92dc684dd8eb75a234bc1c764b4210cf2646479d54b47bf46061657292a8/pydantic_core-2.41.5-cp314-cp314t-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:5cb1b2f9742240e4bb26b652a5aeb840aa4b417c7748b6f8387927bc6e45e40d", size = 2218832, upload-time = "2025-11-04T13:41:37.732Z" },
{ url = "https://files.pythonhosted.org/packages/e2/09/f53e0b05023d3e30357d82eb35835d0f6340ca344720a4599cd663dca599/pydantic_core-2.41.5-cp314-cp314t-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:bd3d54f38609ff308209bd43acea66061494157703364ae40c951f83ba99a1a9", size = 2327585, upload-time = "2025-11-04T13:41:40Z" },
{ url = "https://files.pythonhosted.org/packages/aa/4e/2ae1aa85d6af35a39b236b1b1641de73f5a6ac4d5a7509f77b814885760c/pydantic_core-2.41.5-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2ff4321e56e879ee8d2a879501c8e469414d948f4aba74a2d4593184eb326660", size = 2041078, upload-time = "2025-11-04T13:41:42.323Z" },
{ url = "https://files.pythonhosted.org/packages/cd/13/2e215f17f0ef326fc72afe94776edb77525142c693767fc347ed6288728d/pydantic_core-2.41.5-cp314-cp314t-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:d0d2568a8c11bf8225044aa94409e21da0cb09dcdafe9ecd10250b2baad531a9", size = 2173914, upload-time = "2025-11-04T13:41:45.221Z" },
{ url = "https://files.pythonhosted.org/packages/02/7a/f999a6dcbcd0e5660bc348a3991c8915ce6599f4f2c6ac22f01d7a10816c/pydantic_core-2.41.5-cp314-cp314t-musllinux_1_1_aarch64.whl", hash = "sha256:a39455728aabd58ceabb03c90e12f71fd30fa69615760a075b9fec596456ccc3", size = 2129560, upload-time = "2025-11-04T13:41:47.474Z" },
{ url = "https://files.pythonhosted.org/packages/3a/b1/6c990ac65e3b4c079a4fb9f5b05f5b013afa0f4ed6780a3dd236d2cbdc64/pydantic_core-2.41.5-cp314-cp314t-musllinux_1_1_armv7l.whl", hash = "sha256:239edca560d05757817c13dc17c50766136d21f7cd0fac50295499ae24f90fdf", size = 2329244, upload-time = "2025-11-04T13:41:49.992Z" },
{ url = "https://files.pythonhosted.org/packages/d9/02/3c562f3a51afd4d88fff8dffb1771b30cfdfd79befd9883ee094f5b6c0d8/pydantic_core-2.41.5-cp314-cp314t-musllinux_1_1_x86_64.whl", hash = "sha256:2a5e06546e19f24c6a96a129142a75cee553cc018ffee48a460059b1185f4470", size = 2331955, upload-time = "2025-11-04T13:41:54.079Z" },
{ url = "https://files.pythonhosted.org/packages/5c/96/5fb7d8c3c17bc8c62fdb031c47d77a1af698f1d7a406b0f79aaa1338f9ad/pydantic_core-2.41.5-cp314-cp314t-win32.whl", hash = "sha256:b4ececa40ac28afa90871c2cc2b9ffd2ff0bf749380fbdf57d165fd23da353aa", size = 1988906, upload-time = "2025-11-04T13:41:56.606Z" },
{ url = "https://files.pythonhosted.org/packages/22/ed/182129d83032702912c2e2d8bbe33c036f342cc735737064668585dac28f/pydantic_core-2.41.5-cp314-cp314t-win_amd64.whl", hash = "sha256:80aa89cad80b32a912a65332f64a4450ed00966111b6615ca6816153d3585a8c", size = 1981607, upload-time = "2025-11-04T13:41:58.889Z" },
{ url = "https://files.pythonhosted.org/packages/9f/ed/068e41660b832bb0b1aa5b58011dea2a3fe0ba7861ff38c4d4904c1c1a99/pydantic_core-2.41.5-cp314-cp314t-win_arm64.whl", hash = "sha256:35b44f37a3199f771c3eaa53051bc8a70cd7b54f333531c59e29fd4db5d15008", size = 1974769, upload-time = "2025-11-04T13:42:01.186Z" },
]
[[package]]
name = "pydantic-settings"
version = "2.12.0"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "pydantic" },
{ name = "python-dotenv" },
{ name = "typing-inspection" },
]
sdist = { url = "https://files.pythonhosted.org/packages/43/4b/ac7e0aae12027748076d72a8764ff1c9d82ca75a7a52622e67ed3f765c54/pydantic_settings-2.12.0.tar.gz", hash = "sha256:005538ef951e3c2a68e1c08b292b5f2e71490def8589d4221b95dab00dafcfd0", size = 194184, upload-time = "2025-11-10T14:25:47.013Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/c1/60/5d4751ba3f4a40a6891f24eec885f51afd78d208498268c734e256fb13c4/pydantic_settings-2.12.0-py3-none-any.whl", hash = "sha256:fddb9fd99a5b18da837b29710391e945b1e30c135477f484084ee513adb93809", size = 51880, upload-time = "2025-11-10T14:25:45.546Z" },
]
[[package]]
name = "pygments"
version = "2.19.2"
source = { registry = "https://pypi.org/simple" }
sdist = { url = "https://files.pythonhosted.org/packages/b0/77/a5b8c569bf593b0140bde72ea885a803b82086995367bf2037de0159d924/pygments-2.19.2.tar.gz", hash = "sha256:636cb2477cec7f8952536970bc533bc43743542f70392ae026374600add5b887", size = 4968631, upload-time = "2025-06-21T13:39:12.283Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/c7/21/705964c7812476f378728bdf590ca4b771ec72385c533964653c68e86bdc/pygments-2.19.2-py3-none-any.whl", hash = "sha256:86540386c03d588bb81d44bc3928634ff26449851e99741617ecb9037ee5ec0b", size = 1225217, upload-time = "2025-06-21T13:39:07.939Z" },
]
[[package]]
name = "pyjwt"
version = "2.10.1"
source = { registry = "https://pypi.org/simple" }
sdist = { url = "https://files.pythonhosted.org/packages/e7/46/bd74733ff231675599650d3e47f361794b22ef3e3770998dda30d3b63726/pyjwt-2.10.1.tar.gz", hash = "sha256:3cc5772eb20009233caf06e9d8a0577824723b44e6648ee0a2aedb6cf9381953", size = 87785, upload-time = "2024-11-28T03:43:29.933Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/61/ad/689f02752eeec26aed679477e80e632ef1b682313be70793d798c1d5fc8f/PyJWT-2.10.1-py3-none-any.whl", hash = "sha256:dcdd193e30abefd5debf142f9adfcdd2b58004e644f25406ffaebd50bd98dacb", size = 22997, upload-time = "2024-11-28T03:43:27.893Z" },
]
[package.optional-dependencies]
crypto = [
{ name = "cryptography" },
]
[[package]]
name = "pytest"
version = "9.0.2"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "colorama", marker = "sys_platform == 'win32'" },
{ name = "iniconfig" },
{ name = "packaging" },
{ name = "pluggy" },
{ name = "pygments" },
]
sdist = { url = "https://files.pythonhosted.org/packages/d1/db/7ef3487e0fb0049ddb5ce41d3a49c235bf9ad299b6a25d5780a89f19230f/pytest-9.0.2.tar.gz", hash = "sha256:75186651a92bd89611d1d9fc20f0b4345fd827c41ccd5c299a868a05d70edf11", size = 1568901, upload-time = "2025-12-06T21:30:51.014Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/3b/ab/b3226f0bd7cdcf710fbede2b3548584366da3b19b5021e74f5bde2a8fa3f/pytest-9.0.2-py3-none-any.whl", hash = "sha256:711ffd45bf766d5264d487b917733b453d917afd2b0ad65223959f59089f875b", size = 374801, upload-time = "2025-12-06T21:30:49.154Z" },
]
[[package]]
name = "pytest-asyncio"
version = "1.3.0"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "pytest" },
]
sdist = { url = "https://files.pythonhosted.org/packages/90/2c/8af215c0f776415f3590cac4f9086ccefd6fd463befeae41cd4d3f193e5a/pytest_asyncio-1.3.0.tar.gz", hash = "sha256:d7f52f36d231b80ee124cd216ffb19369aa168fc10095013c6b014a34d3ee9e5", size = 50087, upload-time = "2025-11-10T16:07:47.256Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/e5/35/f8b19922b6a25bc0880171a2f1a003eaeb93657475193ab516fd87cac9da/pytest_asyncio-1.3.0-py3-none-any.whl", hash = "sha256:611e26147c7f77640e6d0a92a38ed17c3e9848063698d5c93d5aa7aa11cebff5", size = 15075, upload-time = "2025-11-10T16:07:45.537Z" },
]
[[package]]
name = "python-dotenv"
version = "1.2.1"
source = { registry = "https://pypi.org/simple" }
sdist = { url = "https://files.pythonhosted.org/packages/f0/26/19cadc79a718c5edbec86fd4919a6b6d3f681039a2f6d66d14be94e75fb9/python_dotenv-1.2.1.tar.gz", hash = "sha256:42667e897e16ab0d66954af0e60a9caa94f0fd4ecf3aaf6d2d260eec1aa36ad6", size = 44221, upload-time = "2025-10-26T15:12:10.434Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/14/1b/a298b06749107c305e1fe0f814c6c74aea7b2f1e10989cb30f544a1b3253/python_dotenv-1.2.1-py3-none-any.whl", hash = "sha256:b81ee9561e9ca4004139c6cbba3a238c32b03e4894671e181b671e8cb8425d61", size = 21230, upload-time = "2025-10-26T15:12:09.109Z" },
]
[[package]]
name = "python-multipart"
version = "0.0.21"
source = { registry = "https://pypi.org/simple" }
sdist = { url = "https://files.pythonhosted.org/packages/78/96/804520d0850c7db98e5ccb70282e29208723f0964e88ffd9d0da2f52ea09/python_multipart-0.0.21.tar.gz", hash = "sha256:7137ebd4d3bbf70ea1622998f902b97a29434a9e8dc40eb203bbcf7c2a2cba92", size = 37196, upload-time = "2025-12-17T09:24:22.446Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/aa/76/03af049af4dcee5d27442f71b6924f01f3efb5d2bd34f23fcd563f2cc5f5/python_multipart-0.0.21-py3-none-any.whl", hash = "sha256:cf7a6713e01c87aa35387f4774e812c4361150938d20d232800f75ffcf266090", size = 24541, upload-time = "2025-12-17T09:24:21.153Z" },
]
[[package]]
name = "pywin32"
version = "311"
source = { registry = "https://pypi.org/simple" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/c9/31/097f2e132c4f16d99a22bfb777e0fd88bd8e1c634304e102f313af69ace5/pywin32-311-cp314-cp314-win32.whl", hash = "sha256:b7a2c10b93f8986666d0c803ee19b5990885872a7de910fc460f9b0c2fbf92ee", size = 8840714, upload-time = "2025-07-14T20:13:32.449Z" },
{ url = "https://files.pythonhosted.org/packages/90/4b/07c77d8ba0e01349358082713400435347df8426208171ce297da32c313d/pywin32-311-cp314-cp314-win_amd64.whl", hash = "sha256:3aca44c046bd2ed8c90de9cb8427f581c479e594e99b5c0bb19b29c10fd6cb87", size = 9656800, upload-time = "2025-07-14T20:13:34.312Z" },
{ url = "https://files.pythonhosted.org/packages/c0/d2/21af5c535501a7233e734b8af901574572da66fcc254cb35d0609c9080dd/pywin32-311-cp314-cp314-win_arm64.whl", hash = "sha256:a508e2d9025764a8270f93111a970e1d0fbfc33f4153b388bb649b7eec4f9b42", size = 8932540, upload-time = "2025-07-14T20:13:36.379Z" },
]
[[package]]
name = "referencing"
version = "0.37.0"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "attrs" },
{ name = "rpds-py" },
]
sdist = { url = "https://files.pythonhosted.org/packages/22/f5/df4e9027acead3ecc63e50fe1e36aca1523e1719559c499951bb4b53188f/referencing-0.37.0.tar.gz", hash = "sha256:44aefc3142c5b842538163acb373e24cce6632bd54bdb01b21ad5863489f50d8", size = 78036, upload-time = "2025-10-13T15:30:48.871Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/2c/58/ca301544e1fa93ed4f80d724bf5b194f6e4b945841c5bfd555878eea9fcb/referencing-0.37.0-py3-none-any.whl", hash = "sha256:381329a9f99628c9069361716891d34ad94af76e461dcb0335825aecc7692231", size = 26766, upload-time = "2025-10-13T15:30:47.625Z" },
]
[[package]]
name = "rpds-py"
version = "0.30.0"
source = { registry = "https://pypi.org/simple" }
sdist = { url = "https://files.pythonhosted.org/packages/20/af/3f2f423103f1113b36230496629986e0ef7e199d2aa8392452b484b38ced/rpds_py-0.30.0.tar.gz", hash = "sha256:dd8ff7cf90014af0c0f787eea34794ebf6415242ee1d6fa91eaba725cc441e84", size = 69469, upload-time = "2025-11-30T20:24:38.837Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/86/81/dad16382ebbd3d0e0328776d8fd7ca94220e4fa0798d1dc5e7da48cb3201/rpds_py-0.30.0-cp314-cp314-macosx_10_12_x86_64.whl", hash = "sha256:68f19c879420aa08f61203801423f6cd5ac5f0ac4ac82a2368a9fcd6a9a075e0", size = 362099, upload-time = "2025-11-30T20:23:27.316Z" },
{ url = "https://files.pythonhosted.org/packages/2b/60/19f7884db5d5603edf3c6bce35408f45ad3e97e10007df0e17dd57af18f8/rpds_py-0.30.0-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:ec7c4490c672c1a0389d319b3a9cfcd098dcdc4783991553c332a15acf7249be", size = 353192, upload-time = "2025-11-30T20:23:29.151Z" },
{ url = "https://files.pythonhosted.org/packages/bf/c4/76eb0e1e72d1a9c4703c69607cec123c29028bff28ce41588792417098ac/rpds_py-0.30.0-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f251c812357a3fed308d684a5079ddfb9d933860fc6de89f2b7ab00da481e65f", size = 384080, upload-time = "2025-11-30T20:23:30.785Z" },
{ url = "https://files.pythonhosted.org/packages/72/87/87ea665e92f3298d1b26d78814721dc39ed8d2c74b86e83348d6b48a6f31/rpds_py-0.30.0-cp314-cp314-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:ac98b175585ecf4c0348fd7b29c3864bda53b805c773cbf7bfdaffc8070c976f", size = 394841, upload-time = "2025-11-30T20:23:32.209Z" },
{ url = "https://files.pythonhosted.org/packages/77/ad/7783a89ca0587c15dcbf139b4a8364a872a25f861bdb88ed99f9b0dec985/rpds_py-0.30.0-cp314-cp314-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:3e62880792319dbeb7eb866547f2e35973289e7d5696c6e295476448f5b63c87", size = 516670, upload-time = "2025-11-30T20:23:33.742Z" },
{ url = "https://files.pythonhosted.org/packages/5b/3c/2882bdac942bd2172f3da574eab16f309ae10a3925644e969536553cb4ee/rpds_py-0.30.0-cp314-cp314-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:4e7fc54e0900ab35d041b0601431b0a0eb495f0851a0639b6ef90f7741b39a18", size = 408005, upload-time = "2025-11-30T20:23:35.253Z" },
{ url = "https://files.pythonhosted.org/packages/ce/81/9a91c0111ce1758c92516a3e44776920b579d9a7c09b2b06b642d4de3f0f/rpds_py-0.30.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:47e77dc9822d3ad616c3d5759ea5631a75e5809d5a28707744ef79d7a1bcfcad", size = 382112, upload-time = "2025-11-30T20:23:36.842Z" },
{ url = "https://files.pythonhosted.org/packages/cf/8e/1da49d4a107027e5fbc64daeab96a0706361a2918da10cb41769244b805d/rpds_py-0.30.0-cp314-cp314-manylinux_2_31_riscv64.whl", hash = "sha256:b4dc1a6ff022ff85ecafef7979a2c6eb423430e05f1165d6688234e62ba99a07", size = 399049, upload-time = "2025-11-30T20:23:38.343Z" },
{ url = "https://files.pythonhosted.org/packages/df/5a/7ee239b1aa48a127570ec03becbb29c9d5a9eb092febbd1699d567cae859/rpds_py-0.30.0-cp314-cp314-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:4559c972db3a360808309e06a74628b95eaccbf961c335c8fe0d590cf587456f", size = 415661, upload-time = "2025-11-30T20:23:40.263Z" },
{ url = "https://files.pythonhosted.org/packages/70/ea/caa143cf6b772f823bc7929a45da1fa83569ee49b11d18d0ada7f5ee6fd6/rpds_py-0.30.0-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:0ed177ed9bded28f8deb6ab40c183cd1192aa0de40c12f38be4d59cd33cb5c65", size = 565606, upload-time = "2025-11-30T20:23:42.186Z" },
{ url = "https://files.pythonhosted.org/packages/64/91/ac20ba2d69303f961ad8cf55bf7dbdb4763f627291ba3d0d7d67333cced9/rpds_py-0.30.0-cp314-cp314-musllinux_1_2_i686.whl", hash = "sha256:ad1fa8db769b76ea911cb4e10f049d80bf518c104f15b3edb2371cc65375c46f", size = 591126, upload-time = "2025-11-30T20:23:44.086Z" },
{ url = "https://files.pythonhosted.org/packages/21/20/7ff5f3c8b00c8a95f75985128c26ba44503fb35b8e0259d812766ea966c7/rpds_py-0.30.0-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:46e83c697b1f1c72b50e5ee5adb4353eef7406fb3f2043d64c33f20ad1c2fc53", size = 553371, upload-time = "2025-11-30T20:23:46.004Z" },
{ url = "https://files.pythonhosted.org/packages/72/c7/81dadd7b27c8ee391c132a6b192111ca58d866577ce2d9b0ca157552cce0/rpds_py-0.30.0-cp314-cp314-win32.whl", hash = "sha256:ee454b2a007d57363c2dfd5b6ca4a5d7e2c518938f8ed3b706e37e5d470801ed", size = 215298, upload-time = "2025-11-30T20:23:47.696Z" },
{ url = "https://files.pythonhosted.org/packages/3e/d2/1aaac33287e8cfb07aab2e6b8ac1deca62f6f65411344f1433c55e6f3eb8/rpds_py-0.30.0-cp314-cp314-win_amd64.whl", hash = "sha256:95f0802447ac2d10bcc69f6dc28fe95fdf17940367b21d34e34c737870758950", size = 228604, upload-time = "2025-11-30T20:23:49.501Z" },
{ url = "https://files.pythonhosted.org/packages/e8/95/ab005315818cc519ad074cb7784dae60d939163108bd2b394e60dc7b5461/rpds_py-0.30.0-cp314-cp314-win_arm64.whl", hash = "sha256:613aa4771c99f03346e54c3f038e4cc574ac09a3ddfb0e8878487335e96dead6", size = 222391, upload-time = "2025-11-30T20:23:50.96Z" },
{ url = "https://files.pythonhosted.org/packages/9e/68/154fe0194d83b973cdedcdcc88947a2752411165930182ae41d983dcefa6/rpds_py-0.30.0-cp314-cp314t-macosx_10_12_x86_64.whl", hash = "sha256:7e6ecfcb62edfd632e56983964e6884851786443739dbfe3582947e87274f7cb", size = 364868, upload-time = "2025-11-30T20:23:52.494Z" },
{ url = "https://files.pythonhosted.org/packages/83/69/8bbc8b07ec854d92a8b75668c24d2abcb1719ebf890f5604c61c9369a16f/rpds_py-0.30.0-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:a1d0bc22a7cdc173fedebb73ef81e07faef93692b8c1ad3733b67e31e1b6e1b8", size = 353747, upload-time = "2025-11-30T20:23:54.036Z" },
{ url = "https://files.pythonhosted.org/packages/ab/00/ba2e50183dbd9abcce9497fa5149c62b4ff3e22d338a30d690f9af970561/rpds_py-0.30.0-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0d08f00679177226c4cb8c5265012eea897c8ca3b93f429e546600c971bcbae7", size = 383795, upload-time = "2025-11-30T20:23:55.556Z" },
{ url = "https://files.pythonhosted.org/packages/05/6f/86f0272b84926bcb0e4c972262f54223e8ecc556b3224d281e6598fc9268/rpds_py-0.30.0-cp314-cp314t-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:5965af57d5848192c13534f90f9dd16464f3c37aaf166cc1da1cae1fd5a34898", size = 393330, upload-time = "2025-11-30T20:23:57.033Z" },
{ url = "https://files.pythonhosted.org/packages/cb/e9/0e02bb2e6dc63d212641da45df2b0bf29699d01715913e0d0f017ee29438/rpds_py-0.30.0-cp314-cp314t-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:9a4e86e34e9ab6b667c27f3211ca48f73dba7cd3d90f8d5b11be56e5dbc3fb4e", size = 518194, upload-time = "2025-11-30T20:23:58.637Z" },
{ url = "https://files.pythonhosted.org/packages/ee/ca/be7bca14cf21513bdf9c0606aba17d1f389ea2b6987035eb4f62bd923f25/rpds_py-0.30.0-cp314-cp314t-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:e5d3e6b26f2c785d65cc25ef1e5267ccbe1b069c5c21b8cc724efee290554419", size = 408340, upload-time = "2025-11-30T20:24:00.2Z" },
{ url = "https://files.pythonhosted.org/packages/c2/c7/736e00ebf39ed81d75544c0da6ef7b0998f8201b369acf842f9a90dc8fce/rpds_py-0.30.0-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:626a7433c34566535b6e56a1b39a7b17ba961e97ce3b80ec62e6f1312c025551", size = 383765, upload-time = "2025-11-30T20:24:01.759Z" },
{ url = "https://files.pythonhosted.org/packages/4a/3f/da50dfde9956aaf365c4adc9533b100008ed31aea635f2b8d7b627e25b49/rpds_py-0.30.0-cp314-cp314t-manylinux_2_31_riscv64.whl", hash = "sha256:acd7eb3f4471577b9b5a41baf02a978e8bdeb08b4b355273994f8b87032000a8", size = 396834, upload-time = "2025-11-30T20:24:03.687Z" },
{ url = "https://files.pythonhosted.org/packages/4e/00/34bcc2565b6020eab2623349efbdec810676ad571995911f1abdae62a3a0/rpds_py-0.30.0-cp314-cp314t-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:fe5fa731a1fa8a0a56b0977413f8cacac1768dad38d16b3a296712709476fbd5", size = 415470, upload-time = "2025-11-30T20:24:05.232Z" },
{ url = "https://files.pythonhosted.org/packages/8c/28/882e72b5b3e6f718d5453bd4d0d9cf8df36fddeb4ddbbab17869d5868616/rpds_py-0.30.0-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:74a3243a411126362712ee1524dfc90c650a503502f135d54d1b352bd01f2404", size = 565630, upload-time = "2025-11-30T20:24:06.878Z" },
{ url = "https://files.pythonhosted.org/packages/3b/97/04a65539c17692de5b85c6e293520fd01317fd878ea1995f0367d4532fb1/rpds_py-0.30.0-cp314-cp314t-musllinux_1_2_i686.whl", hash = "sha256:3e8eeb0544f2eb0d2581774be4c3410356eba189529a6b3e36bbbf9696175856", size = 591148, upload-time = "2025-11-30T20:24:08.445Z" },
{ url = "https://files.pythonhosted.org/packages/85/70/92482ccffb96f5441aab93e26c4d66489eb599efdcf96fad90c14bbfb976/rpds_py-0.30.0-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:dbd936cde57abfee19ab3213cf9c26be06d60750e60a8e4dd85d1ab12c8b1f40", size = 556030, upload-time = "2025-11-30T20:24:10.956Z" },
{ url = "https://files.pythonhosted.org/packages/20/53/7c7e784abfa500a2b6b583b147ee4bb5a2b3747a9166bab52fec4b5b5e7d/rpds_py-0.30.0-cp314-cp314t-win32.whl", hash = "sha256:dc824125c72246d924f7f796b4f63c1e9dc810c7d9e2355864b3c3a73d59ade0", size = 211570, upload-time = "2025-11-30T20:24:12.735Z" },
{ url = "https://files.pythonhosted.org/packages/d0/02/fa464cdfbe6b26e0600b62c528b72d8608f5cc49f96b8d6e38c95d60c676/rpds_py-0.30.0-cp314-cp314t-win_amd64.whl", hash = "sha256:27f4b0e92de5bfbc6f86e43959e6edd1425c33b5e69aab0984a72047f2bcf1e3", size = 226532, upload-time = "2025-11-30T20:24:14.634Z" },
]
[[package]]
name = "ruff"
version = "0.14.10"
source = { registry = "https://pypi.org/simple" }
sdist = { url = "https://files.pythonhosted.org/packages/57/08/52232a877978dd8f9cf2aeddce3e611b40a63287dfca29b6b8da791f5e8d/ruff-0.14.10.tar.gz", hash = "sha256:9a2e830f075d1a42cd28420d7809ace390832a490ed0966fe373ba288e77aaf4", size = 5859763, upload-time = "2025-12-18T19:28:57.98Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/60/01/933704d69f3f05ee16ef11406b78881733c186fe14b6a46b05cfcaf6d3b2/ruff-0.14.10-py3-none-linux_armv6l.whl", hash = "sha256:7a3ce585f2ade3e1f29ec1b92df13e3da262178df8c8bdf876f48fa0e8316c49", size = 13527080, upload-time = "2025-12-18T19:29:25.642Z" },
{ url = "https://files.pythonhosted.org/packages/df/58/a0349197a7dfa603ffb7f5b0470391efa79ddc327c1e29c4851e85b09cc5/ruff-0.14.10-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:674f9be9372907f7257c51f1d4fc902cb7cf014b9980152b802794317941f08f", size = 13797320, upload-time = "2025-12-18T19:29:02.571Z" },
{ url = "https://files.pythonhosted.org/packages/7b/82/36be59f00a6082e38c23536df4e71cdbc6af8d7c707eade97fcad5c98235/ruff-0.14.10-py3-none-macosx_11_0_arm64.whl", hash = "sha256:d85713d522348837ef9df8efca33ccb8bd6fcfc86a2cde3ccb4bc9d28a18003d", size = 12918434, upload-time = "2025-12-18T19:28:51.202Z" },
{ url = "https://files.pythonhosted.org/packages/a6/00/45c62a7f7e34da92a25804f813ebe05c88aa9e0c25e5cb5a7d23dd7450e3/ruff-0.14.10-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6987ebe0501ae4f4308d7d24e2d0fe3d7a98430f5adfd0f1fead050a740a3a77", size = 13371961, upload-time = "2025-12-18T19:29:04.991Z" },
{ url = "https://files.pythonhosted.org/packages/40/31/a5906d60f0405f7e57045a70f2d57084a93ca7425f22e1d66904769d1628/ruff-0.14.10-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:16a01dfb7b9e4eee556fbfd5392806b1b8550c9b4a9f6acd3dbe6812b193c70a", size = 13275629, upload-time = "2025-12-18T19:29:21.381Z" },
{ url = "https://files.pythonhosted.org/packages/3e/60/61c0087df21894cf9d928dc04bcd4fb10e8b2e8dca7b1a276ba2155b2002/ruff-0.14.10-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:7165d31a925b7a294465fa81be8c12a0e9b60fb02bf177e79067c867e71f8b1f", size = 14029234, upload-time = "2025-12-18T19:29:00.132Z" },
{ url = "https://files.pythonhosted.org/packages/44/84/77d911bee3b92348b6e5dab5a0c898d87084ea03ac5dc708f46d88407def/ruff-0.14.10-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:c561695675b972effb0c0a45db233f2c816ff3da8dcfbe7dfc7eed625f218935", size = 15449890, upload-time = "2025-12-18T19:28:53.573Z" },
{ url = "https://files.pythonhosted.org/packages/e9/36/480206eaefa24a7ec321582dda580443a8f0671fdbf6b1c80e9c3e93a16a/ruff-0.14.10-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:4bb98fcbbc61725968893682fd4df8966a34611239c9fd07a1f6a07e7103d08e", size = 15123172, upload-time = "2025-12-18T19:29:23.453Z" },
{ url = "https://files.pythonhosted.org/packages/5c/38/68e414156015ba80cef5473d57919d27dfb62ec804b96180bafdeaf0e090/ruff-0.14.10-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:f24b47993a9d8cb858429e97bdf8544c78029f09b520af615c1d261bf827001d", size = 14460260, upload-time = "2025-12-18T19:29:27.808Z" },
{ url = "https://files.pythonhosted.org/packages/b3/19/9e050c0dca8aba824d67cc0db69fb459c28d8cd3f6855b1405b3f29cc91d/ruff-0.14.10-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:59aabd2e2c4fd614d2862e7939c34a532c04f1084476d6833dddef4afab87e9f", size = 14229978, upload-time = "2025-12-18T19:29:11.32Z" },
{ url = "https://files.pythonhosted.org/packages/51/eb/e8dd1dd6e05b9e695aa9dd420f4577debdd0f87a5ff2fedda33c09e9be8c/ruff-0.14.10-py3-none-manylinux_2_31_riscv64.whl", hash = "sha256:213db2b2e44be8625002dbea33bb9c60c66ea2c07c084a00d55732689d697a7f", size = 14338036, upload-time = "2025-12-18T19:29:09.184Z" },
{ url = "https://files.pythonhosted.org/packages/6a/12/f3e3a505db7c19303b70af370d137795fcfec136d670d5de5391e295c134/ruff-0.14.10-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:b914c40ab64865a17a9a5b67911d14df72346a634527240039eb3bd650e5979d", size = 13264051, upload-time = "2025-12-18T19:29:13.431Z" },
{ url = "https://files.pythonhosted.org/packages/08/64/8c3a47eaccfef8ac20e0484e68e0772013eb85802f8a9f7603ca751eb166/ruff-0.14.10-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:1484983559f026788e3a5c07c81ef7d1e97c1c78ed03041a18f75df104c45405", size = 13283998, upload-time = "2025-12-18T19:29:06.994Z" },
{ url = "https://files.pythonhosted.org/packages/12/84/534a5506f4074e5cc0529e5cd96cfc01bb480e460c7edf5af70d2bcae55e/ruff-0.14.10-py3-none-musllinux_1_2_i686.whl", hash = "sha256:c70427132db492d25f982fffc8d6c7535cc2fd2c83fc8888f05caaa248521e60", size = 13601891, upload-time = "2025-12-18T19:28:55.811Z" },
{ url = "https://files.pythonhosted.org/packages/0d/1e/14c916087d8598917dbad9b2921d340f7884824ad6e9c55de948a93b106d/ruff-0.14.10-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:5bcf45b681e9f1ee6445d317ce1fa9d6cba9a6049542d1c3d5b5958986be8830", size = 14336660, upload-time = "2025-12-18T19:29:16.531Z" },
{ url = "https://files.pythonhosted.org/packages/f2/1c/d7b67ab43f30013b47c12b42d1acd354c195351a3f7a1d67f59e54227ede/ruff-0.14.10-py3-none-win32.whl", hash = "sha256:104c49fc7ab73f3f3a758039adea978869a918f31b73280db175b43a2d9b51d6", size = 13196187, upload-time = "2025-12-18T19:29:19.006Z" },
{ url = "https://files.pythonhosted.org/packages/fb/9c/896c862e13886fae2af961bef3e6312db9ebc6adc2b156fe95e615dee8c1/ruff-0.14.10-py3-none-win_amd64.whl", hash = "sha256:466297bd73638c6bdf06485683e812db1c00c7ac96d4ddd0294a338c62fdc154", size = 14661283, upload-time = "2025-12-18T19:29:30.16Z" },
{ url = "https://files.pythonhosted.org/packages/74/31/b0e29d572670dca3674eeee78e418f20bdf97fa8aa9ea71380885e175ca0/ruff-0.14.10-py3-none-win_arm64.whl", hash = "sha256:e51d046cf6dda98a4633b8a8a771451107413b0f07183b2bef03f075599e44e6", size = 13729839, upload-time = "2025-12-18T19:28:48.636Z" },
]
[[package]]
name = "sse-starlette"
version = "3.1.2"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "anyio" },
{ name = "starlette" },
]
sdist = { url = "https://files.pythonhosted.org/packages/da/34/f5df66cb383efdbf4f2db23cabb27f51b1dcb737efaf8a558f6f1d195134/sse_starlette-3.1.2.tar.gz", hash = "sha256:55eff034207a83a0eb86de9a68099bd0157838f0b8b999a1b742005c71e33618", size = 26303, upload-time = "2025-12-31T08:02:20.023Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/b7/95/8c4b76eec9ae574474e5d2997557cebf764bcd3586458956c30631ae08f4/sse_starlette-3.1.2-py3-none-any.whl", hash = "sha256:cd800dd349f4521b317b9391d3796fa97b71748a4da9b9e00aafab32dda375c8", size = 12484, upload-time = "2025-12-31T08:02:18.894Z" },
]
[[package]]
name = "starlette"
version = "0.50.0"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "anyio" },
]
sdist = { url = "https://files.pythonhosted.org/packages/ba/b8/73a0e6a6e079a9d9cfa64113d771e421640b6f679a52eeb9b32f72d871a1/starlette-0.50.0.tar.gz", hash = "sha256:a2a17b22203254bcbc2e1f926d2d55f3f9497f769416b3190768befe598fa3ca", size = 2646985, upload-time = "2025-11-01T15:25:27.516Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/d9/52/1064f510b141bd54025f9b55105e26d1fa970b9be67ad766380a3c9b74b0/starlette-0.50.0-py3-none-any.whl", hash = "sha256:9e5391843ec9b6e472eed1365a78c8098cfceb7a74bfd4d6b1c0c0095efb3bca", size = 74033, upload-time = "2025-11-01T15:25:25.461Z" },
]
[[package]]
name = "typing-extensions"
version = "4.15.0"
source = { registry = "https://pypi.org/simple" }
sdist = { url = "https://files.pythonhosted.org/packages/72/94/1a15dd82efb362ac84269196e94cf00f187f7ed21c242792a923cdb1c61f/typing_extensions-4.15.0.tar.gz", hash = "sha256:0cea48d173cc12fa28ecabc3b837ea3cf6f38c6d1136f85cbaaf598984861466", size = 109391, upload-time = "2025-08-25T13:49:26.313Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/18/67/36e9267722cc04a6b9f15c7f3441c2363321a3ea07da7ae0c0707beb2a9c/typing_extensions-4.15.0-py3-none-any.whl", hash = "sha256:f0fa19c6845758ab08074a0cfa8b7aecb71c999ca73d62883bc25cc018c4e548", size = 44614, upload-time = "2025-08-25T13:49:24.86Z" },
]
[[package]]
name = "typing-inspection"
version = "0.4.2"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "typing-extensions" },
]
sdist = { url = "https://files.pythonhosted.org/packages/55/e3/70399cb7dd41c10ac53367ae42139cf4b1ca5f36bb3dc6c9d33acdb43655/typing_inspection-0.4.2.tar.gz", hash = "sha256:ba561c48a67c5958007083d386c3295464928b01faa735ab8547c5692e87f464", size = 75949, upload-time = "2025-10-01T02:14:41.687Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/dc/9b/47798a6c91d8bdb567fe2698fe81e0c6b7cb7ef4d13da4114b41d239f65d/typing_inspection-0.4.2-py3-none-any.whl", hash = "sha256:4ed1cacbdc298c220f1bd249ed5287caa16f34d44ef4e9c3d0cbad5b521545e7", size = 14611, upload-time = "2025-10-01T02:14:40.154Z" },
]
[[package]]
name = "uvicorn"
version = "0.40.0"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "click" },
{ name = "h11" },
]
sdist = { url = "https://files.pythonhosted.org/packages/c3/d1/8f3c683c9561a4e6689dd3b1d345c815f10f86acd044ee1fb9a4dcd0b8c5/uvicorn-0.40.0.tar.gz", hash = "sha256:839676675e87e73694518b5574fd0f24c9d97b46bea16df7b8c05ea1a51071ea", size = 81761, upload-time = "2025-12-21T14:16:22.45Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/3d/d8/2083a1daa7439a66f3a48589a57d576aa117726762618f6bb09fe3798796/uvicorn-0.40.0-py3-none-any.whl", hash = "sha256:c6c8f55bc8bf13eb6fa9ff87ad62308bbbc33d0b67f84293151efe87e0d5f2ee", size = 68502, upload-time = "2025-12-21T14:16:21.041Z" },
]
[[package]]
name = "xer-mcp"
version = "0.2.0"
source = { editable = "." }
dependencies = [
{ name = "mcp" },
]
[package.optional-dependencies]
dev = [
{ name = "pytest" },
{ name = "pytest-asyncio" },
{ name = "ruff" },
]
[package.metadata]
requires-dist = [
{ name = "mcp", specifier = ">=1.0.0" },
{ name = "pytest", marker = "extra == 'dev'", specifier = ">=8.0.0" },
{ name = "pytest-asyncio", marker = "extra == 'dev'", specifier = ">=0.24.0" },
{ name = "ruff", marker = "extra == 'dev'", specifier = ">=0.8.0" },
]
provides-extras = ["dev"]