{"id":28955837,"url":"https://github.com/joelayo/kubectl-go-mcp-server","last_synced_at":"2026-04-17T09:31:35.397Z","repository":{"id":300743475,"uuid":"1006779853","full_name":"Joelayo/kubectl-go-mcp-server","owner":"Joelayo","description":"MCP server for secure Kubernetes Interaction via kubectl commands. Enables AI assistants like GitHub Copilot to safely interact with K8s clusters with robust validation and security.","archived":false,"fork":false,"pushed_at":"2025-10-01T06:29:47.000Z","size":72,"stargazers_count":1,"open_issues_count":3,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-09T21:14:43.907Z","etag":null,"topics":["copilot","devops","go","golang","k8s-tools","kubectl","kubernetes","mcp-server","model-context-protocol","security"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Joelayo.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-23T01:26:42.000Z","updated_at":"2025-06-29T23:40:27.000Z","dependencies_parsed_at":"2025-06-23T11:50:56.973Z","dependency_job_id":null,"html_url":"https://github.com/Joelayo/kubectl-go-mcp-server","commit_stats":null,"previous_names":["joelayo/kubectl-go-mcp-server"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/Joelayo/kubectl-go-mcp-server","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Joelayo%2Fkubectl-go-mcp-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Joelayo%2Fkubectl-go-mcp-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Joelayo%2Fkubectl-go-mcp-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Joelayo%2Fkubectl-go-mcp-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Joelayo","download_url":"https://codeload.github.com/Joelayo/kubectl-go-mcp-server/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Joelayo%2Fkubectl-go-mcp-server/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281397336,"owners_count":26493908,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-28T02:00:06.022Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["copilot","devops","go","golang","k8s-tools","kubectl","kubernetes","mcp-server","model-context-protocol","security"],"created_at":"2025-06-23T20:11:50.082Z","updated_at":"2025-10-28T06:40:48.780Z","avatar_url":"https://github.com/Joelayo.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# kubectl-go-mcp-server\r\n\r\nA Model Context Protocol (MCP) server that provides Kubernetes cluster interaction capabilities through kubectl commands. This server enables MCP-compatible clients (like VS Code with Copilot) to execute kubectl commands and retrieve Kubernetes cluster information safely and securely.\r\n\r\n## Features\r\n\r\n- **Kubernetes Integration**: Execute kubectl commands through MCP interface\r\n- **Interactive Command Protection**: Prevents execution of interactive commands that could hang\r\n- **Resource Modification Detection**: Identifies commands that modify cluster resources\r\n- **Robust Security**: Multiple validation layers to prevent command injection and unsafe operations\r\n- **Configurable Kubeconfig**: Support for custom kubeconfig paths\r\n- **Standard Go Project Layout**: Following Go best practices for maintainability\r\n- **Cobra CLI Integration**: Professional command-line interface with subcommands\r\n\r\n## Architecture\r\n\r\nkubectl-go-mcp-server acts as a bridge between MCP clients (like VS Code with Copilot) and Kubernetes clusters through kubectl commands:\r\n\r\n```\r\nVS Code/Copilot → MCP Client → kubectl-go-mcp-server → kubectl → Kubernetes Cluster\r\n```\r\n\r\n### Key Components\r\n\r\n- **MCP Server**: Handles JSON-RPC communication and tool registration\r\n- **kubectl Tool**: Validates and executes kubectl commands safely\r\n- **Security Layer**: Prevents interactive commands and command injection\r\n\r\nFor detailed architecture information, see [docs/architecture.md](docs/architecture.md).\r\n\r\n```\r\npkg/\r\n├── types/          # 🔧 Core interfaces and data structures\r\n│   ├── Tool        # Interface for all MCP tools\r\n│   ├── Schema      # JSON schema definitions\r\n│   └── ExecResult  # Command execution results\r\n│\r\n├── kubectl/        # 🎯 kubectl-specific implementation\r\n│   ├── KubectlTool # Main tool implementation\r\n│   ├── Validation  # Command safety checks\r\n│   └── Execution   # kubectl command runner\r\n│\r\ninternal/\r\n├── mcp/           # 🌐 MCP protocol implementation\r\n│   ├── Server     # MCP server and protocol handling\r\n│   ├── Tools      # Tool registry and management\r\n│   └── Protocol   # JSON-RPC message handling\r\n│\r\n└── config/        # ⚙️ Configuration management\r\n    ├── Config     # Application configuration\r\n    └── Defaults   # Default settings\r\n```\r\n\r\n### Extension Points\r\n\r\nThe architecture is designed for extensibility:\r\n\r\n1. **New Tools**: Implement the `Tool` interface to add new capabilities\r\n2. **Custom Validation**: Add validation layers for specific use cases\r\n3. **Protocol Extensions**: Extend MCP handling for additional features\r\n4. **Output Formatters**: Add custom result processing\r\n\r\n### Performance Considerations\r\n\r\n- **Concurrent Safety**: All components are designed for concurrent access\r\n- **Resource Management**: Proper cleanup and resource disposal\r\n- **Timeout Handling**: Configurable timeouts for all operations\r\n- **Memory Efficiency**: Streaming and buffered I/O for large outputs\r\n\r\n## Installation\r\n\r\n### Prerequisites\r\n\r\n- Go 1.23 or later\r\n- kubectl installed and configured\r\n- Access to a Kubernetes cluster\r\n\r\n### Build from Source\r\n\r\n```bash\r\n# Clone the repository\r\ngit clone https://github.com/Joelayo/kubectl-go-mcp-server.git\r\ncd kubectl-go-mcp-server\r\n\r\n# Build the binary\r\nmake build\r\n\r\n# Or install directly\r\nmake install\r\n```\r\n\r\n### Download Binary\r\n\r\nDownload the latest release from the [releases page](https://github.com/Joelayo/kubectl-go-mcp-server/releases) for your platform.\r\n\r\n## Usage\r\n\r\n### Standalone\r\n\r\n```bash\r\n# Run with default kubeconfig\r\n./kubectl-go-mcp-server\r\n\r\n# Run with custom kubeconfig\r\n./kubectl-go-mcp-server --kubeconfig /path/to/kubeconfig\r\n\r\n# Show version\r\n./kubectl-go-mcp-server version\r\n```\r\n\r\n### VS Code Integration\r\n\r\nTo use with VS Code and Copilot, add this MCP server to your VS Code settings:\r\n\r\n```json\r\n{\r\n  \"mcp\": {\r\n    \"servers\": {\r\n      \"kubectl-go-mcp-server\": {\r\n        \"type\": \"stdio\",\r\n        \"command\": \"/path/to/kubectl-go-mcp-server\",\r\n        \"env\": {}\r\n      }\r\n    }\r\n  }\r\n}\r\n```\r\n\r\nFor platform-specific installation details, see the [examples directory](./examples/).\r\n\r\n## Available Tools\r\n\r\nThe MCP server provides the following tool:\r\n\r\n### kubectl\r\n\r\nExecute kubectl commands with comprehensive validation and safety checks.\r\n\r\n**Parameters:**\r\n\r\n- `command` (required): The complete kubectl command to execute (including 'kubectl' prefix)\r\n- `modifies_resource` (optional): Indicates if the command modifies resources (\"yes\", \"no\", \"unknown\")\r\n\r\n**Example:**\r\n\r\n```json\r\n{\r\n  \"name\": \"kubectl\",\r\n  \"arguments\": {\r\n    \"command\": \"kubectl get pods -o json\",\r\n    \"modifies_resource\": \"no\"\r\n  }\r\n}\r\n```\r\n\r\n**Safety Features:**\r\n\r\n- **Interactive Command Detection**: Prevents hanging on interactive commands like `kubectl exec -it`, `kubectl edit`, `kubectl port-forward`\r\n- **Resource Modification Tracking**: Automatically detects destructive operations\r\n- **Command Validation**: Ensures only valid kubectl commands are executed\r\n\r\n## Security\r\n\r\nThis server implements multiple security layers including command validation, injection prevention, and interactive command blocking. For detailed security information, see:\r\n\r\n- [Security Overview](docs/security.md) - Technical security implementation details\r\n- [Security Policy](SECURITY.md) - Vulnerability reporting and security best practices\r\n\r\n## Development\r\n\r\nSee [CONTRIBUTING.md](CONTRIBUTING.md) for development setup, workflow, and contribution guidelines.\r\n\r\n### Quick Start for Developers\r\n\r\n```bash\r\n# Install dependencies and build\r\nmake deps \u0026\u0026 make build\r\n\r\n# Run tests\r\nmake test\r\n\r\n# Format and lint code  \r\nmake fmt \u0026\u0026 make lint\r\n```\r\n\r\n## Troubleshooting\r\n\r\n### Common Issues\r\n\r\n- **Server not responding**: Verify kubectl is installed and kubeconfig is accessible\r\n- **Interactive command errors**: Use non-interactive alternatives (see [Security Overview](docs/security.md))\r\n- **Permission denied**: Check kubectl permissions and cluster connectivity\r\n\r\nFor detailed debugging information, the server logs all tool calls, validation results, and errors.\r\n\r\n## Support\r\n\r\n- [Create an issue](https://github.com/Joelayo/kubectl-go-mcp-server/issues) for bug reports or feature requests\r\n- Check [existing issues](https://github.com/Joelayo/kubectl-go-mcp-server/issues) for known problems\r\n- See [CONTRIBUTING.md](CONTRIBUTING.md) for development questions\r\n\r\n## License\r\n\r\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoelayo%2Fkubectl-go-mcp-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoelayo%2Fkubectl-go-mcp-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoelayo%2Fkubectl-go-mcp-server/lists"}