feat(mcp): --tools flag to select exposed MCP tools (#716) - #717
Open
gustav-fff wants to merge 2 commits into
Open
feat(mcp): --tools flag to select exposed MCP tools (#716)#717gustav-fff wants to merge 2 commits into
gustav-fff wants to merge 2 commits into
Conversation
Add a CLI-configurable tool selector to fff-mcp. Default stays "all three" so existing configs are unchanged; picking a subset removes the unused tools from the router and drops the parts of MCP_INSTRUCTIONS that describe them, saving system-prompt tokens. - clap ValueEnum accepts find_files,grep,multi_grep (snake_case). Unknown names fail startup with the list of valid values. - FffServer::new takes the exposed set, filters the rmcp ToolRouter via remove_route, and builds instructions dynamically. - MCP_INSTRUCTIONS is now assembled by build_instructions() in a new instructions module; sections referring to disabled tools (e.g. multi_grep rule 4, grep constraint syntax) are omitted. Closes #716
dmtrKovalenko
approved these changes
Jul 28, 2026
dmtrKovalenko
left a comment
Owner
There was a problem hiding this comment.
The implementation is pretty sloppy but it makes sense @gustav-fff can you please make at least comments less sloppy
- ExposedTool + tool_name are pub(crate); ALL is a const array. - Drop the re-export of build_instructions; server imports it directly. - Server reuses ExposedTool::ALL instead of a hardcoded list. - Shorter --tools clap doc (clap already prints valid values).
Collaborator
Author
|
[triage-bot] DIRECTED: pushed 1dcdc2b.
`cargo test -p fff-mcp` 17/17, `cargo clippy -p fff-mcp --no-deps` clean. Honk-Honk 🪿 |
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.
Closes #716
Root cause
fff-mcpunconditionally registersfind_files,grep, andmulti_grepin the rmcpToolRouterand ships the full 75-lineMCP_INSTRUCTIONSblob (crates/fff-mcp/src/main.rs:19-93on pre-fixmain). Every client pays the schema + instructions cost even if it only needs one tool.Fix
Add
--tools <name,...>(clapValueEnum, snake_case, comma-separated, default = all three).FffServer::newnow takes the exposed set, filters the router viaToolRouter::remove_route, and stores instructions built by a newbuild_instructions()helper.multi_grep,grep/multi_grepconstraint syntax) are omitted so the model is not told to use tools it cannot call.Behavior with no flag is identical to before.
Steps to reproduce
Before the fix, on
origin/main:After the fix:
Expected: unknown names hard-fail at startup; enabled subset is the only thing
list_toolsreturns;get_info().instructionsno longer mentions the disabled tools.How verified
cargo clippy -p fff-mcp --no-depsclean;cargo fmtapplied.Automated triage via Gustav. Honk-Honk 🪿