Repository navigation
Conversation
Hide resource generation without an injected model and PromQL generation without an OpenAI API key. Cover tool discovery and invocation through MCP in both read-only and read-write mode. Fixes kagent-dev#93 Signed-off-by: Pavan Nalam <pavan.nalam3693@gmail.com>
ntmspavan
marked this pull request as ready for review
November 16, 2026 23:21
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.
Fixes #93
The server advertises
k8s_generate_resourceandprometheus_promql_tooleven when their LLM configuration is missing. Agents can select these tools, but every call then fails.Only register resource generation when the caller supplies an LLM, and PromQL generation when
OPENAI_API_KEYis non-empty. Other tools and the existing read-only restrictions stay available as before. The README explains the optional Helm Secret and why the CLI cannot currently offer Kubernetes resource generation, even with an OpenAI key.Tests exercise MCP tool discovery and invocation with missing and configured models, unset and empty keys, and both access modes. Configured generation uses a mock model or local HTTP server.
Validation with Go 1.27.3 in an isolated container:
make fmtmake lint— zero issuesmake test— passed, including all five platform buildsgo test -tags=test -race ./pkg/k8s ./pkg/prometheus ./cmd -coverprofile=/tmp/issue93-coverage.out— passedBoth changed registration functions have 100% statement coverage. Package coverage is 86.7% for Prometheus and 77.2% for Kubernetes. I checked Kubernetes coverage on the unchanged base: it was already 77.1%, below the documented 80% target.
No public function signatures or tool inputs/outputs change. Tools without configuration intentionally disappear from discovery. Configuration is checked at registration; restart the server after adding the key. This does not validate credentials or model access, and no live-cluster or real-model testing was performed.