-
Notifications
You must be signed in to change notification settings - Fork 198
feet(tools+context): Dynamic tool reg #309
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
gerboland
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: please update the README to reflect the new CLI flag & behaviour.
|
Added a comment about supported protocols. |
sd2k
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love the idea!
| // ToolsetInfo provides information about a toolset | ||
| type ToolsetInfo struct { | ||
| Name string `json:"name" jsonschema:"required,description=The name of the toolset"` | ||
| Description string `json:"description" jsonschema:"description=Description of what the toolset provides"` | ||
| Enabled bool `json:"enabled" jsonschema:"description=Whether the toolset is currently enabled"` | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think it would be worth including ToolNames []string here, as a more concrete hint of what tools this contains?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
README.md
Outdated
| - ✅ **stdio protocol** - Fully supported | ||
| - ❌ **SSE (Server-Sent Events)** - Not yet supported | ||
| - ❌ **Streamable HTTP** - Not yet supported |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh, is this because notifications aren't as well supported over streamable HTTP?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is now fixed. After rebasing on top of your PR. https://github.com/grafana/mcp-grafana/pull/314/files 🥳
3744eaa to
88579d6
Compare
Yeah it should update on the UI as well. The moment you ask more tools to be enabled and the tool is called, the new tools should appear on the UI. |
835e637 to
f57223e
Compare
f57223e to
b28d052
Compare


Dynamic Toolset Discovery and Loading
Summary
Adds dynamic toolset functionality that allows clients to discover and selectively enable tool categories at runtime, significantly reducing context window usage by only loading tools when needed.
Motivation
MCP tool descriptions can consume substantial context window space. By enabling dynamic discovery, clients only load the tools they actually need, preserving context for more important data.
Implementation
New flag:
--dynamic-toolsetsenables dynamic toolset modeDiscovery tools: Added grafana_list_toolsets and grafana_enable_toolset meta-tools
Notification support: Sends tools/list_changed notification when toolsets are enabled, triggering client refresh
Integration with --enabled-tools:
--enabled-tools=""--> no toolsets discoverable--enabled-tools="datasources,dashboards"--> only specified toolsets discoverableLimitations and client compatibility
Protocol Support:
✅ stdio protocol - Fully supported
✅ SSE (Server-Sent Events) - Fully supported
✅ Streamable HTTP - Fully supported
After pr https://github.com/grafana/mcp-grafana/pull/314/files from @sd2k all protocols are supported.
Client Support
✅ Supported: Cursor, VSCode (support notifications)
❌ Not yet: Claude Desktop, Claude Code (no notification support) there are open issues though for it
Known Behavior
Slight delay expected: There may be a few seconds of delay between calling grafana_enable_toolset and the tools becoming available in the client, as the client needs to receive and process the
tools/list_changednotification.Note: This is opt-in via the
--dynamic-toolsetsflag. Existing static tool registration remains the default behavior.How it works with Cursor.
Currently Sonnet 4.5 model selected - 1m tokens available for this conversation
Normal behavior all tools available:
At the beginning 13.9% of context used

How many tools are available 14.1%

List my prometheus datasources 14.8%

Dynamic tool discovery enabled with all tools discoverable.
At the beginning 5.5% of context used

List available toolsets - 5.9%

Enable Datasource toolset

List Datasources 7%
