Skip to content

fix(k8s): the MCP tool k8s_logs takes no Loki URL - #2668

Merged
dan-petty merged 6 commits into
mainfrom
fix/2635-k8s-logs-mcp-loki-url
Oct 29, 2026
Merged

dan-petty merged 6 commits into
mainfrom
fix/2635-k8s-logs-mcp-loki-url

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

The MCP tool k8s_logs published the option loki_url. A model that gave it made devops-cli send a GET request to any path of any loopback or private host. The tool then returned the answer text of that host in its error or its log lines.

The tool now publishes only its other options, through _PATH_PARAM_RESTRICTIONS. It queries the default Loki, as devops k8s logs does when it gets no --loki-url. A call that gives loki_url fails at the argument contract and sends no request. The command keeps --loki-url for a person.

The code has no loki.url setting. So the tool dials the localhost default, and #2651 covers the missing setting.

Change: openspec/changes/archive/2026-10-29-2635-k8s-logs-mcp-no-loki-url/

Closes #2635

Plans the change for issue 2635. The proposal records the offline probe
that shows the defect, and the design records the decisions.
Refs #2635. The tests call the tool through a FastMCP client. They check
the published schema, the refusal of a loopback or private loki_url, the
default Loki for a call with no URL, and the option of the command.
Refs #2635. The tool published loki_url, and a model could make the
client send a GET request to any path of a loopback or private host and
read the answer text. The tool now publishes no URL and queries the
default Loki, as the command does without --loki-url. The command keeps
its option for a person.
Refs #2635. docs/TESTING.md says a CLI test uses the cli fixture and not
a CliRunner that the test builds.
…2651

Refs #2635. The design says that #2651 must modify the scenario of the
default Loki and its test.
@dan-petty dan-petty added scope/security Security linters (trivy, bandit, gitleaks, kubeconform) and Vault type/security Type security: a vulnerability or a leak labels Oct 29, 2026
@dan-petty

Copy link
Copy Markdown
Owner Author

Targeted tests on the rebased branch: 652 passed (tests/test_k8s_logql.py, test_mcp.py, test_fastmcp_contracts.py, test_valkey.py, test_k8s_logging_stack.py, test_http_egress.py, test_ai_gateway.py).
ruff check, ruff format, mypy on generator.py, openspec check and docs check pass.

Fail-to-pass against origin/main (exit 0). Three new tests fail on base and pass on the branch:

  failed on base: tests.test_k8s_logql.TestLogsToolTakesNoLokiUrlFromTheModel::test_the_tool_publishes_no_loki_url_parameter (AssertionError: assert [['pod', 'que...follow', ...]] == [['pod', 'que...follow', ...]])
  failed on base: tests.test_k8s_logql.TestLogsToolTakesNoLokiUrlFromTheModel::test_a_loki_url_argument_is_refused_and_reaches_no_socket[host in a private range] (AssertionError: assert (True, False,...2.10', 8200)]) == (True, Tru
  failed on base: tests.test_k8s_logql.TestLogsToolTakesNoLokiUrlFromTheModel::test_a_loki_url_argument_is_refused_and_reaches_no_socket[loopback] (AssertionError: assert (True, False,....0.1', 8200)]) == (True, True, False, []))
3 failed on base (3 failed and 34 passed in tests/test_k8s_logql.py; 0 errored).

Offline probe on origin/main: a loopback listener got GET /v1/sys/seal-status?query=... and the marker text of its answer came back in the tool error. After the change, the call fails at the argument contract and the listener sees 0 requests.

@dan-petty
dan-petty marked this pull request as ready for review October 29, 2026 15:06
@dan-petty
dan-petty merged commit 39fae85 into main Oct 29, 2026
17 checks passed
@dan-petty
dan-petty deleted the fix/2635-k8s-logs-mcp-loki-url branch October 29, 2026 15:07
dan-petty-release Bot added a commit that referenced this pull request Oct 29, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.16.5](v0.16.4...v0.16.5)
(2026-10-29)


### Bug Fixes

* **ai:** name benchmark servers and models by host and port
([#2666](#2666))
([8a08031](8a08031)),
closes [#2481](#2481)
* **config:** the audit-keys alert names the removal commands
([#2663](#2663))
([3eb138d](3eb138d)),
closes [#2513](#2513)
* **k8s:** the MCP tool k8s_logs takes no Loki URL
([#2668](#2668))
([39fae85](39fae85)),
closes [#2635](#2635)

---
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/security Security linters (trivy, bandit, gitleaks, kubeconform) and Vault type/security Type security: a vulnerability or a leak

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(k8s): a loki url that the mcp tool k8s_logs gets from the model reaches private addresses and returns the answer

1 participant