feat(tools): let MCP_TOOLS register a subset of tool groups - #2
Open
wromansky wants to merge 1 commit into
Open
Conversation
All 81 tools are registered unconditionally today. That is a lot of schema
for one agent to carry, and it is a problem for two kinds of deployment:
- Agents driven by small local models. Tool-selection accuracy falls off as
the surface grows, and every schema is spent from a modest context window.
- Single-purpose agents. A food-logging assistant has no business holding 24
routine-authoring tools.
MCP_TOOLS takes a comma-separated list of group names, following the same CSV
convention as ALLOWED_HOSTS. Empty keeps the current behaviour, so this is
backwards compatible.
MCP_TOOLS=nutrition,off,profile
_REGISTRARS becomes a name-keyed dict and TOOL_GROUPS is derived from it, so
the documented list cannot drift from the code. Registration iterates that
dict rather than the env var, which keeps tool order stable however the
variable is written and makes a repeated name harmless instead of a duplicate
registration.
An unknown group name raises at startup, naming both the typo and the valid
groups. Silently registering nothing is the failure mode most likely to cost
a self-hoster an evening.
Adds 8 tests covering the default, a subset, duplicates, env ordering, the
unknown-name error, CSV parsing, and that every name in TOOL_GROUPS is
independently valid.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This was referenced Aug 13, 2026
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.
Why
All 81 tools are registered unconditionally today. That is a lot of schema for one agent to carry, and it is awkward for two kinds of deployment:
The handoff notes list several open items, but not this one — it surfaced while wiring the server up to a self-hosted instance for exactly that small-local-model case.
What
MCP_TOOLStakes a comma-separated list of group names, using the same CSV convention asALLOWED_HOSTS. Empty keeps today's behaviour, so the change is backwards compatible.MCP_TOOLS=nutrition,off,profile # a food-logging agentValid names are the module names:
profile,routines,workout_logs,body_weight,measurements,equipment,nutrition,exercises,analytics,off.Three details worth a look during review:
_REGISTRARSbecomes a name-keyed dict andTOOL_GROUPSis derived from it, so the documented list cannot drift from the code.Tests
8 new tests in
tests/test_tool_selection.py: the default surface, a subset, duplicates, env ordering, the unknown-name error, CSV parsing, and that every name inTOOL_GROUPSis independently valid — so the documented list stays honest as groups are added.Full suite passes (79) and
ruff checkis clean.MCP_TOOLSwas added to the conftest cleared-vars list so a stray value in the environment cannot skew other tests.Docs
README.mdgains a short section under Tools, and.env.examplea commented block next to the other optional settings.