Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .testcoverage.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Coverage threshold gate for the mcp-server module.
# Enforced by `make cover-go-check` via go-test-coverage/v2.
# Enforced in CI by Gameplane's shared go-component.yaml workflow (go-test-coverage/v2).
#
# The server is a thin, strictly read-only MCP tool surface: the tests cover
# tool registration (including the read-only invariant — no mutating verb
Expand Down
22 changes: 22 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# mcp-server — AI assistant guide

This repository holds the optional, strictly read-only MCP server (stdio) for cluster debugging. It is a split component of [GameplanePanel/Gameplane](https://github.com/GameplanePanel/Gameplane), checked out there as the `mcp-server/` submodule (the repository is named `mcp`, the folder is `mcp-server/`). What it does and its contracts: [`specs.md`](specs.md).

## How it fits into Gameplane

- **Own Go module**, not part of Gameplane's `go.work`. Build and test from this repository's root: `go build ./...` (inside a Gameplane checkout, prefix `GOWORK=off`).
- **CI** is `.github/workflows/ci.yaml`, a thin caller of Gameplane's shared [`go-component.yaml`](https://github.com/GameplanePanel/Gameplane/blob/master/.github/workflows/go-component.yaml), pinned by SHA: lint with Gameplane's root `.golangci.yml` and `.hadolint.yaml` (no copy here), race tests on amd64 and arm64 with the `.testcoverage.yml` gate, govulncheck, and an image build. Dependabot runs in this repository.
- **Images** `mcp-server` (`Dockerfile`, built by `make image-mcp-server`) are built and published from the Gameplane repository root: the Dockerfiles copy `mcp-server/...` from that build context.
- **Callers live in Gameplane:** paths such as `operator/`, `api/`, `charts/`, `docs/` and `web/` in `specs.md` and code comments refer to that repository.
- **Shipping a change:** PR to `main` here → after it merges, bump the `mcp-server` pointer in Gameplane (`git -C mcp-server checkout <merged sha on main>`, `git add mcp-server`) in a Gameplane PR. A user-visible change gets its `changelog/unreleased/` entry in that Gameplane PR.

## Rules

Gameplane's [`AGENTS.md`](https://github.com/GameplanePanel/Gameplane/blob/master/AGENTS.md) core rules apply here. The ones that matter most in this repository:

- **CI verifies:** locally only compile checks (`go build ./...`); never run test or lint suites locally.
- **Fix, don't silence:** no `//nolint` and no per-repository `.golangci.yml`; `_test.go` files are exempt from `errcheck`/`gosec`/`unparam` through the shared config.
- **Go errors:** wrap with `%w`.
- **Tests:** never delete or weaken a test without the maintainer's explicit sign-off; fix the code.
- **Git:** signed commits (`git commit -s`), conventional prefixes (`feat:`, `fix:`, `chore:`, `docs:` …), one branch per unit of work, never amend pushed commits; delete the branch after merge.
- **Docs:** keep `specs.md` in step with behaviour changes in the same PR.
1 change: 1 addition & 0 deletions CLAUDE.md
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# mcp-server

> This repository is checked out as the `mcp-server/` submodule of [GameplanePanel/Gameplane](https://github.com/GameplanePanel/Gameplane). Paths such as `docs/`, `operator/`, `api/`, `charts/` and `web/` below refer to that repository.

The **mcp-server** [optional] is a strictly **read-only** [Model Context Protocol](https://modelcontextprotocol.io/)
(MCP) server for Gameplane clusters. It lets an AI assistant read cluster
state — 7 of Gameplane's 9 CRDs (not Cluster or NetworkCapture), Pods, Events, and pod logs — and get a
Expand Down Expand Up @@ -59,7 +61,7 @@ but install it with that blast radius in mind: anyone who can
MCP client already wired to it) can read logs and object state for
*any* pod in the cluster, not just Gameplane-managed ones. If that's wider
than you want, don't enable `mcpServer` on a cluster that also runs
unrelated, more sensitive workloads. See `docs/security.md` for the rest of
unrelated, more sensitive workloads. See [`docs/security.md`](https://github.com/GameplanePanel/Gameplane/blob/master/docs/security.md) for the rest of
the threat model.

## Tools
Expand Down
17 changes: 8 additions & 9 deletions specs.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# mcp-server — Specification

> This repository is checked out as the `mcp-server/` submodule of [GameplanePanel/Gameplane](https://github.com/GameplanePanel/Gameplane). Paths such as `docs/`, `operator/`, `api/`, `charts/` and `web/` below refer to that repository.

**Status:** pre-v1 (v0.4.1)
**Module / package:** `github.com/GameplanePanel/gameplane/mcp-server`

Expand Down Expand Up @@ -145,14 +147,14 @@ From `go.mod` (verified):
| `k8s.io/client-go` | v0.37.0 | Kubernetes typed clientset, dynamic client, rest.Config |
| `sigs.k8s.io/controller-runtime` | v0.25.1 | `ctrl.GetConfig()` for kubeconfig loading |

**Why these versions?** Pinned to match the operator's dependencies for consistency across the workspace (via `go.work`).
**Why these versions?** Kept in step with the Gameplane operator's Kubernetes dependencies; Dependabot in this repository proposes updates.

## Security considerations

1. **Read-only blast radius**: The ClusterRole grants get/list/watch cluster-wide (all namespaces), not just `gameplane-games`. Pod logs in any namespace may contain application secrets (API keys, connection strings); this is an accepted tradeoff on an opt-in component.
2. **No listening port**: No network surface to expose; reachable only via `kubectl exec`.
3. **Deployment model**: Opt-in via `mcpServer.enabled=true` in the Helm chart. Admin responsibility to decide if this is acceptable for their cluster.
4. **See `docs/security.md`** for the full threat model and per-cluster decisions (especially if cohabiting with unrelated sensitive workloads).
4. **See [`docs/security.md`](https://github.com/GameplanePanel/Gameplane/blob/master/docs/security.md)** for the full threat model and per-cluster decisions (especially if cohabiting with unrelated sensitive workloads).

## Testing & coverage

Expand All @@ -165,12 +167,10 @@ From `go.mod` (verified):

### Test commands

Run via the workspace root Makefile:
Run from this repository's root (CI runs the same through Gameplane's shared `go-component.yaml` workflow):

```sh
make test-go # Runs all Go tests, including mcp-server
make cover # Full coverage report with gate checks
cd mcp-server && go test ./... # Isolated run
go test -race ./...
```

### Key test cases
Expand All @@ -185,9 +185,8 @@ From `main_test.go`:

## References

- **`mcp-server/README.md`** — run instructions, transport details, RBAC blast radius, tool descriptions.
- **[`README.md`](README.md)** — run instructions, transport details, RBAC blast radius, tool descriptions.
- **`charts/gameplane/templates/mcp-server.yaml`** — Helm template (ServiceAccount, ClusterRole, Deployment).
- **`docs/security.md`** — threat model, mcp-server section, admin decision guidance.
- **`go.work`** — workspace that links all Go modules (operator, api, agent, mcp-server, etc.).
- **[`docs/security.md`](https://github.com/GameplanePanel/Gameplane/blob/master/docs/security.md)** — threat model, mcp-server section, admin decision guidance.
- **Model Context Protocol spec** — https://modelcontextprotocol.io/

4 changes: 2 additions & 2 deletions system-deps.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ component = "mcp-server"
name = "go"
kind = "toolchain"
version = "go"
reason = "Compiles and tests the mcp-server module (go.work:3-21; inventory 2.1)."
reason = "Compiles and tests the mcp-server module."

[[dep]]
name = "golangci-lint"
kind = "cli"
version = "golangci_lint"
reason = "make lint-go runs golangci-lint in this module (Makefile:302-305; GO_MODULES at Makefile:43)."
reason = "golangci-lint runs on this module with Gameplane's root .golangci.yml (shared go-component.yaml workflow)."
Loading