|
1 | | -# obs-mcp |
| 1 | +# obs mcp server |
2 | 2 |
|
3 | | -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. |
| 3 | +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. |
4 | 4 |
|
5 | 5 | > [!NOTE] |
6 | 6 | > This project is moved from [jhadvig/genie-plugin](https://github.com/jhadvig/genie-plugin/tree/main/obs-mcp) preserving the history of commits. |
7 | 7 |
|
8 | | -## Pre-requisites |
| 8 | +## Development Quickstart |
9 | 9 |
|
10 | | -Before starting, ensure you have the following: |
| 10 | +The easiest way to get the obs-mcp connected to the cluster is via a kubeconfig: |
11 | 11 |
|
12 | | -- A working Lightspeed Core-based server with the capability to integrate the MCP server located in the `obs-mcp` directory of this project. |
13 | | -- Access to a model capable of tool calling. This project was tested with `gpt-4o-mini`. |
14 | | -- 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. |
15 | | -- Access to an OpenShift Container Platform (OCP) cluster with the monitoring plugin installed. |
| 12 | + 1. Log into your OpenShift cluster |
| 13 | + 2. Run the server with |
16 | 14 |
|
17 | | -## Getting Started |
| 15 | + ```sh |
| 16 | + go run ./cmd/obs-mcp/ --listen 127.0.0.1:9100 --auth-mode kubeconfig --insecure |
| 17 | + ``` |
18 | 18 |
|
19 | | -See the [obs-mcp README](./obs-mcp/README.md) |
| 19 | +This will connect the obs-mcp to the thanos querier running in the cluster. |
| 20 | + |
| 21 | +This procedure would not work if you're not using token-based auth (`oc whoami -t` to validate). |
| 22 | +In that case, consider using serviceaccount + token auth. Alternatively, follow the procedure bellow. |
| 23 | + |
| 24 | +> [!NOTE] |
| 25 | +> It is possible to hit the ground running locally as well: |
| 26 | +
|
| 27 | +```shell |
| 28 | +helm install prometheus-community/prometheus --name-template <prefix> # sets up Prometheus (and exporters) on your local single-node k8s cluster |
| 29 | +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 |
| 30 | +go run ./cmd/obs-mcp/ --auth-mode header --insecure --listen :9100 |
| 31 | +``` |
| 32 | + |
| 33 | +### Port-forwarding alternative |
| 34 | + |
| 35 | +This scenario opens a local port via port-forward that the obs-mcp will connect to: |
| 36 | + |
| 37 | + 1. Log into your OpenShift cluster |
| 38 | + |
| 39 | + 1. Port forward the OpenShift Thanos instance to a local port |
| 40 | + |
| 41 | +``` sh |
| 42 | +PROM_POD=$(kubectl get pods -n openshift-monitoring -l app.kubernetes.io/instance=thanos-querier -o jsonpath="{.items[0].met |
| 43 | +adata.name}") |
| 44 | +kubectl port-forward -n openshift-monitoring $PROM_POD 9090:9090 |
| 45 | +``` |
| 46 | + |
| 47 | + 1. Run the server with |
| 48 | + |
| 49 | +```sh |
| 50 | +PROMETHEUS_URL=http://localhost:9090 go run ./cmd/obs-mcp/ --listen 127.0.0.1:9100 --auth-mode header |
| 51 | +``` |
0 commit comments