Skip to content

PreToolUse matchers miss external MCP namespaces; raw output enters context #529

@ccheng555

Description

@ccheng555

PreToolUse matchers miss external MCP namespaces; raw output enters context

Current state (v1.0.103)

hooks/hooks.json PreToolUse covers: Bash, WebFetch, Read, Grep, Agent, and three mcp__plugin_context-mode_context-mode__ctx_* tools. PostToolUse matcher is broad (Bash|...|mcp__) and catches everything post-execution.

Symptom

Large MCP returns reach the agent unfiltered before PostToolUse fires. PreToolUse can't route them through ctx_execute or warn the agent first, because the matcher list doesn't include them.

Concrete examples of large unbounded returns:

  • mcp__slack-* channel history, conversation search (50+ messages)
  • mcp__plugin_telegram__* message content, attachments
  • mcp__claude_ai_Google_Drive__* file content, search results
  • any future notion / obsidian-cli style MCP server

Proposal

Add PreToolUse matchers for external MCP namespaces. Two shapes:

  1. A broader pattern: mcp__(?!plugin_context-mode_).*. Covers all external MCPs and avoids recursing into context-mode.
  2. A per-namespace allowlist that grows as new MCPs are added.

Option 1 scales without manual upkeep. pretooluse.mjs already runs for ctx_* calls, so the existing routing logic should apply.

Workaround

Local edit to hooks/hooks.json, lost on plugin upgrade.

Happy to PR option 1 if that's the direction you'd take.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions