Make server instructions reflect disabled categories#579
Open
drtootsie wants to merge 1 commit intografana:mainfrom
Open
Make server instructions reflect disabled categories#579drtootsie wants to merge 1 commit intografana:mainfrom
drtootsie wants to merge 1 commit intografana:mainfrom
Conversation
Addresses grafana#552 The MCP server instructions are now dynamically built based on which tool categories are actually enabled, preventing AI clients from repeatedly attempting to use disabled features. Changes: - Added buildInstructions() method to disabledTools - Added isEnabled() helper to check if a category is enabled - Dynamically builds Prometheus & Loki line based on what's enabled - Omits disabled categories from instructions entirely Example: With --disable-loki, instructions now say: 'Prometheus: Run PromQL queries...' instead of: 'Prometheus & Loki: Run PromQL and LogQL queries...' This significantly improves the client experience by providing accurate capability information upfront.
|
Pepper Pancoast seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
sd2k
reviewed
Feb 16, 2026
Collaborator
sd2k
left a comment
There was a problem hiding this comment.
I agree that we should do this but I don't like defining another isEnabled function with lots of untyped strings. We already do 'stuff' conditional on each flag being enabled in addTools. I think we could change that to processTools, and wrap each call to maybeAddTools in a function that also builds up the instruction string; that way we only have a single place mapping fields of disabledTools to strings representing the flag.
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.
Addresses #552
Problem
The MCP server instructions were hardcoded and always listed all capabilities, even when categories were disabled. This caused AI clients to repeatedly attempt using disabled features.
Solution
Made instructions dynamic - they now reflect only enabled categories.
Changes
buildInstructions()method to dynamically build instructionsisEnabled()helper to check category statusExamples
With
--disable-loki:With
--disable-loki --disable-oncall --disable-incident:Only enabled categories appear in the instructions.
Impact
AI clients now receive accurate capability information upfront, preventing wasted attempts to use disabled features.
Note
Low Risk
Changes only the human/AI-facing instructions string generation; tool registration and request handling are untouched, so impact is limited to messaging correctness.
Overview
Server startup instructions are no longer hardcoded:
cmd/mcp-grafana/main.gonow builds the MCPWithInstructionstext dynamically from the enabled/disabled tool categories.Adds
disabledTools.isEnabled()andbuildInstructions()to omit disabled capabilities entirely and to tailor the Prometheus/Loki wording based on which of those categories are enabled.Written by Cursor Bugbot for commit 02ee4a2. This will update automatically on new commits. Configure here.