You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This repository contains a Go implementation of a Model Context Protocol (MCP)
4
-
server for Kubernetes and OpenShift.
5
-
6
-
## Repository layout
7
-
8
-
-`cmd/kubernetes-mcp-server/` – entry point and Cobra CLI.
9
-
-`pkg/` – libraries grouped by domain (`kubernetes`, `mcp`, `output`, …).
1
+
# Project Agents.md for Kubernetes MCP Server
2
+
3
+
This Agents.md file provides comprehensive guidance for AI assistants and coding agents (like Claude, Gemini, Cursor, and others) to work with this codebase.
4
+
5
+
This repository contains the kubernetes-mcp-server project,
6
+
a powerful Go-based Model Context Protocol (MCP) server that provides native Kubernetes and OpenShift cluster management capabilities without external dependencies.
7
+
This MCP server enables AI assistants (like Claude, Gemini, Cursor, and others) to interact with Kubernetes clusters using the Model Context Protocol (MCP).
8
+
9
+
## Project Structure and Repository layout
10
+
11
+
- Go package layout follows the standard Go conventions:
12
+
-`cmd/kubernetes-mcp-server/` – main application entry point using Cobra CLI framework.
13
+
-`pkg/` – libraries grouped by domain.
14
+
-`config/` – configuration management.
15
+
-`helm/` - Helm chart operations integration.
16
+
-`http/` - HTTP server and authorization middleware.
17
+
-`kubernetes/` - Kubernetes client management, authentication, and access control.
18
+
-`mcp/` - Model Context Protocol (MCP) server implementation with tool registration and STDIO/HTTP support.
-`npm/` – Node packages that wraps the compiled binaries for distribution through npmjs.com.
23
+
-`python/` – Python package providing a script that downloads the correct platform binary from the GitHub releases page and runs it for distribution through pypi.org.
24
+
-`Dockerfile` - container image description file to distribute the server as a container image.
10
25
-`Makefile` – tasks for building, formatting, linting and testing.
11
-
-`npm/` – Node packages that wrap the compiled binary. The `kubernetes-mcp-server` package
12
-
defines a small launcher in `bin/index.js` which resolves the platform specific
13
-
optional dependency (`kubernetes-mcp-server-<os>-<arch>`) and executes it.
14
-
-`python/` – Python package providing a script that downloads the correct
15
-
platform binary from the GitHub releases page and runs it.
16
26
17
27
## Feature development
18
28
19
29
Implement new functionality in the Go sources under `cmd/` and `pkg/`.
20
-
The JavaScript and Python directories only wrap the compiled binary for
21
-
distribution (npm and PyPI). Most changes will not require touching them
22
-
unless the version or packaging needs to be updated.
30
+
The JavaScript (`npm/`) and Python (`python/`) directories only wrap the compiled binary for distribution (npm and PyPI).
31
+
Most changes will not require touching them unless the version or packaging needs to be updated.
23
32
24
33
## Building
25
34
@@ -33,8 +42,8 @@ make build
33
42
make build-all-platforms
34
43
```
35
44
36
-
`make build` will run `go fmt` and `go mod tidy` before compiling. The
37
-
resulting executable is `kubernetes-mcp-server`.
45
+
`make build` will run `go fmt` and `go mod tidy` before compiling.
46
+
The resulting executable is `kubernetes-mcp-server`.
The server is typically run locally and connects to the cluster using the same
50
-
configuration loading rules as `kubectl`. When started with `npx` or `uvx` it
51
-
downloads and executes a platform specific binary. The running process then
52
-
reads the kubeconfig resolved from the `--kubeconfig` flag, the `KUBECONFIG`
53
-
environment variable or the default `~/.kube/config` file. If those are not
54
-
present and the process executes inside a pod it falls back to in-cluster
55
-
configuration. This means that `npx kubernetes-mcp-server` on a workstation will
56
-
talk to whatever cluster your current kubeconfig points to (e.g. a local Kind
57
-
cluster).
58
+
To run the server locally, you can use `npx`, `uvx` or execute the binary directly:
59
+
60
+
```bash
61
+
# Using npx (Node.js package runner)
62
+
npx -y kubernetes-mcp-server@latest
63
+
64
+
# Using uvx (Python package runner)
65
+
uvx kubernetes-mcp-server@latest
66
+
67
+
# Binary execution
68
+
./kubernetes-mcp-server
69
+
```
70
+
71
+
This MCP server is designed to run both locally and remotely.
72
+
73
+
### Local Execution
74
+
75
+
When running locally, the server connects to a Kubernetes or OpenShift cluster using the kubeconfig file.
76
+
It reads the kubeconfig from the `--kubeconfig` flag, the `KUBECONFIG` environment variable, or defaults to `~/.kube/config`.
77
+
78
+
This means that `npx -y kubernetes-mcp-server@latest` on a workstation will talk to whatever cluster your current kubeconfig points to (e.g. a local Kind cluster).
79
+
80
+
### Remote Execution
81
+
82
+
When running remotely, the server can be deployed as a container image in a Kubernetes or OpenShift cluster.
83
+
The server can be run as a Deployment, StatefulSet, or any other Kubernetes resource that suits your needs.
84
+
The server will automatically use the in-cluster configuration to connect to the Kubernetes API server.
58
85
59
86
## Tests
60
87
@@ -64,10 +91,9 @@ Run all Go tests with:
64
91
make test
65
92
```
66
93
67
-
The test suite relies on the `setup-envtest` tooling from
68
-
`sigs.k8s.io/controller-runtime`. The first run downloads a Kubernetes
69
-
`envtest` environment from the internet, so network access is required. Without
70
-
it some tests will fail during setup.
94
+
The test suite relies on the `setup-envtest` tooling from `sigs.k8s.io/controller-runtime`.
95
+
The first run downloads a Kubernetes `envtest` environment from the internet, so network access is required.
96
+
Without it some tests will fail during setup.
71
97
72
98
## Linting
73
99
@@ -77,17 +103,26 @@ Static analysis is performed with `golangci-lint`:
77
103
make lint
78
104
```
79
105
80
-
The `lint` target downloads the specified `golangci-lint` version if it is not
81
-
already present under `_output/tools/bin/`.
106
+
The `lint` target downloads the specified `golangci-lint` version if it is not already present under `_output/tools/bin/`.
82
107
83
108
## Dependencies
84
109
85
-
When introducing new modules run `go mod tidy` (or `make tidy`) so that
86
-
`go.mod` and `go.sum` remain tidy.
110
+
When introducing new modules run `make tidy` so that `go.mod` and `go.sum` remain tidy.
87
111
88
112
## Coding style
89
113
90
114
- Go modules target Go **1.24** (see `go.mod`).
91
115
- Tests are written with the standard library `testing` package.
92
116
- Build, test and lint steps are defined in the Makefile—keep them working.
93
117
118
+
## Distribution Methods
119
+
120
+
The server is distributed as a binary executable, a Docker image, an npm package, and a Python package.
121
+
122
+
-**Native binaries** for Linux, macOS, and Windows are available in the GitHub releases.
123
+
- A **container image** (Docker) is built and pushed to the `quay.io/manusa/kubernetes_mcp_server` repository.
124
+
- An **npm** package is available at [npmjs.com](https://www.npmjs.com/package/kubernetes-mcp-server).
125
+
It wraps the platform-specific binary and provides a convenient way to run the server using `npx`.
126
+
- A **Python** package is available at [pypi.org](https://pypi.org/project/kubernetes-mcp-server/).
127
+
It provides a script that downloads the correct platform binary from the GitHub releases page and runs it.
128
+
It provides a convenient way to run the server using `uvx` or `python -m kubernetes_mcp_server`.
0 commit comments