MCP Examples

Real-world examples showing how to use Kubiya’s MCP server with different AI assistants and use cases.

Quick Start Examples

1. Basic Tool Execution

Ask your AI assistant (Claude, Cursor, etc.):

"Can you check the health of our Kubernetes cluster?"

Kubiya will execute:

  • kubectl get nodes - Check node health
  • kubectl get pods --all-namespaces - List all pods
  • kubectl top nodes - Check resource usage

2. Execute Custom Script

"Run a Python script that analyzes our application logs"

Kubiya will:

  • Create a Python container
  • Execute your analysis script
  • Return results with live streaming

3. Multi-Step Workflow

"Deploy version 2.1.0 to staging, run tests, and promote to production if successful"

Kubiya handles the entire pipeline:

  • Build Docker image
  • Deploy to staging
  • Run integration tests
  • Promote to production if tests pass

AI Assistant Integrations

Claude Desktop

After configuring Claude Desktop with the MCP server:

{
  "mcpServers": {
    "kubiya": {
      "command": "kubiya",
      "args": ["mcp", "serve"],
      "env": {
        "KUBIYA_API_KEY": "your-api-key"
      }
    }
  }
}

Try these commands:

Infrastructure Management:

"List all runners and check their health status"
"Execute kubectl get pods in production namespace"
"Check disk space on all servers"

Automation:

"Create a backup of our PostgreSQL database"
"Deploy the latest version of our API service"
"Run our nightly data processing job"

Cursor IDE

With Cursor configured:

{
  "mcp.servers": {
    "kubiya": {
      "command": "kubiya",
      "args": ["mcp", "serve"],
      "env": {
        "KUBIYA_API_KEY": "your-api-key"
      }
    }
  }
}

Use in Composer:

Development Workflow:

"Use Kubiya to run our test suite on the dev cluster"
"Deploy this branch to staging for testing"
"Check the logs for any errors in the last hour"

Code Analysis:

"Run security scans on our codebase"
"Check code coverage for our tests"
"Analyze performance metrics for our API"

Real-World Use Cases

1. DevOps Assistant

Request: “Our application seems slow, can you investigate?”

AI + Kubiya Response:

  1. Checks application metrics using monitoring tools
  2. Analyzes recent logs for errors
  3. Examines resource usage (CPU, memory, disk)
  4. Identifies bottlenecks
  5. Suggests optimizations

Example Tools Used:

  • execute_tool with kubectl commands
  • execute_tool with custom monitoring scripts
  • search_kb for troubleshooting guides

2. Database Operations

Request: “Create a backup of our production database”

Kubiya executes:

# Create timestamped backup
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
pg_dump -h prod-db -U backup_user myapp > backup_${TIMESTAMP}.sql

# Compress backup
gzip backup_${TIMESTAMP}.sql

# Upload to S3
aws s3 cp backup_${TIMESTAMP}.sql.gz s3://db-backups/myapp/

3. Security Scanning

Request: “Check for any security issues in our infrastructure”

AI + Kubiya:

  1. Scans container images for vulnerabilities
  2. Checks Kubernetes configurations for security issues
  3. Reviews access controls and permissions
  4. Validates compliance with security policies
  5. Generates comprehensive security report

4. Data Processing Pipeline

Request: “Process today’s user analytics and update the dashboard”

Kubiya Pipeline:

  1. Extracts data from multiple sources (databases, APIs)
  2. Runs ETL transformations using pandas/numpy
  3. Validates data quality
  4. Updates data warehouse
  5. Refreshes BI dashboards

Advanced Examples

1. Multi-Cloud Deployment

Request: “Deploy our application to both AWS and GCP”

Kubiya orchestrates:

  • AWS ECS deployment
  • GCP Cloud Run deployment
  • Load balancer configuration
  • Health checks for both environments

2. Incident Response

Request: “We have a P1 incident, please investigate and remediate”

AI + Kubiya:

  1. Gathers system metrics and logs
  2. Identifies root cause
  3. Implements immediate fixes
  4. Scales resources if needed
  5. Documents incident timeline

3. CI/CD Pipeline

Request: “Set up continuous deployment for our new microservice”

Kubiya configures:

  • GitHub Actions workflow
  • Docker build and push
  • Kubernetes deployment
  • Testing and validation
  • Rollback mechanisms

Integration Patterns

1. Tool Chaining

Execute multiple tools in sequence:

"First check the database connections, then restart any failed services, and finally verify everything is working"

2. Conditional Execution

Use logic in your requests:

"If the staging tests pass, deploy to production, otherwise send me the test results"

3. Parallel Processing

Handle multiple tasks simultaneously:

"Check the health of all our services and generate a status report"

Configuration Examples

Basic Configuration

{
  "enable_runners": true,
  "allow_platform_apis": false,
  "enable_opa_policies": false,
  "verbose_logging": false
}

Enterprise Configuration

{
  "enable_runners": true,
  "allow_platform_apis": true,
  "enable_opa_policies": true,
  "verbose_logging": true,
  "whitelisted_tools": [
    {
      "name": "kubectl",
      "description": "Kubernetes CLI tool",
      "type": "docker",
      "image": "kubiya/kubectl-light:latest"
    }
  ]
}

Error Handling

Graceful Failure

When tools fail, Kubiya provides detailed error information:

"The kubectl command failed because the cluster is unreachable. 
Would you like me to try connecting to the backup cluster?"

Retry Logic

Built-in retry mechanisms for transient failures:

"Retrying connection to database... (attempt 2/3)"

Monitoring and Logging

Execution Tracking

All tool executions are logged with:

  • Execution time
  • Exit codes
  • Resource usage
  • Error messages

Debug Mode

Enable detailed logging:

kubiya mcp serve --verbose

Best Practices

1. Security First

  • Always use appropriate access controls
  • Enable OPA policies for production
  • Regularly rotate API keys
  • Monitor tool execution logs

2. Resource Management

  • Use appropriate runners for different workloads
  • Monitor resource usage
  • Set timeouts for long-running tasks

3. Error Handling

  • Implement proper error handling
  • Use retries for transient failures
  • Provide meaningful error messages

Next Steps