Skip to content

Agent gets stuck when WebFetch is blocked but ctx_fetch_and_index MCP tool is unavailable #230

@benzntech

Description

@benzntech

Problem

When context-mode blocks WebFetch via the PreToolUse hook, it instructs the agent to use ctx_fetch_and_index instead. However, if the context-mode MCP server is not running (or its tools are not yet registered in the session), the agent has no fallback and gets stuck — repeatedly retrying WebFetch and receiving the same blocking error.

Steps to Reproduce

  1. Install context-mode plugin and start a new Claude Code session
  2. Ask the agent to fetch a URL (e.g. a GitHub repo page)
  3. The PreToolUse hook blocks WebFetch and tells the agent to use ctx_fetch_and_index
  4. If the MCP server hasn't started / tools aren't registered yet, the agent retries WebFetch and gets blocked again repeatedly

Observed Behavior

PreToolUse:WebFetch hook returned blocking error
context-mode: WebFetch blocked. Use mcp__plugin_context-mode_context-mode__ctx_fetch_and_index(url: "...", source: "...") to fetch this URL in sandbox. Then use mcp__plugin_context-mode_context-mode__ctx_search(queries: [...]) to query results. Do NOT use curl, wget, mcp_web_fetch, or mcp_fetch_tool.

The error fires twice in a row and the agent gives up without completing the task.

Expected Behavior

Either:

  • The MCP server should be guaranteed to be started and tools registered before any WebFetch block fires, OR
  • The hook's deny message should detect MCP tool unavailability and degrade gracefully (e.g. allow the fetch if ctx_fetch_and_index is not available), OR
  • The sessionstart.mjs hook should validate that the MCP server is reachable before the session begins

Environment

  • context-mode version: 1.0.59
  • Platform: macOS
  • Claude Code with PreToolUse hook on matcher: Bash|WebFetch|Read|Grep|Agent|Task|...

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions