MCP server for Kubernetes support bundles
Project description
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 (uses melange/apko instead of Containerfile)
./scripts/build.sh
# Run the server
podman run -i --rm \
-v "/path/to/bundles:/data/bundles" \
-e SBCTL_TOKEN="your-token" \
troubleshoot-mcp-server-dev:latest
See the Podman documentation 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 troubleshoot_mcp_server
Container Image Variants
This project provides two distinct container image variants:
Development Image: troubleshoot-mcp-server-dev:latest
- Purpose: Local development and testing
- Built by:
./scripts/build.sh(default) - Usage: When building from source or developing locally
- Example:
./scripts/build.sh podman run -i --rm troubleshoot-mcp-server-dev:latest
Production Image: troubleshoot-mcp-server:latest
- Purpose: Official releases and production deployments
- Built by: CI/CD pipeline with
IMAGE_NAME=troubleshoot-mcp-server ./scripts/build.sh - Usage: In production environments or when using official releases
- Example:
IMAGE_NAME=troubleshoot-mcp-server ./scripts/build.sh podman run -i --rm troubleshoot-mcp-server:latest
Why Two Variants?
The -dev suffix prevents conflicts between local development images and official production releases. This allows users to:
- Use official container releases without interference from local builds
- Develop and test locally without overwriting production images
- Maintain clear separation between development and production environments
Documentation
For comprehensive documentation, see:
- User Guide: Installation, configuration, and usage instructions
- API Reference: Detailed API documentation
- Developer Guide: Information for developers
- Podman Guide: Container setup and configuration
- System Architecture: Overall system design
- Troubleshooting Guide: Solutions for common issues
- Release Process: How to create new releases
The examples 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
โ โโโ troubleshoot_mcp_server/
โ โโโ __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/troubleshoot-mcp-server.git
cd troubleshoot-mcp-server
# 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 Dependency Management Guide.
Code Style
Code formatting is done using Ruff:
# Format code with Ruff
uv run ruff format .
# 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
kubectlcommand-line toolsbctlcommand-line tool for bundle management- Token for authentication (set as
SBCTL_TOKENorREPLICATEDenvironment variable)
All dependencies are included in the Podman container, making it the recommended deployment method.
Contributing
Contributions are welcome! Please see the Developer Guide for details on how to contribute.
License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file troubleshoot_mcp_server-1.9.2.tar.gz.
File metadata
- Download URL: troubleshoot_mcp_server-1.9.2.tar.gz
- Upload date:
- Size: 63.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8785f3f2db59de092f0c62d6d7e21516e90360a94b7bcf1b77d610c8c56e1c52
|
|
| MD5 |
6c458bd3c0ad1f2c88b8eea4d522904c
|
|
| BLAKE2b-256 |
97eba2c7e6537fb464ca63ef5bf53788e36d6ac6012753442cc3caf53c37579c
|
File details
Details for the file troubleshoot_mcp_server-1.9.2-py3-none-any.whl.
File metadata
- Download URL: troubleshoot_mcp_server-1.9.2-py3-none-any.whl
- Upload date:
- Size: 66.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6eca535d53d4a36dde92caf245165763d65dd2ee219c72442ab540938f02bde1
|
|
| MD5 |
1409cd97587c09d68b2a89d6b7ea3259
|
|
| BLAKE2b-256 |
5d51d450a30f2a054cc3b46704537b91c7b42af1a106b15d81181b91524f629c
|