Repository navigation
mcp, ai-vercel: hide commands whose when is false (#67) - #73
Merged
Merged
Conversation
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… (review of #67) Co-Authored-By: Claude Sonnet 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.
Closes #67.
context(already oncreateMcpServerandtoAITools, until now only passed to dispatch) now also filters the list:registry.list({ context })evaluates stringwhenclauses, so an unavailable command is not offered. New:buildToolsList(registry, { context }).contextmay be a function (ContextSource), read on everytools/list, build and dispatch, so it follows a context that changes. No context → unchanged. The getState name-collision check ignores the context on purpose.when_clause_failedat dispatch stays as the backstop. Note: the MCP server cannot know when a context changes; the doc comment says to sendnotifications/tools/list_changed.Tests: tools (4), a real server over the SDK's in-memory transport (2), toAITools (3). Mutation-checked (reverting the sources fails 6). Suites: mcp 44, ai-vercel 14, tsc clean. Minor changeset (new option behaviour: listings shrink for callers who already passed
context). Skills/README updated; the 'not implemented yet' note dropped.Adversarial review (fresh Opus): fix-then-merge. Confirmed and fixed: (1) passing context to registry.list ran function whens that are then excluded anyway and could throw, failing the whole tools/list — availability is now checked after the function-when exclusion (regression tests, both packages); (2) the ai-vercel dispatch test could not detect a broken getter — now has a positive case; (3) no MCP test dispatched with a function context — added; (4) docs: changeset and README now say the list is fixed when built and the server never sends list_changed for a context change. (5) A throwing context getter is a protocol error on tools/call: documented. Checked fine: missing keys are false (commands that used to fail at dispatch are the ones now hidden), collision check ignores context, hidden commands stay callable by name (dispatch re-checks when). Not changed: toAITools and toToolNameMap each read a function context separately.
🤖 Generated with Claude Code