Skip to content

WebFetch redirect has no exemption for claude.ai/code/artifact URLs, breaks artifact fetches #984

Description

@kewtyboi

Summary

The routing hook (hooks/core/routing.mjs) unconditionally denies every WebFetch call and redirects to ctx_fetch_and_index, with no exemption for claude.ai/code/artifact/{uuid} URLs. This makes it impossible to fetch the actual content of a Claude Code artifact through Claude Code's tool set while context-mode is active.

Root cause

ctx_fetch_and_index is a plain unauthenticated HTTP fetch with no JS rendering. claude.ai/code/artifact/{uuid} pages are SPA-rendered and require Claude Code's native WebFetch authenticated fetch path (this is documented directly in WebFetch's own tool description as an explicit exception: "claude.ai/code/artifact/{uuid} URLs ARE fetchable, WebFetch uses your claude.ai login"). Redirecting these URLs to ctx_fetch_and_index can only ever return the SPA shell, never the artifact's rendered content — there is no workaround through the sandboxed tool.

Suggested fix

Add an exemption in the WebFetch handler so claude.ai/preview.claude.ai artifact URLs bypass the redirect and reach the real WebFetch tool, e.g.:

if (canonical === "WebFetch") {
  const url = toolInput.url ?? "";
  if (/^https:\/\/(preview\.)?claude\.ai\/code\/artifact\//.test(url)) {
    return null;
  }
  return mcpRedirect({ /* ...existing redirect... */ });
}

Verified locally: this patch, applied both to the installed plugin cache and the marketplace source copy, restores correct artifact fetching (tested against a real published artifact).

Secondary note (not the main bug, worth being aware of)

Once the redirect is bypassed, WebFetch's native artifact handling saves the full page HTML (1MB+, mostly embedded base64 web fonts) to a file and returns only a small head preview, rather than a prompt-processed extract. Not something this plugin needs to fix, but worth documenting for anyone hitting this: pull real content out of the saved HTML via a script that strips <style>/<script> tags rather than reading the raw file.

Environment

  • context-mode plugin version: 1.0.162
  • Reproduced via Claude Code with context-mode installed as a marketplace plugin

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