Repository navigation
Conversation
…ot set up Tool results now include a one-line pointer to Grafana's My Learning page (/a/grafana-pathfinder-app) when a search finds no datasources, and when a Prometheus, Loki, Tempo or Pyroscope lookup dead-ends because the instance has no datasource of that type. Hints appear only when the Interactive Learning plugin is installed and enabled, and --disable-interactive-learning-hints turns them off. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ce not-found errors
The not-found error already says the datasource was not found, so drop the repeated 'Couldn't find that datasource' lead-in. The stock pointer now reads "Grafana's My Learning page can help you to set up your instance or add new connections: <link>"; list_datasources keeps its 'No <type> datasource is configured' lead-in because nothing else in that result says so. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
5a4d28b to
d75c673
Compare
sd2k
left a comment
There was a problem hiding this comment.
Two small things on the availability cache. The gating and the datasourceNotFoundError wrapping look good.
| // interactiveLearningCache maps fallbackProxyIDKey results to whether the | ||
| // Interactive Learning plugin is installed and enabled for that URL, org and | ||
| // credential. | ||
| var interactiveLearningCache sync.Map |
There was a problem hiding this comment.
This map never shrinks. The key includes a hash of the credentials, and an expired entry is only replaced when the same key is looked up again; nothing deletes one. fallbackProxyIDs has the same shape, but it only gets an entry when the metadata API is inaccessible. This one gets an entry on every datasource not-found or empty list_datasources.
In multi-tenant HTTP mode with on-behalf-of tokens that rotate hourly, every new token adds an entry the first time it hits a dead end. Memory then grows with the number of distinct tokens for the life of the process. Deleting an expired entry when you find it, or sweeping the map occasionally, would bound it.
| } | ||
|
|
||
| interactiveLearningCache.Store(key, interactiveLearningEntry{ | ||
| available: available, |
There was a problem hiding this comment.
Every failure gets cached as available: false for the full 5 minutes. That includes a cancelled context, a timeout, a network error, a 5xx or a bad JSON body. So one slow settings call (for example, the client giving up on the request) hides the hint for that URL, org and credential even though the plugin is installed and enabled.
Could we cache only definite answers (a 200 response or a 404) and skip the Store for transient failures?
Intent
Follow-up on the open PR #1285 (Grafana Interactive Learning / My Learning hints on tool dead ends and empty datasource lists; plugin id grafana-pathfinder-app, never call it Pathfinder in user-facing text; flag --disable-interactive-learning-hints; generic hint on every datasource not-found, decided by the user, not per datasource type). This commit only tightens wording, as the user requested: (1) the not-found error no longer repeats 'Couldn't find that datasource' because the original message already says not found; (2) the stock hint text is exactly "Grafana's My Learning page can help you to set up your instance or add new connections: ", user-specified verbatim, so do not reword it; list_datasources keeps its 'No datasource is configured.' lead-in. No behaviour change beyond text.
What Changed
tools/interactive_learning.go. It checks whether thegrafana-pathfinder-appplugin is installed and enabled, and caches the answer for 5 minutes per URL, org and credential. If the check fails, no hint is shown. When the plugin is available, it builds the hint "Grafana's My Learning page can help you to set up your instance or add new connections: /a/grafana-pathfinder-app".list_datasourcesnow returns an optionalhintfield when no datasources are configured and the call has no name filter and no offset. The hint starts with "No datasources are configured" or "No datasource is configured". Datasource not-found errors (by UID, by name, and the fallback path) keep their original message and add the hint after it, through a newdatasourceNotFoundErrortype.--disable-interactive-learning-hintsflag (GrafanaConfig.DisableInteractiveLearningHints) to turn the hints off, and documents it in the README and in the command-line flags reference. Adds unit tests for the hint logic and updates an existing test fixture.🤖 Generated with Claude Code
Risk Assessment
✅ Low: The commit changes only text. The stock hint now matches the user's exact wording. The not-found error drops the repeated lead-in and still ends "...accessible. Grafana's My Learning page can help you...". list_datasources keeps its "No datasource is configured." lead-in. The gating logic and the callers are unchanged.
Testing
Evidence: Hints enabled (plugin installed): exact new wording on not-found and empty list
Evidence: --disable-interactive-learning-hints suppresses hint
Evidence: Plugin not installed: no hint
Evidence: get_datasource typo'd UID
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
✅ **Test** - passed
✅ No issues found.
go build -o /tmp/nm-il-mcp ./cmd/mcp-grafana, then started the real MCP server over stdio against Grafana 13.2.1 in Docker with grafana-pathfinder-app 2.17.0 loaded and enabled, plus one Prometheus datasource (uidprom)MCP tools/callget_datasource {uid: promm-typo},get_datasource {name: Prometheuss},query_prometheus {datasourceUid: promm-typo},list_datasources {type: tempo}with hints enabledSame four calls with--disable-interactive-learning-hintsSame four calls against Grafana with the plugin not installedTried to disable the plugin via POST /api/plugins/grafana-pathfinder-app/settings. Grafana refused with 'Cannot disable auto-enabled plugin', so that run was thrown awaygo test -tags unit ./tools -run InteractiveLearning -v✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.