Skip to content

Commit 0bacbc2

Browse files
committed
metamcp: allow updating existing STREAMABLE_HTTP/SSE servers (url, headers, bearerToken) when updateExisting=true; bump to 0.1.24
1 parent 700ccb6 commit 0bacbc2

File tree

2 files changed

+43
-12
lines changed

2 files changed

+43
-12
lines changed

charts/metamcp/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v2
22
name: metamcp
33
description: MetaMCP aggregator Helm chart for Kubernetes
44
type: application
5-
version: 0.1.23
5+
version: 0.1.24
66
appVersion: "latest"
77
icon: https://icoretech.github.io/helm/charts/metamcp/logo.png
88
keywords:

charts/metamcp/scripts/provision.py

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -172,37 +172,40 @@ def k8s_get_configmap_data(name: str):
172172
pass
173173
return {}
174174

175-
# Map existing servers
175+
# Map existing servers (name -> uuid and full info)
176176
srv_map = {}
177+
srv_info = {}
177178
try:
178179
lr = trpc_get('/trpc/frontend/frontend.mcpServers.list?input=%7B%7D')
179180
if lr.ok:
180181
for s in lr.json().get('result',{}).get('data',{}).get('data',[]):
181182
srv_map[s['name']] = s['uuid']
183+
srv_info[s['name']] = s
182184
except Exception:
183185
pass
184186

185187
for s in servers:
186188
if not (s.get('enabled', True)):
187189
continue
188190
name = s.get('name'); st = (s.get('type','SSE') or 'SSE').upper()
189-
if not name or name in srv_map:
191+
if not name:
190192
continue
191193
if st in ('SSE','STREAMABLE'):
192194
st = 'SSE' if st=='SSE' else 'STREAMABLE_HTTP'
193195
body = {'name': name, 'type': st}
196+
desired_url = None
194197
if st in ('SSE','STREAMABLE_HTTP'):
195-
url = s.get('url')
196-
if not url:
198+
desired_url = s.get('url')
199+
if not desired_url:
197200
base = s.get('serviceBase')
198201
if base:
199202
suffix = '/mcp' if st=='STREAMABLE_HTTP' else '/sse'
200203
# ensure scheme
201204
if base.startswith('http://') or base.startswith('https://'):
202-
url = base + suffix
205+
desired_url = base + suffix
203206
else:
204-
url = 'http://' + base + suffix
205-
# proactive readiness: if we know serviceBase, wait for port to accept before creating record
207+
desired_url = 'http://' + base + suffix
208+
# proactive readiness for deployed servers
206209
if base:
207210
try:
208211
hostport = base.split('://')[-1]
@@ -212,7 +215,6 @@ def k8s_get_configmap_data(name: str):
212215
if host and port:
213216
log(f"[ready] waiting tcp {host}:{port} …")
214217
max_tries = 8
215-
tried = 0
216218
ok = False
217219
for _ in range(max_tries):
218220
try:
@@ -222,9 +224,38 @@ def k8s_get_configmap_data(name: str):
222224
except Exception:
223225
time.sleep(1)
224226
log(f"[ready] tcp {host}:{port} -> {'ok' if ok else 'timeout'}")
225-
if url: body['url'] = url
226-
if s.get('bearerToken'): body['bearerToken'] = s['bearerToken']
227-
if s.get('headers'): body['headers'] = s['headers']
227+
if desired_url:
228+
body['url'] = desired_url
229+
if s.get('bearerToken'):
230+
body['bearerToken'] = s['bearerToken']
231+
if s.get('headers'):
232+
body['headers'] = s['headers']
233+
234+
# If server exists and updates are allowed, patch safe fields for HTTP/SSE
235+
if name in srv_map:
236+
if UPDATE_EXISTING and st in ('SSE','STREAMABLE_HTTP'):
237+
try:
238+
current = srv_info.get(name, {})
239+
patch = {'uuid': current.get('uuid'), 'name': name, 'type': st}
240+
changed = False
241+
if desired_url and (current.get('url') or '') != desired_url:
242+
patch['url'] = desired_url; changed = True
243+
if 'bearerToken' in body and (current.get('bearerToken') or '') != body.get('bearerToken'):
244+
patch['bearerToken'] = body['bearerToken']; changed = True
245+
if 'headers' in body:
246+
# best-effort compare
247+
cur_headers = current.get('headers') or {}
248+
if cur_headers != body['headers']:
249+
patch['headers'] = body['headers']; changed = True
250+
if changed:
251+
r = trpc_post('/trpc/frontend/frontend.mcpServers.update', patch)
252+
if r.ok:
253+
log(f"server updated: {name}")
254+
else:
255+
log(f"WARN server update {name} -> {r.status_code}: {r.text[:160]}")
256+
except Exception:
257+
pass
258+
continue
228259
if st == 'STDIO':
229260
cmd = s.get('command')
230261
args = s.get('args') or []

0 commit comments

Comments
 (0)