Repository navigation
Mark tools hidden by MCP_PERMISSIONS and sharpen overlapping tool descriptions - #43
Merged
Merged
Conversation
…criptions
- Tools whose permission class is not enabled are marked wherever they are named
("(needs MCP_PERMISSIONS write|destructive|admin)"): tool and parameter descriptions,
server instructions, prompts, guide resources and get_guide. Extends the "(full tool set)"
mark of MCP_TOOLSET=core; both reasons combine in one mark. Marks follow call arguments
and a closing backtick.
- Overlapping tools (get_training_summary / get_weekly_summary / get_coach_context /
get_training_load / get_load_projection; get_wellness_data / get_recovery_snapshot /
get_wellness_trends / get_nutrition_summary) name the sibling to use for the other cases
in their first paragraph. No behaviour changes.
- Tests: no unmarked reference to an unregistered tool at MCP_PERMISSIONS=read, no write
marks at read,write (real MCP session in a fresh process), mark placement, siblings.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Glama's tool-definition quality score (TDQS 3.9/5) found two problems, and this PR fixes both.
1. References to tools that the permission classes hide
With the default
MCP_PERMISSIONS=read, the descriptions, server instructions, prompts and guides named write tools such asadd_or_update_event,add_events_bulk,create_library_workoutandupdate_sport_settings. Those tools are missing fromtools/list, so Glama called the server "a dead-end for mutations".This extends the "(full tool set)" mechanism from #28 into
mcp_instance.mark_unavailable_tools(text, toolset, permissions), which replacesmark_outside_toolset:MCP_TOOLSET=corestill gets "(full tool set)". When both apply, the reasons share one mark: "(full tool set, needs MCP_PERMISSIONS write)".tools/list), the server instructions (IntervalsFastMCP.mark_instructions(), called at the end ofserver.pyonce every tool is defined), prompts, guide resources andget_guide.`add_or_update_event` (needs …),get_durability(...) (full tool set)), so a Markdown code span keeps the exact tool name. Marking an already marked text again changes nothing.get_activitiespointed toget_gear_listwithout a mark.read,write, no write tool is marked. Only the admin toolsupdate_sport_settingsandadd_events_bulkkeep "(needs MCP_PERMISSIONS admin)".Examples (real
tools/list/ initialize over stdio):MCP_PERMISSIONS=read)MCP_PERMISSIONS=read)validate_workoutget_sport_settingsvalidate_workoutread,write,validate_workoutKnown limitation (possible follow-up): with OAuth, a connection can be granted fewer classes than the server enables. The tools hidden only for that token are not marked, because the marks follow
MCP_PERMISSIONS.tools/callstill refuses them with the reconnect hint.2. Overlapping tools
The first paragraph of each description now says when to use the tool and which sibling to use for the other cases. Every description stays at 900 characters or fewer. There are no behaviour changes, renames or merges.
get_training_summaryget_weekly_summaryget_coach_contextget_training_loadget_load_projectionget_wellness_dataget_recovery_snapshotget_wellness_trendsget_nutrition_summaryThe "X: tool" cross-references at the end of these descriptions moved into the first paragraph. The usage guide's totals line now says the same.
Token counts
These come from a real stdio round trip (
futureweb-intervals-mcp, initialize +tools/list, placeholder credentials, no Intervals.icu request). They are tiktoken cl100k counts of the compacttools/listJSON. The catalogue budget intests/test_catalogue.pyuses chars/4.MCP_PERMISSIONS/ tool setTests
test_unregistered_tools_are_marked_everywhere_in_a_fresh_process[read, read,write]: runs a fresh process with thatMCP_PERMISSIONSand opens a real MCP session (initialize,tools/list, every prompt, every guide resource,get_guidefor every topic). It checks that every mention of a package tool carries exactly the expected mark: none for an exposed tool, the reasons for a hidden one. It also checks thatread,writehas no write mark and that no request leaves the machine.test_unavailable_tool_marks_placement_and_combination: mark placement (backticks, call arguments), combined marks, idempotence, and no false matches (get_events_x).test_core_toolset_marks_tools_outside_the_set: now also covers parameter descriptions.test_overlapping_tools_name_the_sibling_for_the_other_cases: checks the "For … use get_…" sentence and the siblings in the first paragraph.Checks:
ruff check .,mypy src testsandpytest(whole suite) passed. The pylint gate (pylint --disable=C0301 --fail-under=0 --fail-on=E,F) exits 0 and reports no messages in the changed files.🤖 Generated with Claude Code