Skip to content

Commit bac751d

Browse files
authored
feat(helm): add mcp server (#6586)
1 parent 3e0f386 commit bac751d

File tree

7 files changed

+260
-5
lines changed

7 files changed

+260
-5
lines changed

deployment/data/nginx/mcp.conf.inc.template

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
# MCP Server - must come BEFORE /api location
2-
location /mcp {
1+
# MCP Server - Model Context Protocol for LLM integrations
2+
# Match /mcp, /mcp/, or /mcp/* but NOT /mcpserver, /mcpapi, etc.
3+
location ~ ^/mcp(/.*)?$ {
34
# misc headers
45
proxy_set_header X-Real-IP $remote_addr;
56
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
@@ -17,6 +18,7 @@ location /mcp {
1718
proxy_read_timeout 300s;
1819

1920
proxy_redirect off;
20-
rewrite ^/mcp/?(.*)$ /$1 break;
21-
proxy_pass http://mcp_server/;
21+
rewrite ^/mcp(/.*)$ $1 break;
22+
rewrite ^/mcp/?$ / break;
23+
proxy_pass http://mcp_server;
2224
}

deployment/helm/charts/onyx/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ home: https://www.onyx.app/
55
sources:
66
- "https://github.com/onyx-dot-app/onyx"
77
type: application
8-
version: 0.4.13
8+
version: 0.4.14
99
appVersion: latest
1010
annotations:
1111
category: Productivity
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{{- if and .Values.ingress.enabled .Values.mcpServer.enabled -}}
2+
apiVersion: networking.k8s.io/v1
3+
kind: Ingress
4+
metadata:
5+
name: {{ include "onyx.fullname" . }}-ingress-mcp
6+
annotations:
7+
kubernetes.io/ingress.class: nginx
8+
nginx.ingress.kubernetes.io/rewrite-target: /$2
9+
nginx.ingress.kubernetes.io/use-regex: "true"
10+
cert-manager.io/cluster-issuer: {{ include "onyx.fullname" . }}-letsencrypt
11+
spec:
12+
rules:
13+
- host: {{ .Values.ingress.api.host }}
14+
http:
15+
paths:
16+
- path: /mcp(/|$)(.*)
17+
pathType: ImplementationSpecific
18+
backend:
19+
service:
20+
name: {{ include "onyx.fullname" . }}-mcp-server-service
21+
port:
22+
number: {{ .Values.mcpServer.service.servicePort }}
23+
tls:
24+
- hosts:
25+
- {{ .Values.ingress.api.host }}
26+
secretName: {{ include "onyx.fullname" . }}-ingress-mcp-tls
27+
{{- end }}
28+
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
{{- if .Values.mcpServer.enabled }}
2+
apiVersion: apps/v1
3+
kind: Deployment
4+
metadata:
5+
name: {{ include "onyx.fullname" . }}-mcp-server
6+
labels:
7+
{{- include "onyx.labels" . | nindent 4 }}
8+
{{- with .Values.mcpServer.deploymentLabels }}
9+
{{- toYaml . | nindent 4 }}
10+
{{- end }}
11+
spec:
12+
replicas: {{ .Values.mcpServer.replicaCount }}
13+
selector:
14+
matchLabels:
15+
{{- include "onyx.selectorLabels" . | nindent 6 }}
16+
{{- if .Values.mcpServer.deploymentLabels }}
17+
{{- toYaml .Values.mcpServer.deploymentLabels | nindent 6 }}
18+
{{- end }}
19+
template:
20+
metadata:
21+
annotations:
22+
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
23+
{{- with .Values.mcpServer.podAnnotations }}
24+
{{- toYaml . | nindent 8 }}
25+
{{- end }}
26+
labels:
27+
{{- include "onyx.labels" . | nindent 8 }}
28+
{{- with .Values.mcpServer.deploymentLabels }}
29+
{{- toYaml . | nindent 8 }}
30+
{{- end }}
31+
{{- with .Values.mcpServer.podLabels }}
32+
{{- toYaml . | nindent 8 }}
33+
{{- end }}
34+
spec:
35+
{{- with .Values.imagePullSecrets }}
36+
imagePullSecrets:
37+
{{- toYaml . | nindent 8 }}
38+
{{- end }}
39+
serviceAccountName: {{ include "onyx.serviceAccountName" . }}
40+
securityContext:
41+
{{- toYaml .Values.mcpServer.podSecurityContext | nindent 8 }}
42+
{{- with .Values.mcpServer.nodeSelector }}
43+
nodeSelector:
44+
{{- toYaml . | nindent 8 }}
45+
{{- end }}
46+
{{- with .Values.mcpServer.affinity }}
47+
affinity:
48+
{{- toYaml . | nindent 8 }}
49+
{{- end }}
50+
{{- with .Values.mcpServer.tolerations }}
51+
tolerations:
52+
{{- toYaml . | nindent 8 }}
53+
{{- end }}
54+
containers:
55+
- name: mcp-server
56+
securityContext:
57+
{{- toYaml .Values.mcpServer.securityContext | nindent 12 }}
58+
image: "{{ .Values.mcpServer.image.repository }}:{{ .Values.mcpServer.image.tag | default .Values.global.version }}"
59+
imagePullPolicy: {{ .Values.global.pullPolicy }}
60+
command: ["python", "onyx/mcp_server_main.py"]
61+
ports:
62+
- name: mcp-server-port
63+
containerPort: {{ .Values.mcpServer.containerPorts.server }}
64+
protocol: TCP
65+
livenessProbe:
66+
httpGet:
67+
path: /health
68+
port: mcp-server-port
69+
initialDelaySeconds: {{ .Values.mcpServer.livenessProbe.initialDelaySeconds }}
70+
periodSeconds: {{ .Values.mcpServer.livenessProbe.periodSeconds }}
71+
timeoutSeconds: {{ .Values.mcpServer.livenessProbe.timeoutSeconds }}
72+
failureThreshold: {{ .Values.mcpServer.livenessProbe.failureThreshold }}
73+
readinessProbe:
74+
httpGet:
75+
path: /health
76+
port: mcp-server-port
77+
initialDelaySeconds: {{ .Values.mcpServer.readinessProbe.initialDelaySeconds }}
78+
periodSeconds: {{ .Values.mcpServer.readinessProbe.periodSeconds }}
79+
timeoutSeconds: {{ .Values.mcpServer.readinessProbe.timeoutSeconds }}
80+
failureThreshold: {{ .Values.mcpServer.readinessProbe.failureThreshold }}
81+
resources:
82+
{{- toYaml .Values.mcpServer.resources | nindent 12 }}
83+
envFrom:
84+
- configMapRef:
85+
name: {{ .Values.config.envConfigMapName }}
86+
env:
87+
- name: MCP_SERVER_ENABLED
88+
value: "true"
89+
- name: MCP_SERVER_PORT
90+
value: "{{ .Values.mcpServer.containerPorts.server }}"
91+
{{- if .Values.mcpServer.corsOrigins }}
92+
- name: MCP_SERVER_CORS_ORIGINS
93+
value: "{{ .Values.mcpServer.corsOrigins }}"
94+
{{- end }}
95+
# API server connection for authentication and proxying
96+
- name: API_SERVER_BASE_URL
97+
value: "http://{{ include "onyx.fullname" . }}-api-service:{{ .Values.api.service.servicePort }}"
98+
{{- include "onyx.envSecrets" . | nindent 12 }}
99+
{{- with .Values.mcpServer.volumeMounts }}
100+
volumeMounts:
101+
{{- toYaml . | nindent 12 }}
102+
{{- end }}
103+
{{- with .Values.mcpServer.volumes }}
104+
volumes:
105+
{{- toYaml . | nindent 8 }}
106+
{{- end }}
107+
{{- end }}
108+
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{{- if .Values.mcpServer.enabled }}
2+
apiVersion: v1
3+
kind: Service
4+
metadata:
5+
name: {{ include "onyx.fullname" . }}-mcp-server-service
6+
labels:
7+
{{- include "onyx.labels" . | nindent 4 }}
8+
{{- if .Values.mcpServer.deploymentLabels }}
9+
{{- toYaml .Values.mcpServer.deploymentLabels | nindent 4 }}
10+
{{- end }}
11+
spec:
12+
type: {{ .Values.mcpServer.service.type }}
13+
ports:
14+
- port: {{ .Values.mcpServer.service.servicePort }}
15+
targetPort: {{ .Values.mcpServer.service.targetPort }}
16+
protocol: TCP
17+
name: {{ .Values.mcpServer.service.portName }}
18+
selector:
19+
{{- include "onyx.selectorLabels" . | nindent 4 }}
20+
{{- if .Values.mcpServer.deploymentLabels }}
21+
{{- toYaml .Values.mcpServer.deploymentLabels | nindent 4 }}
22+
{{- end }}
23+
{{- end }}
24+

deployment/helm/charts/onyx/templates/nginx-conf.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
###############################################################################
2+
# NOTE: If you make changes to this file, increment the following in values.yaml
3+
# before running `helm upgrade` to trigger an automatic nginx restart:
4+
#
5+
# nginx.controller.podAnnotations:
6+
# onyx.app/nginx-config-version: "<new_version>"
7+
#
8+
# Otherwise, changes won't apply until you manually restart the nginx pods.
9+
###############################################################################
10+
111
apiVersion: v1
212
kind: ConfigMap
313
metadata:
@@ -11,13 +21,41 @@ data:
1121
upstream web_server {
1222
server {{ include "onyx.fullname" . }}-webserver:{{ .Values.webserver.service.servicePort }} fail_timeout=0;
1323
}
24+
{{- if .Values.mcpServer.enabled }}
25+
26+
upstream mcp_server {
27+
server {{ include "onyx.fullname" . }}-mcp-server-service:{{ .Values.mcpServer.service.servicePort }} fail_timeout=0;
28+
}
29+
{{- end }}
1430
1531
server.conf: |
1632
server {
1733
listen 1024;
1834
server_name $$DOMAIN;
1935
2036
client_max_body_size 5G;
37+
{{- if .Values.mcpServer.enabled }}
38+
39+
# MCP Server - Model Context Protocol for LLM integrations
40+
# Match /mcp, /mcp/, or /mcp/* but NOT /mcpserver, /mcpapi, etc.
41+
location ~ ^/mcp(/.*)?$ {
42+
rewrite ^/mcp(/.*)$ $1 break;
43+
rewrite ^/mcp/?$ / break;
44+
proxy_set_header X-Real-IP $remote_addr;
45+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
46+
proxy_set_header X-Forwarded-Proto $scheme;
47+
proxy_set_header X-Forwarded-Host $host;
48+
proxy_set_header Host $host;
49+
proxy_http_version 1.1;
50+
proxy_buffering off;
51+
proxy_redirect off;
52+
# timeout settings
53+
proxy_connect_timeout {{ .Values.nginx.timeouts.connect }}s;
54+
proxy_send_timeout {{ .Values.nginx.timeouts.send }}s;
55+
proxy_read_timeout {{ .Values.nginx.timeouts.read }}s;
56+
proxy_pass http://mcp_server;
57+
}
58+
{{- end }}
2159
2260
location ~ ^/api(.*)$ {
2361
rewrite ^/api(/.*)$ $1 break;

deployment/helm/charts/onyx/values.yaml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,12 @@ nginx:
175175
containerPort:
176176
http: 1024
177177

178+
# NOTE: When onyx-nginx-conf changes, nginx pods need to restart.
179+
# The ingress-nginx subchart doesn't auto-detect our custom ConfigMap changes.
180+
# Workaround: Helm upgrade will restart if the following annotation value changes.
181+
podAnnotations:
182+
onyx.app/nginx-config-version: "1"
183+
178184
# Propagate DOMAIN into nginx so server_name continues to use the same env var
179185
extraEnvs:
180186
- name: DOMAIN
@@ -693,6 +699,55 @@ slackbot:
693699
tolerations: []
694700
affinity: {}
695701

702+
# Onyx Model Context Protocol (MCP) Server
703+
# Allows LLMs to use Onyx like invoking tools or accessing resources
704+
mcpServer:
705+
enabled: false # Disabled by default
706+
replicaCount: 1
707+
image:
708+
repository: onyxdotapp/onyx-backend
709+
tag: "" # Overrides the image tag whose default is the chart appVersion.
710+
# CORS origins for MCP clients (comma-separated)
711+
# Example: "https://claude.ai,https://app.cursor.sh"
712+
corsOrigins: ""
713+
podAnnotations: {}
714+
podLabels:
715+
scope: onyx-backend
716+
app: mcp-server
717+
deploymentLabels:
718+
app: mcp-server
719+
containerPorts:
720+
server: 8090
721+
service:
722+
type: ClusterIP
723+
servicePort: 8090
724+
targetPort: mcp-server-port
725+
portName: mcp-server-port
726+
podSecurityContext: {}
727+
securityContext: {}
728+
resources:
729+
requests:
730+
cpu: "250m"
731+
memory: "256Mi"
732+
limits:
733+
cpu: "500m"
734+
memory: "512Mi"
735+
livenessProbe:
736+
initialDelaySeconds: 10
737+
periodSeconds: 30
738+
timeoutSeconds: 5
739+
failureThreshold: 3
740+
readinessProbe:
741+
initialDelaySeconds: 5
742+
periodSeconds: 10
743+
timeoutSeconds: 5
744+
failureThreshold: 3
745+
volumes: []
746+
volumeMounts: []
747+
nodeSelector: {}
748+
tolerations: []
749+
affinity: {}
750+
696751
celery_worker_docfetching:
697752
replicaCount: 1
698753
autoscaling:

0 commit comments

Comments
 (0)