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
4 changes: 0 additions & 4 deletions .ci-operator.yaml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
name: obs-mcp-unit
name: unit

on:
push:
pull_request:
branches:
- main
paths:
- "obs-mcp/**"
- ".github/workflows/obs-mcp-unit.yaml"

# To cancel running workflow when new commits pushed in a pull request
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
Expand All @@ -27,4 +25,4 @@ jobs:
with:
go-version: "${{ env.golang-version }}"
check-latest: true
- run: make obs-mcp-test
- run: make test-unit
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ obs-mcp/obs-mcp
.devcontainer/dev.env
integration-tests/videos
integration-tests/screenshots
.vscode/*
21 changes: 0 additions & 21 deletions .vscode/settings.json

This file was deleted.

File renamed without changes.
File renamed without changes.
30 changes: 15 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ CONTAINER_CLI ?= docker

.PHONY: help
help: ## Show this help message
@echo "Genie Plugin - Available commands:"
@echo "obs-mcp - Available commands:"
@echo ""
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'

Expand All @@ -14,26 +14,26 @@ check-tools: ## Check if required tools are installed
@command -v $(CONTAINER_CLI) >/dev/null 2>&1 || echo "Warning: $(CONTAINER_CLI) is not installed. Container builds will fail."
@echo "✓ All required tools are installed"

.PHONY: obs-mcp-build
obs-mcp-build: ## Build obs-mcp binary
@cd obs-mcp && go build -tags strictfipsruntime -o obs-mcp ./cmd/obs-mcp
.PHONY: build
build: ## Build obs-mcp binary
go build -tags strictfipsruntime -o obs-mcp ./cmd/obs-mcp

.PHONY: obs-mcp-test
obs-mcp-test: ## Run obs-mcp tests
@cd obs-mcp && go test -v -race ./...
.PHONY: test-unit
test-unit: ## Run obs-mcp unit tests
go test -v -race ./...

.PHONY: obs-mcp-clean
obs-mcp-clean: ## Clean obs-mcp build artifacts
@cd obs-mcp && go clean && rm -f obs-mcp/obs-mcp
.PHONY: clean
clean: ## Clean obs-mcp build artifacts
go clean && rm -f obs-mcp

.PHONY: obs-mcp-container
obs-mcp-container: obs-mcp-build ## Build obs-mcp container image
@cd obs-mcp && $(CONTAINER_CLI) build -f Containerfile -t obs-mcp:latest .
.PHONY: container
container: build ## Build obs-mcp container image
$(CONTAINER_CLI) build -f Containerfile -t obs-mcp:latest .

.PHONY: format
format: ## Format all code
@cd obs-mcp && go fmt ./...
go fmt ./...

.PHONY: setup
setup: check-tools ## Install dependencies for all components
@cd obs-mcp && go mod download
go mod download
52 changes: 42 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,51 @@
# obs-mcp
# obs mcp server

This is an [MCP](https://modelcontextprotocol.io/introduction) server to allow LLMs to interact with a running [Prometheus](https://prometheus.io/) instance via the API.
This is an [mcp](https://modelcontextprotocol.io/introduction) server to allow LLMs to interact with a running [Prometheus](https://prometheus.io/) instance via the API.

> [!NOTE]
> This project is moved from [jhadvig/genie-plugin](https://github.com/jhadvig/genie-plugin/tree/main/obs-mcp) preserving the history of commits.

## Pre-requisites
## Development Quickstart

Before starting, ensure you have the following:
The easiest way to get the obs-mcp connected to the cluster is via a kubeconfig:

- A working Lightspeed Core-based server with the capability to integrate the MCP server located in the `obs-mcp` directory of this project.
- Access to a model capable of tool calling. This project was tested with `gpt-4o-mini`.
- An environment where both Node.js (version 20 or higher) and Golang are available. Using `nvm` (Node Version Manager) and `gvm` (Go Version Manager) is recommended for managing multiple versions.
- Access to an OpenShift Container Platform (OCP) cluster with the monitoring plugin installed.
1. Log into your OpenShift cluster
2. Run the server with

## Getting Started
```sh
go run ./cmd/obs-mcp/ --listen 127.0.0.1:9100 --auth-mode kubeconfig --insecure
```

See the [obs-mcp README](./obs-mcp/README.md)
This will connect the obs-mcp to the thanos querier running in the cluster.

This procedure would not work if you're not using token-based auth (`oc whoami -t` to validate).
In that case, consider using serviceaccount + token auth. Alternatively, follow the procedure bellow.

> [!NOTE]
> It is possible to hit the ground running locally as well:

```shell
helm install prometheus-community/prometheus --name-template <prefix> # sets up Prometheus (and exporters) on your local single-node k8s cluster
export POD_NAME=$(kubectl get pods --namespace default -l "app.kubernetes.io/name=alertmanager,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 --insecure --listen :9100
```

### Port-forwarding alternative

This scenario opens a local port via port-forward that the obs-mcp will connect to:

1. Log into your OpenShift cluster

1. Port forward the OpenShift Thanos instance to a local port

``` sh
PROM_POD=$(kubectl get pods -n openshift-monitoring -l app.kubernetes.io/instance=thanos-querier -o jsonpath="{.items[0].met
adata.name}")
kubectl port-forward -n openshift-monitoring $PROM_POD 9090:9090
```

1. Run the server with

```sh
PROMETHEUS_URL=http://localhost:9090 go run ./cmd/obs-mcp/ --listen 127.0.0.1:9100 --auth-mode header
```
6 changes: 3 additions & 3 deletions obs-mcp/cmd/obs-mcp/main.go → cmd/obs-mcp/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import (

"github.com/prometheus/common/promslog"

"github.com/inecas/obs-mcp/pkg/k8s"
"github.com/inecas/obs-mcp/pkg/mcp"
"github.com/inecas/obs-mcp/pkg/prometheus"
"github.com/mark3labs/mcp-go/server"
"github.com/rhobs/obs-mcp/pkg/k8s"
"github.com/rhobs/obs-mcp/pkg/mcp"
"github.com/rhobs/obs-mcp/pkg/prometheus"
)

const (
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion obs-mcp/go.mod → go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/inecas/obs-mcp
module github.com/rhobs/obs-mcp

go 1.24.6

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion obs-mcp/.gitignore

This file was deleted.

44 changes: 0 additions & 44 deletions obs-mcp/README.md

This file was deleted.

File renamed without changes.
4 changes: 2 additions & 2 deletions obs-mcp/pkg/mcp/auth.go → pkg/mcp/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import (
"os"
"strings"

"github.com/inecas/obs-mcp/pkg/k8s"
"github.com/inecas/obs-mcp/pkg/prometheus"
promapi "github.com/prometheus/client_golang/api"
promcfg "github.com/prometheus/common/config"
"github.com/rhobs/obs-mcp/pkg/k8s"
"github.com/rhobs/obs-mcp/pkg/prometheus"
"k8s.io/client-go/rest"
)

Expand Down
2 changes: 1 addition & 1 deletion obs-mcp/pkg/mcp/handlers.go → pkg/mcp/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (

promModel "github.com/prometheus/common/model"

"github.com/inecas/obs-mcp/pkg/prometheus"
"github.com/mark3labs/mcp-go/mcp"
"github.com/prometheus/common/model"
"github.com/rhobs/obs-mcp/pkg/prometheus"
)

// errorResult is a helper to log and return an error result.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"testing"
"time"

"github.com/inecas/obs-mcp/pkg/prometheus"
"github.com/mark3labs/mcp-go/mcp"
"github.com/rhobs/obs-mcp/pkg/prometheus"
)

// MockedLoader is a mock implementation of prometheus.PromClient for testing
Expand Down
2 changes: 1 addition & 1 deletion obs-mcp/pkg/mcp/server.go → pkg/mcp/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"syscall"
"time"

"github.com/inecas/obs-mcp/pkg/prometheus"
"github.com/mark3labs/mcp-go/server"
"github.com/rhobs/obs-mcp/pkg/prometheus"
)

// ObsMCPOptions contains configuration options for the MCP server
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.