Repository navigation
fix(ai): the MCP gateway tools take no URL and guard the AI key - #2640
Merged
Merged
Conversation
The three MCP gateway tools take a gateway or backend URL from the model, and the router uses it as configuration. The plan removes the URL from the tools and sends the AI API key only to the configured gateway. Plans #2480.
…ly to the configured gateway The MCP tools ai_gateway_status, ai_gateway_routes and ai_gateway_probe_backend published a gateway or backend URL that the calling model fills in, and the router used it as configuration. A model could reach a loopback service of the host without ai.allow_private_network, and could make `devops ai gateway routes` send the AI API key to any host. - The three tools publish only `provider` or `backend`. A call that gives a URL fails at the argument contract and sends no request. The commands keep --gateway-url and --backend-url for a person. - GatewayRouter.list_routes sends the key only to the scheme, host and port of the configured gateway. A gateway of another origin that refuses the request gets an error that says it got no key. - SECURITY.md states the rule for a URL that a model gives to an MCP tool. Closes #2480.
…teway The key rule sat in GatewayRouter.list_routes. fetch_model_info and the tuning sweep still put the key on the request to any URL, so `devops ai gateway tune --gateway-url <other host>` sent it there. - _query_model_info gives the key only when the origin of the URL is the origin of ai.gateway_url or ai.portkey_url. Every caller of fetch_model_info gets the rule. The router and the OpenAI client pass their own config. - A gateway of another origin that refuses the request gets an error that says it got no key. The unreachable fallback text is gone. - The tests run the rule through list_routes, fetch_model_info and tune_pool. A port that starts with the configured port replaces the row that depended on the way httpx2 reads user information. Each MCP tool has a test for its configured service. The mock hosts are example.com and example.org, and the refusal test checks the error and exit codes.
…follows the new design - SECURITY.md gets principle 11 in short sentences: a URL from a model is untrusted input, and a credential goes only to the origin that the configuration names. The sentence that was added to principle 2 is gone. - The comment of _PATH_PARAM_RESTRICTIONS describes the table as it is now. - The OpenSpec change records that the key rule is where the header is attached, covers the tuning sweep, and lists the MCP tools that still publish a URL option as open exceptions (#2634, #2635, #2637, #2638, #2639). Its text uses sentences of at most 25 words.
The change moves to openspec/changes/archive and its three requirements join the capability ai-gateway-routing.
Owner
Author
|
Test results of the local run (HOME in a temporary directory, null keyring):
Fail-to-pass ( Tests that fail on the base (all in tests/test_ai_gateway.py): Summary line of the tool: |
dan-petty
marked this pull request as ready for review
October 29, 2026 14:11
dan-petty-release Bot
added a commit
that referenced
this pull request
Oct 29, 2026
🤖 I have created a release *beep* *boop* --- ## [0.16.1](v0.16.0...v0.16.1) (2026-10-29) ### Bug Fixes * **ai:** the MCP gateway tools take no URL and guard the AI key ([#2640](#2640)) ([7dde54e](7dde54e)), closes [#2480](#2480) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The MCP tools
ai_gateway_status,ai_gateway_routesandai_gateway_probe_backendpublished a gateway or backend URL that the calling model fills in. The commands used that URL as configuration. A model could reach a loopback service of the host withoutai.allow_private_network. A model could also makedevops ai gateway routessend the AI API key to any host.providerorbackend. A call that gives a URL fails at the argument contract and sends no request. The commands keep--gateway-urland--backend-urlfor a person.fetch_model_info) sends the AI API key only to a gateway that has the scheme, host and port ofai.gateway_urlorai.portkey_url. The router, the tuning sweep, the run store and the OpenAI client get this rule.SECURITY.mdgets principle 11: a URL from a model is untrusted input for an MCP tool.Change: openspec/changes/archive/2026-10-29-2480-mcp-gateway-url-override/
Closes #2480