fix(#469): suggest-mcp-search surfaces to the agent + install-gates#470
Merged
Merged
Conversation
The advisory was written to stderr with exit 0 — which Claude Code does NOT inject into the model's context, so the nudge was invisible to the agent (the exact failure the hook exists to prevent). It also fired regardless of whether apexyard-search was installed, nagging adopters without the premium component. - Emit the advisory as hookSpecificOutput.additionalContext JSON on STDOUT (exit 0, non-blocking) so the model actually reads it on the next turn. - Install-gate: only emit when `apexyard-search` is in a resolvable .mcp.json (ops root via the hook's own path, or $APEXYARD_PORTFOLIO_ROOT). Silent fallback to plain grep otherwise. - Detection (grep/find + framework/workspace paths) unchanged. - test_suggest_mcp_search.sh rewritten: asserts additionalContext JSON when gated-on, silence when apexyard-search isn't configured + on non-matches. 11 passed. Example paths genericized (no private project names). Closes #469
me2resh
added a commit
that referenced
this pull request
Jun 5, 2026
…470) The advisory was written to stderr with exit 0 — which Claude Code does NOT inject into the model's context, so the nudge was invisible to the agent (the exact failure the hook exists to prevent). It also fired regardless of whether apexyard-search was installed, nagging adopters without the premium component. - Emit the advisory as hookSpecificOutput.additionalContext JSON on STDOUT (exit 0, non-blocking) so the model actually reads it on the next turn. - Install-gate: only emit when `apexyard-search` is in a resolvable .mcp.json (ops root via the hook's own path, or $APEXYARD_PORTFOLIO_ROOT). Silent fallback to plain grep otherwise. - Detection (grep/find + framework/workspace paths) unchanged. - test_suggest_mcp_search.sh rewritten: asserts additionalContext JSON when gated-on, silence when apexyard-search isn't configured + on non-matches. 11 passed. Example paths genericized (no private project names). Closes #469 Co-authored-by: me2resh <ahmed.abdelaliem@gmail.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.
Summary
suggest-mcp-searchadvisory never reaching the agent ([Bug] suggest-mcp-search advisory never reaches the agent (stderr+exit0) and isn't install-gated #469). The hook (from [Feature] Enforce MCP search-first pattern — advisory hook + session-start auto-load #418) wrote its💡 MCP search availablebanner to stderr withexit 0— which Claude Code does not inject into the model's context. So the hook fired correctly but the nudge was invisible to the agent, which is the exact failure it exists to prevent (confirmed against the hooks contract: only exit-2 stderr reaches the model, and exit 2 blocks the tool — wrong for an advisory).hookSpecificOutput.additionalContextJSON on stdout (exit 0, non-blocking) — a system reminder the model reads on the next turn, without blocking the Bash call.apexyard-searchis configured in a resolvable.mcp.json(ops root via the hook's own path, or$APEXYARD_PORTFOLIO_ROOT). Adopters without the premium search component get silent fallback to plain grep — no nag.workspace//projects/paths) is unchanged.Testing
bash .claude/hooks/tests/test_suggest_mcp_search.sh— 11 passed. The suite was rewritten to inject the gate via a temp$APEXYARD_PORTFOLIO_ROOT/.mcp.jsonfixture and asserts: additionalContext JSON emitted when gated-on; silence whenapexyard-searchisn't configured; silence on non-search commands, non-framework paths, and non-Bash tools; output is valid JSON.Glossary
hookSpecificOutputfield a PreToolUse hook prints to stdout (exit 0) to inject a non-blocking advisory the model reads.apexyard-searchMCP server is actually configured in.mcp.json.Closes #469