Skip to content

[Feature]: Env-var opt-out for the main-session WebFetch deny (e.g. CONTEXT_MODE_ALLOW_WEBFETCH=1) #843

@rrva

Description

@rrva

Summary

The PreToolUse WebFetch branch hard-denies WebFetch in the main session and redirects to ctx_fetch_and_index (hooks/core/routing.mjs ~L800, action: "deny"). This is intentional and valuable as a default, but there is currently no first-class way to opt out of just this interception while keeping the rest of context-mode enabled. I'd like to request an env-var opt-out, e.g. CONTEXT_MODE_ALLOW_WEBFETCH=1, checked in the canonical === "WebFetch" branch and returning pass-through (null) when set.

Environment

  • context-mode 1.0.162 (plugin via marketplace), Claude Code CLI, macOS
  • MCP server running normally in the main session (ctx_doctor all green)

Why this is needed

Confirmed (source + DeepWiki) that no env var, config file, or per-tool allowlist/denylist disables the WebFetch deny — the routing is hardcoded. The only way to restore WebFetch today is to edit the plugin-cache hooks/hooks.json (drop the WebFetch matcher) or patch the routing.mjs branch to return null. Both work, but live under the install-cache path and are silently overwritten on every plugin update, so they aren't durable.

There are legitimate reasons to want WebFetch directly in the main session:

Precedent

This is the same shape already requested for a different hook branch in #832 (CONTEXT_MODE_DISABLE_AGENT_INJECTION=1 for the Agent-injection branch). A symmetric WebFetch flag would be consistent with that, and with the existing env-var surface (CONTEXT_MODE_REQUIRE_SECURITY, CONTEXT_MODE_PLATFORM, CONTEXT_MODE_DEBUG, …).

Relationship to existing issues

Proposed (any one resolves it)

  1. Env-var opt-out CONTEXT_MODE_ALLOW_WEBFETCH=1 (or CONTEXT_MODE_DISABLE_WEBFETCH_REDIRECT=1), checked in the canonical === "WebFetch" branch of routing.mjs, returning null (pass-through) instead of the deny.
  2. A more general per-tool deny/allow list config covering WebFetch (would also subsume parts of PreToolUse/PostToolUse hooks intercept small Bash/WebFetch calls without a size threshold (Claude Code) — unlike Gemini CLI's size-aware BeforeTool matcher #817/[Feature]: Env-var opt-out for subagent Agent-injection - foreground agents can hang on forced ctx_* calls #832).
  3. At minimum, document that the WebFetch deny exists and how to disable it.

Rationale for opt-out over removal: the default deny stays for everyone who wants it; this only adds an escape hatch.

Happy to send a PR for option 1 if you're open to it.

🤖 Filed with Claude Code

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