Skip to content

Make server instructions reflect disabled categories#579

Open
drtootsie wants to merge 1 commit intografana:mainfrom
drtootsie:fix-server-instructions-clarity
Open

Make server instructions reflect disabled categories#579
drtootsie wants to merge 1 commit intografana:mainfrom
drtootsie:fix-server-instructions-clarity

Conversation

@drtootsie
Copy link

@drtootsie drtootsie commented Feb 15, 2026

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

  • Added buildInstructions() method to dynamically build instructions
  • Added isEnabled() helper to check category status
  • Prometheus & Loki line now adapts based on what's enabled
  • Disabled categories are completely omitted

Examples

With --disable-loki:

  • Before: "Prometheus & Loki: Run PromQL and LogQL queries..."
  • After: "Prometheus: Run PromQL queries..."

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.go now builds the MCP WithInstructions text dynamically from the enabled/disabled tool categories.

Adds disabledTools.isEnabled() and buildInstructions() 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.

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.
@drtootsie drtootsie requested a review from a team as a code owner February 15, 2026 20:03
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


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.

Copy link
Collaborator

@sd2k sd2k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants