-
Initialize Python project structure
- Initialize project (
uv init) - Initialize virtual environment (
uv venv) - Add & configure dev dependencies (pytest, ruff, etc.) (
uv add) - Set up src/mcp_background_job package structure
- Initialize project (
-
Set up development environment
- Sync dependencies (
uv sync) - Configure pytest.ini for test discovery
- Set up logging configuration
- Sync dependencies (
-
Define Pydantic models
- JobStatus enum
- BackgroundJob model
- JobSummary model
- ProcessOutput model
- All tool input/output models
-
Create configuration model
- BackgroundJobConfig with environment defaults
- Configuration loading and validation
-
Implement ProcessWrapper class
- Process creation with proper I/O handling
- Stdout/stderr buffering with ring buffer
- Process status monitoring
- Input sending to stdin
- Process termination handling
-
Add output management
- Tail functionality for last N lines
- Full output retrieval
- Buffer size management and cleanup
-
Implement JobManager class
- Job registry with in-memory storage
- UUID generation for job IDs
- Job lifecycle management
-
Core job operations
- execute_command method
- get_job_status method
- list_jobs method
- get_job_output method
- tail_job_output method
-
Advanced job operations
- kill_job method
- interact_with_job method
- cleanup_completed_jobs method
-
Set up FastMCP server
- Server initialization and configuration
- Error handling with ToolError
-
Implement read-only tools
- list tool - show all jobs
- status tool - get job status
- output tool - get full job output
- tail tool - get recent output lines
-
Implement interactive tools
- execute tool - start new background job
- interact tool - send input to job
- kill tool - terminate job
-
Custom exception classes
- JobNotFoundError
- JobAlreadyTerminatedError
- ProcessExecutionError
-
Input validation and sanitization
- Command validation
- Job ID format validation
- Parameter bounds checking
-
Error response formatting
- Consistent error messages
- Proper HTTP status codes for MCP errors
-
Command security
- Command allowlist/blocklist implementation
- Shell injection prevention
- Path traversal protection
-
Resource limits
- Maximum concurrent jobs enforcement
- Memory usage monitoring
- Process timeout handling
-
Cleanup mechanisms
- Automatic cleanup of old jobs
- Resource leak prevention
- Graceful shutdown handling
-
Unit test setup
- Test fixtures for jobs and processes
- Mock subprocess for isolated testing
- Test utilities and helpers
-
Core functionality tests
- JobManager unit tests
- ProcessWrapper unit tests
- Data model validation tests
-
MCP tool integration tests
- Tool execution tests
- Error handling tests
- Input/output validation tests
-
End-to-end workflow tests
- Execute → status → output → kill workflow
- Execute → interact → output workflow
- Concurrent job handling tests
-
Long-running process tests
- Jobs that run for extended periods
- Memory usage over time
- Output buffering under load
-
Edge case testing
- Invalid job IDs
- Already terminated processes
- Resource exhaustion scenarios
-
Code documentation
- Docstrings for all public methods
- Type hints validation
- API documentation generation
-
Usage examples
- Update README with usage examples
- Integration examples for common use cases
- Configuration examples
-
Performance optimization
- Output buffer efficiency
- Process monitoring overhead
- Memory usage optimization
-
Logging and monitoring
- Structured logging implementation
- Performance metrics collection
- Health check endpoints
-
Configuration management
- Environment variable handling
- Configuration file support
- Default value validation
-
Deployment preparation
- Transport configuration (stdio/HTTP)
- CORS handling for HTTP transport
- Production logging setup
-
Final testing and validation
- Load testing with multiple clients
- Security audit of command execution
- Memory leak testing