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
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Standalone integration of the upstream alert management toolset (`observability/alert-management`) with MCP tools for listing alerts and listing, creating, updating, deleting, and previewing OpenShift alert rules via the monitoring-plugin management API ([#171](https://github.com/rhobs/obs-mcp/pull/171))
- Alertmanager silence write tools: `create_silence`, `update_silence`, and `delete_silence` (alongside existing `get_silences`)
- Sample ConfigMaps include `observability/alert-management` for listing and previewing; writes remain disabled by default
- E2E tests for silence writes, `list_alerts`, `list_alert_rules`, user-defined alert-rule create/update/delete, and platform drop/restore via `alerting_rule_enabled` (skipped when the management API is unreachable). Kind does not install monitoring-plugin.
- mcpchecker evals for listing rules, listing alerts, and previewing (default `eval.yaml`). Mutating CRUD, platform drop/restore, and silence create/expire live in `evals/mcpchecker/eval-writes.yaml`

### Changed

- Move observability toolsets and shared `pkg/obs` packages into [kubernetes-mcp-server](https://github.com/containers/kubernetes-mcp-server); obs-mcp is now a thin standalone host ([#213](https://github.com/rhobs/obs-mcp/pull/213))
Expand All @@ -18,11 +26,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Document that tool/toolset contributions belong in kubernetes-mcp-server; retarget the kube-mcp-sync skill for host adapter audits
- Broaden Containerfile OCI image description for current observability backends
- Remove unused `GetKubeClient` helper
- Standalone `--read-only` defaults to true (kubernetes-mcp `read_only` flag; OpenShift Lightspeed defaults that on). Silence writes and alert-rule create/update/delete are not registered until `--read-only=false`. `--disable-destructive` hides DestructiveHint tools. Sample ConfigMaps set `read-only: "true"` / `read_only = true`. E2E deploy and `make test-e2e-run` set `--read-only=false`.
- `update_alert_rule` is annotated as destructive (`DestructiveHint`) because it can drop a platform alert
- GitOps `preview_alert_rule` returns typed `resources` (kind, namespace, name, changes, `desiredObject`) and `gitApplyHint` as a Git recipe. This toolset does not open pull requests; a git or GitHub MCP or the host applies the manifest.
- Delete user-created rules, or platform rules in a writable AlertingRule. CMO/operator platform rules are dropped (`alerting_rule_enabled=false`), not deleted. GitOps writes are 405. User-created rules can be fully edited in the plugin; this PATCH does not send expr/name/for/annotations. Platform updates are labels, classification, and drop/restore only.

### Breaking

- Reject `--insecure`: observability backends now require a trusted CA (kubeconfig `CertificateAuthorityData` / in-cluster service CA). Remove `--insecure` from CLI, manifests, and local `make run` targets.

### Fixed

- Read-only mode instructs the agent to tell the user to set `--read-only=false` (or openshift-mcp-server `read_only = false`) when they ask to change a rule, instead of calling a missing write tool
- Skip `list_alert_rules` e2e only for transport failures and the stock-plugin `404 page not found` body, not every HTTP 404, generic `page not found`, or TLS error
- Dedicated `namespace` on platform create/preview overrides `labels.namespace`
- `update_silence` parameter docs no longer claim create-time defaults for omitted `createdBy`, `startsAt`, or `duration`
- Refuse HTTPS-to-HTTP redirects so bearer tokens stay on TLS
- The upstream client rejects insecure TLS and requires a trusted CA. Sample in-cluster Deployment and `make run` no longer pass `--insecure`. In-cluster kubeconfig uses Loki/Tempo service DNS (service CA) unless `--loki.use-route` / `--traces.use-route` is set.
- Silence-write e2e skips when the runner cannot get namespaces or create Roles (Prow test SA)
- Wait for e2e Deployments without `kubectl wait --for=create`, which older `oc` rejects

## [v0.8.1] - 2026-10-01

### Fixed
Expand Down
14 changes: 8 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -146,25 +146,27 @@ LISTEN_ADDR ?= :9100
LOG_LEVEL ?= debug
AUTH_MODE ?= kubeconfig
TOOLSETS ?= observability/metrics
READ_ONLY ?= true
RUN_FLAGS ?= --loki.use-route

.PHONY: run
run: build ## Run obs-mcp in HTTP mode (use LOG_LEVEL=debug to see backend call timings)
@echo "Tip: Override backend URLs with PROMETHEUS_URL=https://... ALERTMANAGER_URL=https://... make run"
@echo "Tip: Override toolsets with TOOLSETS=observability/metrics,observability/traces,observability/otelcol make run"
@echo "Tip: Register write tools with READ_ONLY=false make run (default is read-only)"
@echo "Note: AUTH_MODE=serviceaccount or header requires PROMETHEUS_URL and ALERTMANAGER_URL to be set"
./obs-mcp --listen $(LISTEN_ADDR) --auth-mode $(AUTH_MODE) --log-level $(LOG_LEVEL) --toolsets $(TOOLSETS) $(RUN_FLAGS)
./obs-mcp --listen $(LISTEN_ADDR) --auth-mode $(AUTH_MODE) --log-level $(LOG_LEVEL) --toolsets $(TOOLSETS) --read-only=$(READ_ONLY) $(RUN_FLAGS)

.PHONY: run-no-guardrails
run-no-guardrails: build ## Run obs-mcp in HTTP mode with guardrails disabled
@echo "Tip: Override backend URLs with PROMETHEUS_URL=https://... ALERTMANAGER_URL=https://... make run-no-guardrails"
@echo "Note: AUTH_MODE=serviceaccount or header requires PROMETHEUS_URL and ALERTMANAGER_URL to be set"
./obs-mcp --listen $(LISTEN_ADDR) --auth-mode $(AUTH_MODE) --log-level $(LOG_LEVEL) --toolsets $(TOOLSETS) --guardrails none $(RUN_FLAGS)
./obs-mcp --listen $(LISTEN_ADDR) --auth-mode $(AUTH_MODE) --log-level $(LOG_LEVEL) --toolsets $(TOOLSETS) --read-only=$(READ_ONLY) --guardrails none $(RUN_FLAGS)

.PHONY: run-prometheus
run-prometheus: build ## Run obs-mcp with Prometheus as the metrics backend
@echo "Tip: Override backend URL with PROMETHEUS_URL=https://... make run-prometheus"
./obs-mcp --listen $(LISTEN_ADDR) --auth-mode $(AUTH_MODE) --metrics-backend prometheus --log-level $(LOG_LEVEL) --toolsets $(TOOLSETS) $(RUN_FLAGS)
./obs-mcp --listen $(LISTEN_ADDR) --auth-mode $(AUTH_MODE) --metrics-backend prometheus --log-level $(LOG_LEVEL) --toolsets $(TOOLSETS) --read-only=$(READ_ONLY) $(RUN_FLAGS)


.PHONY: pf-alertmanager
Expand All @@ -180,7 +182,7 @@ run-openshift-pf-prometheus: build pf-alertmanager ## Port-forward prometheus-k8
sleep 2; \
trap "kill $$PF_PID 2>/dev/null" EXIT; \
PROMETHEUS_URL=http://localhost:9090 ALERTMANAGER_URL=http://localhost:9093 \
./obs-mcp --listen $(LISTEN_ADDR) --auth-mode header --log-level $(LOG_LEVEL)
./obs-mcp --listen $(LISTEN_ADDR) --auth-mode header --log-level $(LOG_LEVEL) --read-only=$(READ_ONLY)

.PHONY: run-pf-loki
run-pf-loki: build ## Port-forward loki and start obs-mcp with header auth
Expand All @@ -190,7 +192,7 @@ run-pf-loki: build ## Port-forward loki and start obs-mcp with header auth
sleep 2; \
trap "kill $$PF_LOKI_PID 2>/dev/null" EXIT; \
LOKI_URL=http://localhost:8080 \
./obs-mcp --listen $(LISTEN_ADDR) --auth-mode header --log-level $(LOG_LEVEL) --toolsets observability/logs
./obs-mcp --listen $(LISTEN_ADDR) --auth-mode header --log-level $(LOG_LEVEL) --toolsets observability/logs --read-only=$(READ_ONLY)

.PHONY: inspect
inspect: COMPOSE_HOST_GATEWAY = $(if $(filter podman,$(CONTAINER_CLI)),host.containers.internal,host.docker.internal)
Expand Down Expand Up @@ -266,7 +268,7 @@ RUNS ?= 1
EVAL_CONFIG ?= eval.yaml

.PHONY: run-mcpchecker-eval
run-mcpchecker-eval: $(MCPCHECKER) ## Run mcpchecker eval (TASK=name, CATEGORY=..., EVAL_CONFIG=eval.yaml, RUNS=3)
run-mcpchecker-eval: $(MCPCHECKER) ## Run mcpchecker eval (TASK=name, CATEGORY=..., EVAL_CONFIG=eval.yaml or eval-writes.yaml, RUNS=3)
@yq -i '.mcpServers.obs.headers.Authorization = "Bearer '"$$(kubectl -n obs-mcp create token obs-mcp)"'"' $(MCPCHECKER_EVAL_DIR)/mcp-config.yaml

ifdef TASK
Expand Down
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![e2e](https://github.com/rhobs/obs-mcp/actions/workflows/e2e.yaml/badge.svg)](https://github.com/rhobs/obs-mcp/actions/workflows/e2e.yaml)
[![docs](https://github.com/rhobs/obs-mcp/actions/workflows/docs.yaml/badge.svg)](https://github.com/rhobs/obs-mcp/actions/workflows/docs.yaml)

obs-mcp is an [MCP](https://modelcontextprotocol.io/introduction) server that lets LLMs query [Prometheus](https://prometheus.io/) or [Thanos Querier](https://thanos.io/) and [Alertmanager](https://prometheus.io/docs/alerting/latest/alertmanager/) in Kubernetes. It optionally supports [Loki](https://grafana.com/oss/loki/) for logs, [Grafana Tempo](https://grafana.com/docs/tempo/latest/) for traces, and [OpenTelemetry Collector](https://opentelemetry.io/docs/collector/) configuration assistance. Enable additional toolsets with `--toolsets` (e.g., `--toolsets observability/metrics,observability/logs,observability/traces,observability/otelcol`).
obs-mcp is an [MCP](https://modelcontextprotocol.io/introduction) server that lets LLMs query [Prometheus](https://prometheus.io/) or [Thanos Querier](https://thanos.io/) and [Alertmanager](https://prometheus.io/docs/alerting/latest/alertmanager/) in Kubernetes, including listing, creating, updating, and deleting Alertmanager silences. It optionally supports [Loki](https://grafana.com/oss/loki/) for logs, [Grafana Tempo](https://grafana.com/docs/tempo/latest/) for traces, [OpenTelemetry Collector](https://opentelemetry.io/docs/collector/) configuration assistance, and OpenShift alert-rule management via the monitoring-plugin management API. Enable additional toolsets with `--toolsets` (e.g., `--toolsets observability/metrics,observability/logs,observability/traces,observability/otelcol,observability/alert-management`).

> [!IMPORTANT]
> **Observability toolsets live upstream.** Tool definitions, handlers, and shared backend clients were moved into [kubernetes-mcp-server](https://github.com/containers/kubernetes-mcp-server) (`pkg/toolsets/{metrics,logs,traces,otelcol}` and `pkg/obs/`). **Contribute toolset changes there** — not in this repo. obs-mcp is a thin standalone host (CLI, MCP adapter, deployment, evals). See [Contributing](CONTRIBUTING.md).
Expand Down Expand Up @@ -36,6 +36,9 @@ This will auto-discover the metrics backend in OpenShift. By default, it tries `
> [!NOTE]
> TLS to observability backends must verify with a trusted CA (kubeconfig `certificate-authority-data`, in-cluster service CA, or system trust store). `--insecure` is rejected.

> [!WARNING]
> Observability backends require verified TLS with a trusted CA and matching hostname. Insecure TLS is rejected. Bearer tokens are not sent to plaintext HTTP backends.

> [!WARNING]
> `kubeconfig` auth mode requires a bearer token.
> Run `oc whoami -t` to verify you have one.
Expand Down Expand Up @@ -154,7 +157,7 @@ helm install local prometheus-community/prometheus
# port-forward Prometheus server
export POD_NAME=$(kubectl get pods --namespace default -l "app.kubernetes.io/name=prometheus,app.kubernetes.io/instance=local" -o jsonpath="{.items[0].metadata.name}") && kubectl --namespace default port-forward $POD_NAME 9090

go run ./cmd/obs-mcp/ --auth-mode header --listen :9100
go run ./cmd/obs-mcp/ --auth-mode header --listen :9100
```

### Testing with curl
Expand All @@ -175,8 +178,11 @@ You can test the MCP server using curl. The server uses `JSON-RPC 2.0` over `HTT
> - `observability/logs` - Loki log query tools (requires Loki URL or LokiStack discovery)
> - `observability/traces` - Tempo tracing tools (requires Tempo configuration)
> - `observability/otelcol` - OpenTelemetry Collector configuration assistance (no external dependencies)
> - `observability/alert-management` - List OpenShift alerts and create, list, update, delete, and preview alert rules via the monitoring-plugin management API (`--alert-mgmt-api-url` / `ALERT_MGMT_API_URL`). See [ALERT_MANAGEMENT.md](docs/ALERT_MANAGEMENT.md).
>
> `--read-only` defaults to `true` (kubernetes-mcp `read_only` flag; OpenShift Lightspeed also defaults that on). Silence writes and alert-rule create/update/delete are not registered until you pass `--read-only=false`.
>
> Example: `--toolsets observability/metrics,observability/logs,observability/traces,observability/otelcol`
> Example: `--toolsets observability/metrics,observability/logs,observability/traces,observability/otelcol,observability/alert-management`

```shell
curl -X POST http://localhost:9100/mcp \
Expand Down Expand Up @@ -275,6 +281,7 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for where to open PRs.
|----------|-------------|
| [CONTRIBUTING.md](CONTRIBUTING.md) | Where to contribute (toolsets upstream vs host here) |
| [DEPLOYMENT.md](docs/DEPLOYMENT.md) | Authentication modes, in-cluster deployment, configuration |
| [ALERT_MANAGEMENT.md](docs/ALERT_MANAGEMENT.md) | Alert-rule toolset and Alertmanager silence create/update/delete |
| [TOOLS.md](TOOLS.md) | Available MCP tools |
| [TESTING.md](TESTING.md) | Testing guide |
| [RELEASE.md](RELEASE.md) | Release process and versioning guidelines |
Expand Down
Loading