k8s-mcp-server

Manage Your Kubernetes Cluster with k8s mcp-server

GitHub Stars

75

User Rating

Not Rated

Favorites

0

Views

63

Forks

14

Issues

2

Installation
Difficulty
Intermediate
Estimated Time
10-20 minutes
Requirements
Go 1.23 or later
Access to a Kubernetes cluster
+1 more

Installation

Installation

Prerequisites

Go: 1.23 or later
Access to a Kubernetes cluster
kubectl configured with appropriate cluster access

Installation Steps

1. Clone Repository

bash
git clone https://github.com/reza-gholizade/k8s-mcp-server.git
cd k8s-mcp-server

2. Install Dependencies

bash
go mod download

3. Build the Server

bash
go build -o k8s-mcp-server main.go

Troubleshooting

Common Issues

Issue: Server won't start Solution: Check Go version and reinstall dependencies.

Configuration

Configuration

Basic Configuration

Starting the Server

The server can run in two modes, configurable via command-line flags or environment variables. #### Stdio Mode (for CLI integrations) This mode uses standard input/output for communication.
bash
./k8s-mcp-server --mode stdio
#### SSE Mode (for web applications) This mode starts an HTTP server with Server-Sent Events support. Default (port 8080):
bash
./k8s-mcp-server --mode sse
Specify a port:
bash
./k8s-mcp-server --mode sse --port 9090

Using the Docker Image

You can also run the server using the pre-built Docker image from Docker Hub.
1Pull the image:
bash
docker pull ginnux/k8s-mcp-server:latest
2Run the container:
bash
docker run -p 8080:8080 -v ~/.kube/config:/home/appuser/.kube/config:ro ginnux/k8s-mcp-server

Examples

Examples

Starting the Server

To start the server, execute the following command.

Start in Stdio Mode

bash
./k8s-mcp-server --mode stdio

Start in SSE Mode

bash
./k8s-mcp-server --mode sse

Programmatic Usage

javascript
// JavaScript example (Node.js)
const { MCPClient } = require('@modelcontextprotocol/client');

const client = new MCPClient();
await client.connect();

// Execute tool
const result = await client.callTool('toolName', {
  parameter1: 'value1',
  parameter2: 'value2'
});

console.log(result);

Use Cases

Filtering and listing resources within a Kubernetes cluster to check the status of a specific application.
Retrieving logs from a specific pod for application debugging.
Creating new Kubernetes resources from a YAML file to automate deployments.
Fetching node metrics from a Kubernetes cluster to monitor resource usage.

Additional Resources