Skip to content

fix(#469): suggest-mcp-search surfaces to the agent + install-gates#470

Merged
atlas-apex merged 1 commit into
me2resh:devfrom
atlas-apex:fix/GH-469-mcp-search-surface
May 31, 2026
Merged

fix(#469): suggest-mcp-search surfaces to the agent + install-gates#470
atlas-apex merged 1 commit into
me2resh:devfrom
atlas-apex:fix/GH-469-mcp-search-surface

Conversation

@atlas-apex

Copy link
Copy Markdown
Collaborator

Summary

  • Fixes the suggest-mcp-search advisory 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 available banner to stderr with exit 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).
  • Now emits hookSpecificOutput.additionalContext JSON on stdout (exit 0, non-blocking) — a system reminder the model reads on the next turn, without blocking the Bash call.
  • Install-gated. It only nudges when apexyard-search is 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.
  • Detection logic (grep/find targeting framework or workspace//projects/ paths) is unchanged.

Testing

  • bash .claude/hooks/tests/test_suggest_mcp_search.sh11 passed. The suite was rewritten to inject the gate via a temp $APEXYARD_PORTFOLIO_ROOT/.mcp.json fixture and asserts: additionalContext JSON emitted when gated-on; silence when apexyard-search isn't configured; silence on non-search commands, non-framework paths, and non-Bash tools; output is valid JSON.
  • Example paths in the test genericized (no private project names committed to the public repo).

Glossary

Term Definition
additionalContext The hookSpecificOutput field a PreToolUse hook prints to stdout (exit 0) to inject a non-blocking advisory the model reads.
Install-gate Emitting the MCP nudge only when the apexyard-search MCP server is actually configured in .mcp.json.

Closes #469

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
@atlas-apex atlas-apex merged commit 258365a into me2resh:dev May 31, 2026
3 checks passed
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants