feat(mcp): opt-in group-based tool gating#254
Merged
Conversation
The server registers 39 tools; clients that only need a subset can now hide whole groups or individual tools via NOTEBOOKLM_DISABLED_GROUPS, NOTEBOOKLM_DISABLED_TOOLS, and NOTEBOOKLM_ENABLED_TOOLS. Gating is opt-in: with no configuration every tool stays visible, so existing behavior is unchanged. Tools are hidden through FastMCP's visibility transform rather than unregistered.
Add the three gating environment variables to the MCP guide and a "Selective tool exposure" section with examples and the group list; link to it from the README context-window warning.
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.
feat(mcp): opt-in group-based tool gating
Summary
Adds an optional way to hide MCP tools by group or by name through
environment variables, so a client can expose only the subset it needs
and save context. Gating is opt-in: with no configuration every tool
stays visible and current behavior is unchanged.
Motivation
The README already carries a context-window warning: "This MCP provides
39 tools. Disable it when not using NotebookLM to preserve context."
Today the only lever is all-or-nothing (toggle the whole server off with
@notebooklm-mcp). A query-first client that wants the read and chattools but not the studio, research, or management tools has no way to
trim the set without editing code.
This change gives that lever without changing the default for anyone.
What changed
src/notebooklm_tools/mcp/tool_groups.py(new): a read/manage taxonomymapping every registered tool into exactly one named group, plus the
resolution logic and an
apply(mcp)entry point.src/notebooklm_tools/mcp/server.py: callstool_groups.apply(mcp)once at the end of
_register_tools(), after all tools are registered.tests/test_tool_groups.py(new): unit tests for env resolution,precedence, the no-op path, and taxonomy disjointness.
README.md,docs/MCP_GUIDE.md: document the three environmentvariables and add a "Selective tool exposure" section with examples
and the full group list.
Behavior
Three environment variables, resolved in this order (later wins for a
given tool):
NOTEBOOKLM_DISABLED_GROUPS: comma-separated group names to hide.NOTEBOOKLM_DISABLED_TOOLS: comma-separated single tool names to hide.NOTEBOOKLM_ENABLED_TOOLS: comma-separated tool names to re-enable,overriding the two above.
Tools are hidden through FastMCP's visibility transform
(
mcp.local_provider.disable(names=...)), so nothing is unregistered,only hidden. Unknown group names are ignored. With none of the variables
set,
apply()is a no-op and all 39 tools remain visible.Usage
Testing
uv run pytest tests/test_tool_groups.py: 9 new tests pass.tests/services/test_sources.pyexists onmainbefore this branch;reported separately, not touched here).
uv run ruff check .anduv run ruff format --check .: clean.the client. With no env vars set, 39 tools are visible. With
NOTEBOOKLM_DISABLED_GROUPSset to the six manage/studio/research/etc.groups, the client-facing list drops to the read and chat core with no
disabled tool leaking through.
This feature does not call the NotebookLM API; it only changes which
already-registered tools are advertised to the MCP client. There is no
CLI surface for it.
Notes
one of the new variables.