From 3b20b0a35bc45459d002ae4f85182d0eff7782ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Tailland?= Date: Sun, 23 Aug 2026 15:39:27 +0200 Subject: [PATCH] Revert stream-binding approach: merge GET into the single MCP route instead MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The second ai-mcp-proxy binding (added to fix the GET/SSE 502 loop) created a second runtime plugin instance with the same tool config, which ai-mcp-proxy's own duplicate-name detection caught: all three tools (list-customers/get-customer/create-customer) fell back to auto-generated names across both instances. Confirmed via dataplane pod logs right after applying the previous fix. Real fix: one KongRoute for all three MCP HTTP methods (GET/POST/ DELETE) instead of two, one ai-mcp-proxy binding instead of two. ai-mcp-proxy already tolerates multi-method routes (same "skips method selection" notice the existing POST+DELETE route already produces) — extending to GET is the same class of thing, not new risk, and there is now exactly one plugin instance so no duplicate tool names. --- kong/mcp/pluginbindings.yaml | 31 ------------------------------- kong/mcp/routes.yaml | 35 ++++++++++++++--------------------- 2 files changed, 14 insertions(+), 52 deletions(-) diff --git a/kong/mcp/pluginbindings.yaml b/kong/mcp/pluginbindings.yaml index 9177773..0fa96a4 100644 --- a/kong/mcp/pluginbindings.yaml +++ b/kong/mcp/pluginbindings.yaml @@ -34,37 +34,6 @@ spec: kind: KongRoute name: ${NAME}-customers-mcp --- -# Also bind to the GET/-stream route, not just the POST/DELETE one above. -# Without this, GET requests never reach ai-mcp-proxy at all and fall -# through to the KongService's own upstream target — which is -# ${REST_HOSTNAME} (Kong's own external hostname, mcp/service.yaml), so an -# unintercepted GET loops back into the Gateway and grows response headers -# on every pass until nginx rejects it ("upstream sent too big header", -# 502) — confirmed 2026-08-23 via customers dataplane pod logs (28 -# occurrences) while debugging a LibreChat connection failure specific to -# customers-mcp. catalog-mcp has the identical gap (checked: its -# ai-mcp-proxy-binding also targets only the non-stream route) but happens -# to fail as a harmless 405 there instead of looping — not fixed here, -# flagged in STATUS.md, don't assume catalog's GET stream actually works -# just because nothing broke loudly. -apiVersion: configuration.konghq.com/v1alpha1 -kind: KongPluginBinding -metadata: - name: ${NAME}-customers-mcp-ai-mcp-proxy-stream-binding - namespace: ${NAMESPACE} -spec: - controlPlaneRef: - type: konnectNamespacedRef - konnectNamespacedRef: - name: ${CONTROL_PLANE_REF_NAME} - pluginRef: - name: ${NAME}-customers-mcp-ai-mcp-proxy - targets: - routeRef: - group: configuration.konghq.com - kind: KongRoute - name: ${NAME}-customers-mcp-stream ---- apiVersion: configuration.konghq.com/v1alpha1 kind: KongPluginBinding metadata: diff --git a/kong/mcp/routes.yaml b/kong/mcp/routes.yaml index edb900d..83c268f 100644 --- a/kong/mcp/routes.yaml +++ b/kong/mcp/routes.yaml @@ -1,3 +1,16 @@ +# Single route for all three MCP HTTP methods (GET opens the SSE stream, +# POST carries JSON-RPC, DELETE terminates the session) — deliberately NOT +# split into two KongRoutes the way catalog-mcp does. ai-mcp-proxy is bound +# once, to this one route (mcp/pluginbindings.yaml); a second route with +# its own binding of the *same* KongPlugin creates a second runtime plugin +# instance with the same tool names, and ai-mcp-proxy's cross-instance +# duplicate-name detection then falls back to auto-generated tool names +# for all of them ("Tool custom name 'list-customers' already exists in +# both plugin X and Y") — found and reverted 2026-08-23, see STATUS.md. +# ai-mcp-proxy already tolerates a route with multiple methods (logs a +# harmless "skips method selection" notice, same as catalog-mcp's existing +# POST+DELETE route already does) — extending to GET here is the same +# class of thing, not new risk. apiVersion: configuration.konghq.com/v1alpha1 kind: KongRoute metadata: @@ -12,6 +25,7 @@ spec: hosts: - ${REST_HOSTNAME} methods: + - GET - POST - DELETE paths: @@ -19,24 +33,3 @@ spec: strip_path: false tags: - customers ---- -apiVersion: configuration.konghq.com/v1alpha1 -kind: KongRoute -metadata: - name: ${NAME}-customers-mcp-stream - namespace: ${NAMESPACE} -spec: - serviceRef: - type: namespacedRef - namespacedRef: - name: ${NAME}-customers-mcp - name: customers-mcp-stream - hosts: - - ${REST_HOSTNAME} - methods: - - GET - paths: - - /customers-mcp - strip_path: false - tags: - - customers