troubleshoot-mcp-server
The MCP Server for Kubernetes Support Bundles is designed for AI-driven analysis and troubleshooting of Kubernetes clusters. It enables comprehensive interaction with support bundles, focusing on features like bundle management and secure command execution. This server is particularly notable for its containerization capabilities.
MCP Server for Kubernetes Support Bundles
A Model Context Protocol (MCP) server for AI models to interact with Kubernetes support bundles. This server enables AI models to analyze and troubleshoot Kubernetes clusters by exploring support bundles generated by the Troubleshoot tool.
Features
- š Bundle Management: Initialize and manage Kubernetes support bundles
- š® Command Execution: Run kubectl commands against bundle's API server
- š File Explorer: Navigate and search files within the bundle
- š Secure Authentication: Token-based authentication for bundle access
- š³ Container Support: Run as a containerized application
Quick Start
Using Podman
The easiest way to get started is using Podman:
# Build the image
podman build -t mcp-server-troubleshoot:latest -f Containerfile .
# Run the server
podman run -i --rm \
-v "/path/to/bundles:/data/bundles" \
-e SBCTL_TOKEN="your-token" \
mcp-server-troubleshoot:latest
See the for comprehensive container configuration details.
Manual Installation
- Ensure you have Python 3.13 installed
- Set up environment with UV (recommended):
# Automatically creates and sets up environment with best available Python
./scripts/setup_env.sh
# OR create manually with UV
uv venv -p python3.13 .venv
uv pip install -e ".[dev]" # For development with testing tools
- Set up your authentication token:
export SBCTL_TOKEN=your-token
- Run the server using UV:
uv run python -m mcp_server_troubleshoot
Documentation
For comprehensive documentation, see:
- : Installation, configuration, and usage instructions
- : Detailed API documentation
- : Information for developers
- : Container setup and configuration
- : Overall system design
- : Solutions for common issues
- : How to create new releases
The directory contains reference configurations for developers. These files should not be modified.
Tools
The MCP server provides the following tools for AI models:
Bundle Management
initialize_bundle
: Initialize a support bundle for use
Kubectl Commands
kubectl
: Execute kubectl commands against the bundle
File Operations
list_files
: List files and directoriesread_file
: Read file contentsgrep_files
: Search for patterns in files
Example Usage
AI models can interact with the server using the MCP protocol:
// Request to list files
{
"name": "list_files",
"input": {
"path": "/kubernetes/pods",
"recursive": false
}
}
// Response (simplified)
{
"content": "Listed files in /kubernetes/pods non-recursively:\n```json\n[\n {\n \"name\": \"kube-system\",\n \"path\": \"/kubernetes/pods/kube-system\",\n \"type\": \"directory\",\n \"size\": null,\n \"modified\": \"2025-04-10T12:30:45Z\"\n },\n {\n \"name\": \"pod-definition.yaml\",\n \"path\": \"/kubernetes/pods/pod-definition.yaml\",\n \"type\": \"file\",\n \"size\": 1254,\n \"modified\": \"2025-04-10T12:30:45Z\"\n }\n]\n```\nDirectory metadata:\n```json\n{\n \"path\": \"/kubernetes/pods\",\n \"recursive\": false,\n \"total_files\": 1,\n \"total_dirs\": 1\n}\n```"
}
Project Structure
āāā docs/ # Documentation
ā āāā CLAUDE.md # AI assistant instructions
ā āāā PODMAN.md # Podman configuration guide
ā āāā README.md # Project overview (this file)
ā āāā docs/ # Detailed documentation
ā ā āāā agentic/ # AI agent documentation
ā ā āāā components/ # Component design docs
ā ā āāā examples/ # Example prompts and usage
ā āāā tasks/ # Development tasks
ā āāā completed/ # Completed tasks
ā āāā started/ # Tasks in progress
ā āāā ready/ # Tasks ready to implement
āāā examples/ # Example configurations (for reference only)
ā āāā mcp-servers/ # MCP server example configs
āāā scripts/ # Utility scripts
ā āāā build.sh # Podman build script
ā āāā run.sh # Podman run script
āāā src/ # Source code
ā āāā mcp_server_troubleshoot/
ā āāā __init__.py
ā āāā __main__.py # Entry point
ā āāā bundle.py # Bundle management
ā āāā cli.py # CLI interface
ā āāā config.py # Configuration management
ā āāā files.py # File operations
ā āāā kubectl.py # Kubectl command execution
ā āāā lifecycle.py # Bundle lifecycle management
ā āāā server.py # MCP server implementation
āāā tests/ # Test files
āāā e2e/ # End-to-end tests
āāā fixtures/ # Test fixtures
āāā integration/ # Integration tests
āāā unit/ # Unit tests
āāā util/ # Test utilities
Development
Installation
For development, install the package in editable mode with development dependencies:
# Clone the repository
git clone https://github.com/your-username/mcp-server-troubleshoot.git
cd mcp-server-troubleshoot
# Set up the development environment using UV
./scripts/setup_env.sh
# Or manually with UV
uv venv -p python3.13 .venv
uv pip install -e ".[dev]"
For detailed guidance on dependency management, see our .
Code Style
Code formatting is done using Black and Ruff:
# Format code with Black
uv run black .
# Lint code with Ruff
uv run ruff check .
Testing
# Run all tests
uv run pytest
# Run with verbose output
uv run pytest -v
# Run a specific test type using markers
uv run pytest -m unit
uv run pytest -m integration
uv run pytest -m e2e
# Run tests with detailed warnings
uv run pytest -W all
# Run tests with warnings as errors
uv run pytest -W error
# Or use the helper script
./scripts/run_tests.sh unit
./scripts/run_tests.sh integration
Requirements
- Python 3.13
kubectl
command-line toolsbctl
command-line tool for bundle management- Token for authentication (set as
SBCTL_TOKEN
orREPLICATED
environment variable)
All dependencies are included in the Podman container, making it the recommended deployment method.
Contributing
Contributions are welcome! Please see the for details on how to contribute.
License
This project is licensed under the Apache License 2.0 - see the file for details.