Skip to content

Conversation

@GlassOnTin
Copy link

@GlassOnTin GlassOnTin commented Aug 20, 2025

Summary

This PR adds comprehensive pipeline monitoring and build analysis capabilities to the Azure DevOps MCP server, focusing on accessing pipeline logs, build artifacts, code coverage, and test results.

Features Added

🔍 Pipeline Monitoring & Logs

  • Pipeline run management: List runs with pagination, get detailed run information, cancel running pipelines
  • Log retrieval: Download and cache pipeline logs locally for efficient access
  • Log content access: Streamlined tool to read specific log content with caching
  • Log analysis: Search/grep through logs with regex patterns, context lines, and filtering
  • Performance optimizations: Local caching reduces API calls and improves response times

📊 Build Analysis Tools

  • Build artifacts: List and get details of build artifacts
  • Code coverage: Access coverage summaries and detailed module/function-level metrics
  • Test results: Retrieve test outcomes with filtering and calculate pass rates

Technical Details

  • Full TypeScript type safety with Zod schemas
  • Comprehensive error handling and null safety checks
  • Efficient caching mechanisms for downloaded logs
  • All features integrated with existing MCP server architecture

Testing

All features have been tested and verified working:

  • ✅ Pipeline operations (list, get, cancel)
  • ✅ Log download and search functionality
  • ✅ Build artifact listing and details
  • ✅ Code coverage access (44.1% branch, 63.8% line coverage example)
  • ✅ Test results (97.9% pass rate example with 2,203 tests)

Breaking Changes

None - all changes are additive.

Documentation

Comprehensive documentation added for all new tools in docs/tools/.

- Add list_pipeline_runs tool to get recent runs for a pipeline
- Add get_pipeline_run tool to get detailed run information
- Include run state, result, dates, variables, and template parameters
- Add comprehensive unit tests for both new features
- Update documentation with usage examples
- Add optional 'top' parameter to limit results (default: 50, max: 1000)
- Implement client-side limiting to handle pipelines with extensive history
- Update tests to verify pagination behavior
- Add documentation about large result sets and token limits
- Prevents token limit errors when listing runs for pipelines with thousands of runs
- LogCollection has 'logs' property, not 'value' or 'count'
- Update feature implementation to use correct property names
- Fix all test mocks to match actual API structure
- Use signedContent.url when available (preferred for signed URLs)
- Fall back to log.url if signedContent not available
- Add detailed console logging for debugging authentication issues
- Log response status codes and content types for failed fetches
- Help diagnose why signed URLs return authentication pages
- Handle null/undefined responses from listLogs and getLog
- Add warning messages when logs are not found
- Prevent 'Cannot read properties of null' errors
- Return proper null response structure when no logs exist
- Update return type to allow LogCollection | null
- Add unit tests for null responses from API
- Tests verify proper handling of missing logs
- All tests passing with null safety
- New tool to download all pipeline run logs to local files
- Handles large logs that exceed MCP token limits
- Creates organized directory structure with numbered log files
- Includes summary.json with metadata about downloaded logs
- Gracefully handles failed downloads and missing URLs
- Comprehensive unit tests with 100% coverage
- Documentation added to pipelines.md
- read_downloaded_log: Read log files with pagination support for huge logs
- list_downloaded_logs: List available files in download directory
- Supports reading logs in chunks (offset/limit) to handle massive files
- Solves the problem of accessing files on remote MCP host via TCP tunnel
- Default limit of 1000 lines per read, max 5000 lines
- Single-step tool to get specific log content directly
- Automatically downloads and caches logs (15-minute cache)
- Supports pagination for huge logs (offset/limit)
- Eliminates confusing multi-step process
- Intelligently reuses cached downloads when available
- Perfect for interactive log analysis without manual download management
- Added detailed docs for get_pipeline_log_content (recommended tool)
- Documented all manual download/read tools for advanced users
- Clear categorization: Quick Access vs Advanced Control
- Examples for common use cases and pagination
- Explains when to use each tool
- Search for patterns across all or specific logs
- Auto-downloads and caches logs (shares cache with get_pipeline_log_content)
- Supports regex patterns with case-insensitive option
- Context lines (before/after) like grep -B/-A
- Inverse matching (grep -v) to find lines that don't match
- Max matches limit to prevent token overflow
- Perfect for finding test failures, errors, or specific events in large logs
- Uses Build API to cancel pipeline runs (pipeline run ID = build ID)
- Handles various states (already completed, cancelling, etc.)
- Supports optional cancellation reason
- Updated documentation with usage examples
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant