Skip to content

Commit 1b96d5d

Browse files
nacxnutanix-Hrushikesh
authored andcommitted
mcp: configure access logs for upstream mcp servers (envoyproxy#1302)
**Description** Previously, we only had access logs for the main gateway listeners, but not for the internal listener created to route requests to the upstream MCP servers. This PR configures the access logs for the upstream MCP server listener with the same settings as the gateway access logs, to have logs for the MCP server upstream accesses. With this change, MCP upstream access logs will appear as well, and, if configured, the MCP metadata will also be present: <details> <summary> <strong>Example initialize:</strong> We can see now the main POST request as well as the 2 initialize requests to the upstream MCP servers and the corresponding notifications. </summary> ```json { "bytes_received": 259, "bytes_sent": 329, "connection_termination_details": null, "downstream_local_address": "127.0.0.1:10088", "downstream_remote_address": "127.0.0.1:58117", "duration": 870, "genai_backend_name": null, "genai_model_name": null, "genai_model_name_override": null, "genai_tokens_input": null, "genai_tokens_output": null, "mcp_backend": "context7", "mcp_method": "initialize", "mcp_request_id": "9f518a27-08ab-4d01-92fd-5fd2b560957c", "mcp_session_id": null, "method": "POST", "response_code": 200, "start_time": "2025-10-08T10:40:13.834Z", "upstream_cluster": "httproute/default/ai-eg-mcp-br-mcp-route-context7/rule/0", "upstream_host": "13.217.64.66:443", "upstream_local_address": "192.168.40.127:58119", "upstream_transport_failure_reason": null, "user-agent": "Go-http-client/1.1", "x-envoy-origin-path": "/mcp", "x-request-id": "98ad661e-080a-4ae2-bb62-efebdb2a248e" } { "bytes_received": 66, "bytes_sent": 0, "connection_termination_details": null, "downstream_local_address": "127.0.0.1:10088", "downstream_remote_address": "127.0.0.1:58117", "duration": 118, "genai_backend_name": null, "genai_model_name": null, "genai_model_name_override": null, "genai_tokens_input": null, "genai_tokens_output": null, "mcp_backend": "context7", "mcp_method": "notifications/initialized", "mcp_request_id": "<nil>", "mcp_session_id": null, "method": "POST", "response_code": 202, "start_time": "2025-10-08T10:40:14.706Z", "upstream_cluster": "httproute/default/ai-eg-mcp-br-mcp-route-context7/rule/0", "upstream_host": "13.217.64.66:443", "upstream_local_address": "192.168.40.127:58119", "upstream_transport_failure_reason": null, "user-agent": "Go-http-client/1.1", "x-envoy-origin-path": "/mcp", "x-request-id": "6b49ac24-6ec2-4291-a39f-0c6a31f06e61" } { "bytes_received": 259, "bytes_sent": 362, "connection_termination_details": null, "downstream_local_address": "127.0.0.1:10088", "downstream_remote_address": "127.0.0.1:58116", "duration": 1068, "genai_backend_name": null, "genai_model_name": null, "genai_model_name_override": null, "genai_tokens_input": null, "genai_tokens_output": null, "mcp_backend": "github", "mcp_method": "initialize", "mcp_request_id": "8c86794e-0f5e-472a-852b-92632d6aafc8", "mcp_session_id": null, "method": "POST", "response_code": 200, "start_time": "2025-10-08T10:40:13.832Z", "upstream_cluster": "httproute/default/ai-eg-mcp-br-mcp-route-github/rule/0", "upstream_host": "140.82.114.21:443", "upstream_local_address": "192.168.40.127:58118", "upstream_transport_failure_reason": null, "user-agent": "Go-http-client/1.1", "x-envoy-origin-path": "/mcp/readonly", "x-request-id": "b84bfe17-b783-47d7-b565-8ac0036101b6" } { "bytes_received": 66, "bytes_sent": 0, "connection_termination_details": null, "downstream_local_address": "127.0.0.1:10088", "downstream_remote_address": "127.0.0.1:58116", "duration": 211, "genai_backend_name": null, "genai_model_name": null, "genai_model_name_override": null, "genai_tokens_input": null, "genai_tokens_output": null, "mcp_backend": "github", "mcp_method": "notifications/initialized", "mcp_request_id": "<nil>", "mcp_session_id": "09f09ce2-e99a-4ef2-91e1-b1d4a161dd00", "method": "POST", "response_code": 202, "start_time": "2025-10-08T10:40:14.901Z", "upstream_cluster": "httproute/default/ai-eg-mcp-br-mcp-route-github/rule/0", "upstream_host": "140.82.114.21:443", "upstream_local_address": "192.168.40.127:58118", "upstream_transport_failure_reason": null, "user-agent": "Go-http-client/1.1", "x-envoy-origin-path": "/mcp/readonly", "x-request-id": "2891fff9-2130-4a61-8f1e-5ee774e19856" } { "bytes_received": 222, "bytes_sent": 317, "connection_termination_details": null, "downstream_local_address": "127.0.0.1:1975", "downstream_remote_address": "127.0.0.1:58114", "duration": 1325, "genai_backend_name": null, "genai_model_name": null, "genai_model_name_override": null, "genai_tokens_input": null, "genai_tokens_output": null, "mcp_backend": null, "mcp_method": null, "mcp_request_id": null, "mcp_session_id": null, "method": "POST", "response_code": 200, "start_time": "2025-10-08T10:40:13.829Z", "upstream_cluster": "httproute/default/ai-eg-mcp-main-mcp-route/rule/0", "upstream_host": "127.0.0.1:9856", "upstream_local_address": "127.0.0.1:58115", "upstream_transport_failure_reason": null, "user-agent": "node-fetch", "x-envoy-origin-path": "/mcp", "x-request-id": "b12dac6e-b1f0-4af2-b500-3a89cc053c3d" } ``` </details> <details> <summary> <strong>Example tool list:</strong> We can see now the main POST request as well as the 2 tool list requests to the upstream MCP servers. </summary> ```json { "bytes_received": 85, "bytes_sent": 2709, "connection_termination_details": null, "downstream_local_address": "127.0.0.1:10088", "downstream_remote_address": "127.0.0.1:58116", "duration": 701, "genai_backend_name": null, "genai_model_name": null, "genai_model_name_override": null, "genai_tokens_input": null, "genai_tokens_output": null, "mcp_backend": "context7", "mcp_method": "tools/list", "mcp_request_id": "2", "mcp_session_id": "", "method": "POST", "response_code": 200, "start_time": "2025-10-08T10:41:19.100Z", "upstream_cluster": "httproute/default/ai-eg-mcp-br-mcp-route-context7/rule/0", "upstream_host": "13.217.64.66:443", "upstream_local_address": "192.168.40.127:58149", "upstream_transport_failure_reason": null, "user-agent": "Go-http-client/1.1", "x-envoy-origin-path": "/mcp", "x-request-id": "4e857bd1-7c11-483d-91d3-d06cd905fea6" } { "bytes_received": 85, "bytes_sent": 46095, "connection_termination_details": null, "downstream_local_address": "127.0.0.1:10088", "downstream_remote_address": "127.0.0.1:58124", "duration": 1112, "genai_backend_name": null, "genai_model_name": null, "genai_model_name_override": null, "genai_tokens_input": null, "genai_tokens_output": null, "mcp_backend": "github", "mcp_method": "tools/list", "mcp_request_id": "2", "mcp_session_id": "09f09ce2-e99a-4ef2-91e1-b1d4a161dd00", "method": "POST", "response_code": 200, "start_time": "2025-10-08T10:41:19.100Z", "upstream_cluster": "httproute/default/ai-eg-mcp-br-mcp-route-github/rule/0", "upstream_host": "140.82.113.21:443", "upstream_local_address": "192.168.40.127:58148", "upstream_transport_failure_reason": null, "user-agent": "Go-http-client/1.1", "x-envoy-origin-path": "/mcp/readonly", "x-request-id": "2ed28447-cdee-4570-a1b4-91a2470b4408" } { "bytes_received": 85, "bytes_sent": 4550, "connection_termination_details": null, "downstream_local_address": "127.0.0.1:1975", "downstream_remote_address": "127.0.0.1:58122", "duration": 1193, "genai_backend_name": null, "genai_model_name": null, "genai_model_name_override": null, "genai_tokens_input": null, "genai_tokens_output": null, "mcp_backend": null, "mcp_method": null, "mcp_request_id": null, "mcp_session_id": "LEUnsU/tza7AVbVNwuyF7Kt6e6I+r0IpgzJughZNn+RAHOwtcIN16vyUZgERIFA+iktVrP8mshIsd1MBBxgtM7ibTiOWJNZsRK/hFtB+yP8INego+Txfy9RoLzFsHm/vV6aACb6P+AHVZgz86EKne73VzcPLDTIcy2N2f7SgUkU=", "method": "POST", "response_code": 200, "start_time": "2025-10-08T10:41:19.065Z", "upstream_cluster": "httproute/default/ai-eg-mcp-main-mcp-route/rule/0", "upstream_host": "127.0.0.1:9856", "upstream_local_address": "127.0.0.1:58123", "upstream_transport_failure_reason": null, "user-agent": "node-fetch", "x-envoy-origin-path": "/mcp", "x-request-id": "e62b8491-b32d-434f-9ff9-caf0f4bab4d1" } ``` </details> <details> <summary> <strong>Example tool call:</strong> We can see now the main POST request as well as the tool call to the upstream MCP server. </summary> ```json { "bytes_received": 165, "bytes_sent": 10255, "connection_termination_details": null, "downstream_local_address": "127.0.0.1:10088", "downstream_remote_address": "127.0.0.1:58124", "duration": 653, "genai_backend_name": null, "genai_model_name": null, "genai_model_name_override": null, "genai_tokens_input": null, "genai_tokens_output": null, "mcp_backend": "context7", "mcp_method": "tools/call", "mcp_request_id": "3", "mcp_session_id": null, "method": "POST", "response_code": 200, "start_time": "2025-10-08T10:42:11.430Z", "upstream_cluster": "httproute/default/ai-eg-mcp-br-mcp-route-context7/rule/0", "upstream_host": "13.217.64.66:443", "upstream_local_address": "192.168.40.127:58172", "upstream_transport_failure_reason": null, "user-agent": "Go-http-client/1.1", "x-envoy-origin-path": "/mcp", "x-request-id": "cf2c0454-6290-498e-af6c-e32a611b5da1" } { "bytes_received": 175, "bytes_sent": 10350, "connection_termination_details": null, "downstream_local_address": "127.0.0.1:1975", "downstream_remote_address": "127.0.0.1:58122", "duration": 725, "genai_backend_name": null, "genai_model_name": null, "genai_model_name_override": null, "genai_tokens_input": null, "genai_tokens_output": null, "mcp_backend": null, "mcp_method": null, "mcp_request_id": null, "mcp_session_id": "LEUnsU/tza7AVbVNwuyF7Kt6e6I+r0IpgzJughZNn+RAHOwtcIN16vyUZgERIFA+iktVrP8mshIsd1MBBxgtM7ibTiOWJNZsRK/hFtB+yP8INego+Txfy9RoLzFsHm/vV6aACb6P+AHVZgz86EKne73VzcPLDTIcy2N2f7SgUkU=", "method": "POST", "response_code": 200, "start_time": "2025-10-08T10:42:11.399Z", "upstream_cluster": "httproute/default/ai-eg-mcp-main-mcp-route/rule/0", "upstream_host": "127.0.0.1:9856", "upstream_local_address": "127.0.0.1:58123", "upstream_transport_failure_reason": null, "user-agent": "node-fetch", "x-envoy-origin-path": "/mcp", "x-request-id": "fc253d7b-2c80-4fa6-972e-3d8aae25be29" } ``` </details> **Related Issues/PRs (if applicable)** N/A **Special notes for reviewers (if applicable)** N/A --------- Signed-off-by: Ignasi Barrera <[email protected]> Signed-off-by: Hrushikesh Patil <[email protected]>
1 parent 8533378 commit 1b96d5d

23 files changed

+531
-101
lines changed

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ tests/internal/testopenai/cassettes
44
tests/internal/testopeninference/spans
55
cmd/aigw/testdata
66
internal/autoconfig/testdata
7+
examples/aigw/ollama.yaml

examples/aigw/ollama.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,3 +169,4 @@ spec:
169169
apiKey:
170170
secretRef:
171171
name: openai-apikey
172+
---

examples/mcp/mcp_example.yaml

Lines changed: 61 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,26 @@ spec:
5252
group: gateway.envoyproxy.io
5353
path: "/"
5454
---
55+
apiVersion: aigateway.envoyproxy.io/v1alpha1
56+
kind: MCPRoute
57+
metadata:
58+
name: mcp-route-custom-path
59+
namespace: default
60+
spec:
61+
parentRefs:
62+
- name: aigw-run
63+
kind: Gateway
64+
group: gateway.networking.k8s.io
65+
path: "/mcp/custom/path"
66+
backendRefs:
67+
- name: aws-knowledge
68+
kind: Backend
69+
group: gateway.envoyproxy.io
70+
path: "/"
71+
toolSelector:
72+
include:
73+
- aws___read_documentation
74+
---
5575
kind: Secret
5676
apiVersion: v1
5777
metadata:
@@ -237,23 +257,45 @@ spec:
237257
socket_address:
238258
address: 127.0.0.1
239259
port_value: 9901
260+
telemetry:
261+
accessLog:
262+
settings:
263+
- sinks:
264+
- type: File
265+
file:
266+
path: /dev/stdout
267+
format:
268+
type: JSON
269+
json:
270+
# MCP specific fields
271+
mcp_request_id: "%DYNAMIC_METADATA(io.envoy.ai_gateway:mcp_request_id)%"
272+
mcp_session_id: "%REQ(MCP-SESSION-ID)%"
273+
mcp_method: "%DYNAMIC_METADATA(io.envoy.ai_gateway:mcp_method)%"
274+
mcp_backend: "%DYNAMIC_METADATA(io.envoy.ai_gateway:mcp_backend)%"
275+
# Default fields
276+
start_time: "%START_TIME%"
277+
method: "%REQ(:METHOD)%"
278+
x-envoy-origin-path: "%REQ(X-ENVOY-ORIGINAL-PATH?:PATH)%"
279+
protocol: "%PROTOCOL%"
280+
response_code: "%RESPONSE_CODE%"
281+
response_flags: "%RESPONSE_FLAGS%"
282+
response_code_details: "%RESPONSE_CODE_DETAILS%"
283+
connection_termination_details: "%CONNECTION_TERMINATION_DETAILS%"
284+
upstream_transport_failure_reason: "%UPSTREAM_TRANSPORT_FAILURE_REASON%"
285+
bytes_received: "%BYTES_RECEIVED%"
286+
bytes_sent: "%BYTES_SENT%"
287+
duration: "%DURATION%"
288+
x-envoy-upstream-service-time: "%RESP(X-ENVOY-UPSTREAM-SERVICE-TIME)%"
289+
x-forwarded-for: "%REQ(X-FORWARDED-FOR)%"
290+
user-agent: "%REQ(USER-AGENT)%"
291+
x-request-id: "%REQ(X-REQUEST-ID)%"
292+
":authority": "%REQ(:AUTHORITY)%"
293+
upstream_host: "%UPSTREAM_HOST%"
294+
upstream_cluster: "%UPSTREAM_CLUSTER%"
295+
upstream_local_address: "%UPSTREAM_LOCAL_ADDRESS%"
296+
downstream_local_address: "%DOWNSTREAM_LOCAL_ADDRESS%"
297+
downstream_remote_address: "%DOWNSTREAM_REMOTE_ADDRESS%"
298+
requested_server_name: "%REQUESTED_SERVER_NAME%"
299+
route_name: "%ROUTE_NAME%"
240300
---
241-
apiVersion: aigateway.envoyproxy.io/v1alpha1
242-
kind: MCPRoute
243-
metadata:
244-
name: mcp-route-custom-path
245-
namespace: default
246-
spec:
247-
parentRefs:
248-
- name: aigw-run
249-
kind: Gateway
250-
group: gateway.networking.k8s.io
251-
path: "/mcp/custom/path"
252-
backendRefs:
253-
- name: aws-knowledge
254-
kind: Backend
255-
group: gateway.envoyproxy.io
256-
path: "/"
257-
toolSelector:
258-
include:
259-
- aws___read_documentation
301+

examples/mcp/mcp_oauth_example.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,3 +231,43 @@ spec:
231231
socket_address:
232232
address: 127.0.0.1
233233
port_value: 9901
234+
telemetry:
235+
accessLog:
236+
settings:
237+
- sinks:
238+
- type: File
239+
file:
240+
path: /dev/stdout
241+
format:
242+
type: JSON
243+
json:
244+
# MCP specific fields
245+
mcp_request_id: "%DYNAMIC_METADATA(io.envoy.ai_gateway:mcp_request_id)%"
246+
mcp_session_id: "%REQ(MCP-SESSION-ID)%"
247+
mcp_method: "%DYNAMIC_METADATA(io.envoy.ai_gateway:mcp_method)%"
248+
mcp_backend: "%DYNAMIC_METADATA(io.envoy.ai_gateway:mcp_backend)%"
249+
# Default fields
250+
start_time: "%START_TIME%"
251+
method: "%REQ(:METHOD)%"
252+
x-envoy-origin-path: "%REQ(X-ENVOY-ORIGINAL-PATH?:PATH)%"
253+
protocol: "%PROTOCOL%"
254+
response_code: "%RESPONSE_CODE%"
255+
response_flags: "%RESPONSE_FLAGS%"
256+
response_code_details: "%RESPONSE_CODE_DETAILS%"
257+
connection_termination_details: "%CONNECTION_TERMINATION_DETAILS%"
258+
upstream_transport_failure_reason: "%UPSTREAM_TRANSPORT_FAILURE_REASON%"
259+
bytes_received: "%BYTES_RECEIVED%"
260+
bytes_sent: "%BYTES_SENT%"
261+
duration: "%DURATION%"
262+
x-envoy-upstream-service-time: "%RESP(X-ENVOY-UPSTREAM-SERVICE-TIME)%"
263+
x-forwarded-for: "%REQ(X-FORWARDED-FOR)%"
264+
user-agent: "%REQ(USER-AGENT)%"
265+
x-request-id: "%REQ(X-REQUEST-ID)%"
266+
":authority": "%REQ(:AUTHORITY)%"
267+
upstream_host: "%UPSTREAM_HOST%"
268+
upstream_cluster: "%UPSTREAM_CLUSTER%"
269+
upstream_local_address: "%UPSTREAM_LOCAL_ADDRESS%"
270+
downstream_local_address: "%DOWNSTREAM_LOCAL_ADDRESS%"
271+
downstream_remote_address: "%DOWNSTREAM_REMOTE_ADDRESS%"
272+
requested_server_name: "%REQUESTED_SERVER_NAME%"
273+
route_name: "%ROUTE_NAME%"

examples/mcp/mcp_oauth_keycloak.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,3 +196,43 @@ spec:
196196
socket_address:
197197
address: 127.0.0.1
198198
port_value: 9901
199+
telemetry:
200+
accessLog:
201+
settings:
202+
- sinks:
203+
- type: File
204+
file:
205+
path: /dev/stdout
206+
format:
207+
type: JSON
208+
json:
209+
# MCP specific fields
210+
mcp_request_id: "%DYNAMIC_METADATA(io.envoy.ai_gateway:mcp_request_id)%"
211+
mcp_session_id: "%REQ(MCP-SESSION-ID)%"
212+
mcp_method: "%DYNAMIC_METADATA(io.envoy.ai_gateway:mcp_method)%"
213+
mcp_backend: "%DYNAMIC_METADATA(io.envoy.ai_gateway:mcp_backend)%"
214+
# Default fields
215+
start_time: "%START_TIME%"
216+
method: "%REQ(:METHOD)%"
217+
x-envoy-origin-path: "%REQ(X-ENVOY-ORIGINAL-PATH?:PATH)%"
218+
protocol: "%PROTOCOL%"
219+
response_code: "%RESPONSE_CODE%"
220+
response_flags: "%RESPONSE_FLAGS%"
221+
response_code_details: "%RESPONSE_CODE_DETAILS%"
222+
connection_termination_details: "%CONNECTION_TERMINATION_DETAILS%"
223+
upstream_transport_failure_reason: "%UPSTREAM_TRANSPORT_FAILURE_REASON%"
224+
bytes_received: "%BYTES_RECEIVED%"
225+
bytes_sent: "%BYTES_SENT%"
226+
duration: "%DURATION%"
227+
x-envoy-upstream-service-time: "%RESP(X-ENVOY-UPSTREAM-SERVICE-TIME)%"
228+
x-forwarded-for: "%REQ(X-FORWARDED-FOR)%"
229+
user-agent: "%REQ(USER-AGENT)%"
230+
x-request-id: "%REQ(X-REQUEST-ID)%"
231+
":authority": "%REQ(:AUTHORITY)%"
232+
upstream_host: "%UPSTREAM_HOST%"
233+
upstream_cluster: "%UPSTREAM_CLUSTER%"
234+
upstream_local_address: "%UPSTREAM_LOCAL_ADDRESS%"
235+
downstream_local_address: "%DOWNSTREAM_LOCAL_ADDRESS%"
236+
downstream_remote_address: "%DOWNSTREAM_REMOTE_ADDRESS%"
237+
requested_server_name: "%REQUESTED_SERVER_NAME%"
238+
route_name: "%ROUTE_NAME%"

examples/mcp/openai-github.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ spec:
5454
genai_backend_name: "%DYNAMIC_METADATA(io.envoy.ai_gateway:backend_name)%"
5555
genai_tokens_input: "%DYNAMIC_METADATA(io.envoy.ai_gateway:llm_input_token)%"
5656
genai_tokens_output: "%DYNAMIC_METADATA(io.envoy.ai_gateway:llm_output_token)%"
57+
# MCP specific fields
58+
mcp_request_id: "%DYNAMIC_METADATA(io.envoy.ai_gateway:mcp_request_id)%"
59+
mcp_session_id: "%REQ(MCP-SESSION-ID)%"
60+
mcp_method: "%DYNAMIC_METADATA(io.envoy.ai_gateway:mcp_method)%"
61+
mcp_backend: "%DYNAMIC_METADATA(io.envoy.ai_gateway:mcp_backend)%"
5762
# A few default fields
5863
start_time: "%START_TIME%"
5964
method: "%REQ(:METHOD)%"

internal/autoconfig/config.yaml.tmpl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@ spec:
6565
genai_backend_name: "%DYNAMIC_METADATA(io.envoy.ai_gateway:backend_name)%"
6666
genai_tokens_input: "%DYNAMIC_METADATA(io.envoy.ai_gateway:llm_input_token)%"
6767
genai_tokens_output: "%DYNAMIC_METADATA(io.envoy.ai_gateway:llm_output_token)%"
68+
{{- end }}
69+
{{- if .MCPBackendRefs }}
70+
# MCP specific fields
71+
mcp_request_id: "%DYNAMIC_METADATA(io.envoy.ai_gateway:mcp_request_id)%"
72+
mcp_session_id: "%REQ(MCP-SESSION-ID)%"
73+
mcp_method: "%DYNAMIC_METADATA(io.envoy.ai_gateway:mcp_method)%"
74+
mcp_backend: "%DYNAMIC_METADATA(io.envoy.ai_gateway:mcp_backend)%"
6875
{{- end }}
6976
# A few default fields
7077
start_time: "%START_TIME%"
@@ -265,6 +272,7 @@ spec:
265272
secretRef:
266273
name: openai-apikey
267274
{{- end }}
275+
---
268276
{{- end }}
269277
{{- range .MCPBackendRefs }}
270278
{{- if .APIKey }}

internal/autoconfig/config_test.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ var (
6363

6464
//go:embed testdata/kiwi.yaml
6565
kiwiYAML string
66+
67+
//go:embed testdata/openai-github.yaml
68+
openaiGithubYAML string
6669
)
6770

6871
func TestWriteConfig(t *testing.T) {
@@ -321,6 +324,41 @@ func TestWriteConfig(t *testing.T) {
321324
},
322325
expected: kiwiYAML,
323326
},
327+
{
328+
name: "OpenAI with GitHub MCP server",
329+
input: ConfigData{
330+
Backends: []Backend{
331+
{
332+
Name: "openai",
333+
Hostname: "api.openai.com",
334+
OriginalHostname: "api.openai.com",
335+
Port: 443,
336+
NeedsTLS: true,
337+
},
338+
{
339+
Name: "github",
340+
Hostname: "api.githubcopilot.com",
341+
OriginalHostname: "api.githubcopilot.com",
342+
Port: 443,
343+
NeedsTLS: true,
344+
},
345+
},
346+
OpenAI: &OpenAIConfig{
347+
BackendName: "openai",
348+
SchemaName: "OpenAI",
349+
Version: "",
350+
},
351+
MCPBackendRefs: []MCPBackendRef{
352+
{
353+
BackendName: "github",
354+
Path: "/mcp/x/issues/readonly",
355+
APIKey: "${GITHUB_MCP_TOKEN}",
356+
IncludeTools: []string{"get_issue", "list_issues"},
357+
},
358+
},
359+
},
360+
expected: openaiGithubYAML,
361+
},
324362
}
325363

326364
for _, tt := range tests {

internal/autoconfig/testdata/azure-openai-with-org-and-project.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,3 +190,4 @@ spec:
190190
azureAPIKey:
191191
secretRef:
192192
name: openai-apikey
193+
---

internal/autoconfig/testdata/azure-openai.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,3 +184,4 @@ spec:
184184
azureAPIKey:
185185
secretRef:
186186
name: openai-apikey
187+
---

0 commit comments

Comments
 (0)