Skip to content

Conversation

@aficiomaquinas
Copy link

📋 Add Comprehensive Logs Management Tools

🎯 Overview

This PR adds a complete set of logs management tools to the Kestra MCP server, enabling users to easily access, search, and manage execution logs directly through the MCP interface.

✨ What's New

6 New Logs Tools Added:

  • get_execution_logs - Retrieve logs for a specific execution with filtering options
  • download_execution_logs - Download logs as plain text for easy analysis
  • search_logs - Global log search across all executions with advanced filters
  • delete_execution_logs - Delete logs for a specific execution (use with caution)
  • delete_flow_logs - Delete logs for all executions of a specific flow
  • follow_execution_logs - Real-time log streaming for running executions

🔍 Advanced Filtering Capabilities:

  • Log levels: ERROR, WARN, INFO, DEBUG, TRACE
  • Task filtering: taskId, taskRunId, attempt number
  • Date ranges: For search operations (startDate, endDate)
  • Namespace and flow filtering: Targeted log searches

🚀 Key Benefits

  • Easy Log Access: No need to navigate to Kestra UI for log inspection
  • Powerful Search: Find specific logs across all executions quickly
  • Real-time Monitoring: Follow logs as they're generated during execution
  • Flexible Export: Download logs in various formats for analysis
  • Complete Coverage: Works with both Community and Enterprise editions

📚 Documentation & Testing

  • Complete documentation in docs/prompts/logs.md
  • Comprehensive test suite with 6 test cases
  • Integration tests with real Kestra instance
  • Parameter validation and error handling
  • All tests passing (33/33 tests pass)

🔧 Technical Implementation

  • Uses official Kestra REST API endpoints for logs
  • Compatible with both Basic Auth and API Token authentication
  • Proper error handling and input validation
  • Follows existing MCP server patterns and conventions
  • No breaking changes to existing functionality

📊 Impact

This contribution significantly improves the developer experience by providing:

  • Direct log access through MCP interface
  • Reduced context switching between tools
  • Enhanced debugging capabilities for Kestra workflows
  • Better log management for production environments

🧪 Testing

All tests pass successfully:

$ pytest tests/test_logs.py -v
======================== 6 passed in 21.68s =========================

📝 Usage Examples

# Get logs for a specific execution
Get logs for execution abc123 with INFO level or higher

# Search for errors across executions
Search for error logs in namespace production.etl

# Download logs for analysis
Download all logs from execution xyz789

# Follow logs in real-time
Follow ERROR level logs for execution abc123

🔗 API Endpoints Used

  • GET /api/v1/{tenant}/logs/{executionId} - Get execution logs
  • GET /api/v1/{tenant}/logs/{executionId}/download - Download logs
  • GET /api/v1/{tenant}/logs/search - Search logs globally
  • DELETE /api/v1/{tenant}/logs/{executionId} - Delete execution logs
  • DELETE /api/v1/{tenant}/logs/{namespace}/{flowId} - Delete flow logs
  • GET /api/v1/{tenant}/logs/{executionId}/follow - Follow logs (SSE)

📁 Files Changed

  • src/tools/logs.py - Main implementation (335 lines)
  • docs/prompts/logs.md - Complete documentation (88 lines)
  • tests/test_logs.py - Test suite (208 lines)
  • src/server.py - Tool registration (3 lines)
  • tests/test_mcp_server.py - Updated tool list (7 lines)
  • README.md - Added logs to available tools (1 line)

Total: 6 files changed, 642 insertions(+)


This PR makes log management much more accessible and powerful for Kestra users, providing a seamless experience for debugging and monitoring workflows through the MCP interface.

✨ New Features:
- Add 6 new logs tools for complete log management
- Support for Community and Enterprise editions
- Real-time log following with Server-Sent Events

🛠️ Tools Added:
- get_execution_logs: Retrieve logs with filtering options
- download_execution_logs: Download logs as plain text
- search_logs: Global log search with advanced filters
- delete_execution_logs: Delete logs for specific execution
- delete_flow_logs: Delete logs for all flow executions
- follow_execution_logs: Real-time log streaming

🔍 Filtering Capabilities:
- Log levels: ERROR, WARN, INFO, DEBUG, TRACE
- Task filtering: taskId, taskRunId, attempt number
- Date ranges for search operations
- Namespace and flow filtering

📚 Documentation:
- Complete documentation in docs/prompts/logs.md
- Usage examples and API reference
- Integration with existing MCP server structure

🧪 Testing:
- Comprehensive test suite with 6 test cases
- Integration tests with real Kestra instance
- Parameter validation and error handling tests
- All tests passing ✅

🔧 Technical Details:
- Uses Kestra REST API endpoints for logs
- Compatible with both Basic Auth and API Token auth
- Proper error handling and validation
- Follows existing MCP server patterns

This contribution makes log management much easier for Kestra users
by providing direct access to logs through the MCP interface.
@github-project-automation github-project-automation bot moved this to To review in Pull Requests Oct 21, 2025
@MilosPaunovic MilosPaunovic requested review from a team and loicmathieu October 21, 2025 06:46
@MilosPaunovic MilosPaunovic added kind/external Pull requests raised by community contributors area/backend Needs backend code changes labels Oct 22, 2025
@MilosPaunovic
Copy link
Member

@loicmathieu I'm not sure if you're the right person for a review here, if not, please re-assign.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/backend Needs backend code changes kind/external Pull requests raised by community contributors

Projects

Status: To review

Development

Successfully merging this pull request may close these issues.

2 participants