Skip to content

Commit 970b02c

Browse files
Merge pull request #15 from hemajv/openshift-mcp-server
Add openshift MCP server
2 parents 8443419 + 122868f commit 970b02c

File tree

3 files changed

+174
-0
lines changed

3 files changed

+174
-0
lines changed

mcp-servers/openshift/Containerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
FROM registry.access.redhat.com/ubi9/ubi:latest as builder
2+
3+
WORKDIR /app
4+
USER root
5+
RUN dnf install -y wget tar git make && \
6+
wget https://go.dev/dl/go1.24.1.linux-amd64.tar.gz && \
7+
tar -C /usr/local -xzf go1.24.1.linux-amd64.tar.gz && \
8+
rm -f go1.24.1.linux-amd64.tar.gz
9+
ENV PATH="/usr/local/go/bin:${PATH}"
10+
RUN git clone https://github.com/manusa/kubernetes-mcp-server.git && \
11+
cd kubernetes-mcp-server && \
12+
make build
13+
14+
FROM registry.access.redhat.com/ubi9/ubi-minimal:latest
15+
WORKDIR /app
16+
COPY --from=builder /app/kubernetes-mcp-server/kubernetes-mcp-server /app/kubernetes-mcp-server
17+
ENTRYPOINT ["./kubernetes-mcp-server", "--sse-port", "8080", "--log-level", "9"]
18+
19+
EXPOSE 8080

mcp-servers/openshift/README.md

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# Steps for deploying the OpenShift MCP server on OpenShift
2+
3+
The [OpenShift MCP server](https://github.com/manusa/kubernetes-mcp-server) is a Kubernetes MCP server implementation configured with a few tools that can:
4+
5+
- Automatically view and manage the current Kubernetes `.kube/config` or in-cluster configuration
6+
- Use tools to perform operations on any Kubernetes or OpenShift resource such as:
7+
- **Pod operations** - It can list, get, delete, show logs, exec, run pods
8+
- **Namespace operations** - It can list Kubernetes Namespaces
9+
- **Events** - View Kubernetes events in all namespaces or in a specific namespace
10+
- **Projects** - List OpenShift Projects
11+
12+
## Pre-Requisites
13+
14+
You will need the following installed on your local machine:
15+
16+
- `podman`
17+
- `oc`
18+
19+
## Step 1: Building the Containerfile
20+
21+
You will need to first build a container image using the `Containerfile` and can do this by using `podman`. To build the container image from the current directory:
22+
23+
```
24+
podman build -t ocp-mcp-server:latest -f Containerfile .
25+
```
26+
27+
If running on a Mac:
28+
29+
```
30+
podman build -t ocp-mcp-server:latest --platform="linux/amd64" -f Containerfile .
31+
```
32+
33+
If run successfully, you should see your image `localhost/ocp-mcp-server` listed when you run:
34+
35+
```
36+
podman images
37+
```
38+
39+
## Step 2: Pushing the container image to Quay
40+
41+
Next, you will need to push your container image to a public image repository like [quay.io](https://quay.io/). Make sure you create an account on quay.io, if you don't have one already. Once you have an account, you will need to login:
42+
43+
```
44+
podman login -u=<user_name> -p=<pass_word> quay.io
45+
```
46+
47+
Once you're logged in successfully, you can now push your image by first tagging your local image:
48+
49+
```
50+
podman tag localhost/ocp-mcp-server:latest quay.io/<username>/ocp-mcp-server:latest
51+
```
52+
53+
Then you can push to your quay registry:
54+
55+
```
56+
podman push quay.io/<username>/ocp-mcp-server:latest
57+
```
58+
59+
### Step 3: Deploying on OpenShift
60+
61+
To deploy the OpenShift MCP server on OpenShift, make sure you have access to an active OpenShift cluster and namespace. Note that as this MCP server is implemented to perform certain operations on a OpenShift/Kubernetes environment you will need to setup a `ServiceAccount` with `edit` RoleBinding access to allow suitable permissions for the MCP server to execute those operations. This has been defined in the `deployment.yaml`.
62+
63+
**Login to Openshift**
64+
65+
```
66+
oc login --token=<your user token> --server=<your openshift cluster server>
67+
```
68+
69+
Select a suitable namespace within the cluter:
70+
71+
```
72+
oc project <your namespace>
73+
```
74+
75+
**Deploy the OpenShift MCP server application**:
76+
77+
```
78+
oc apply -f deployment.yaml
79+
```
80+
81+
You should now see a pod running successfully in OpenShift as well as a service created for it! You should see an address created for the service in your OpenShift something like `http://172.xx.yyy.zzz:8000`.
82+
83+
### Step 4: Testing the OpenShift MCP server
84+
85+
You can run the example sript in `app/src/0_simple_agent.py` by modifying the following:
86+
87+
- Set the `REMOTE_MCP_URL` env var to `http://<your mcp service endpoint>:8000/sse`
88+
- Set the `REMOTE_BASE_URL` env var to your hosted llama stack server
89+
- Provide a suitable user query to test. You can try an example user prompt like "Please list all the pods running in my xyz namespace?" and pass it [here](https://github.com/redhat-et/llama-stack-on-ocp/blob/main/app/src/0_simple_agent.py#L74)
90+
91+
Then run the script like:
92+
93+
```
94+
python 0_simple_agent.py -r -a
95+
```

mcp-servers/openshift/deployment.yaml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
kind: Deployment
2+
apiVersion: apps/v1
3+
metadata:
4+
name: ocp-mcp-server
5+
labels:
6+
app: ocp-mcp-server
7+
spec:
8+
selector:
9+
matchLabels:
10+
app: ocp-mcp-server
11+
replicas: 1
12+
template:
13+
metadata:
14+
labels:
15+
app: ocp-mcp-server
16+
deployment: ocp-mcp-server
17+
spec:
18+
serviceAccountName: ocp-mcp
19+
containers:
20+
- name: ocp-mcp-server
21+
image: quay.io/hveeradh/ocp-mcp-server:latest
22+
ports:
23+
- name: http
24+
containerPort: 8000
25+
protocol: TCP
26+
command: ["./kubernetes-mcp-server"]
27+
args: ["--sse-port", "8000"]
28+
resources: {}
29+
---
30+
apiVersion: v1
31+
kind: Service
32+
metadata:
33+
name: ocp-mcp-server
34+
labels:
35+
app: ocp-mcp-server
36+
spec:
37+
selector:
38+
app: ocp-mcp-server
39+
deployment: ocp-mcp-server
40+
ports:
41+
- port: 8000
42+
targetPort: http
43+
protocol: TCP
44+
---
45+
apiVersion: v1
46+
kind: ServiceAccount
47+
metadata:
48+
name: ocp-mcp
49+
---
50+
kind: RoleBinding
51+
apiVersion: rbac.authorization.k8s.io/v1
52+
metadata:
53+
name: ocp-mcp
54+
subjects:
55+
- kind: ServiceAccount
56+
name: ocp-mcp
57+
roleRef:
58+
apiGroup: rbac.authorization.k8s.io
59+
kind: ClusterRole
60+
name: edit

0 commit comments

Comments
 (0)