`evaluate_script` `sourcePath` http(s) URLs are mangled into `file://` paths

Aperta Adatta ai principianti
#3,453 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

  • #3571 di @DrSkyle — chiusa senza merge

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
node.js, typescript

Direzione di ricerca

Inizia con resolveScriptSource in src/tools/script.ts e confronta la gestione degli URL con il passaggio diretto di allowUrl in src/ToolHandler.ts e il comportamento di loadResource descritto nell’issue. Controlla lo schema Zod in src/tools/script.ts e la descrizione di sourcePath in docs/tool-reference.md. Il lavoro è completato quando gli URL http(s) e file raggiungono il loader senza modifiche, i percorsi semplici vengono convertiti e la documentazione concorda con lo schema.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

collecting-feedback
Description of the bug

evaluate_script advertises remote sourcePath URLs: file verification is called with allowUrl: true, and McpContext.loadResource can fetch http: / https:. resolveScriptSource then always runs non-file: values through pathToFileURL, so a CDN or gist URL never reaches the network loader.

Actual behavior

pathToFileURL("https://example.com/script.js") produces a bogus path such as file:///…/https:/example.com/script.js. loadResource then treats it as a local file and fails with Unable to read script source from ….

The comment and schema at src/tools/script.ts already state that sourcePath may be an http(s) URL the server fetches. docs/tool-reference.md still describes filesystem-only paths and is stale relative to that code.

This was confirmed by reading the current main code path and by evaluating the pathToFileURL transform; it was not re-run end-to-end against a live page.

Reproduction
  1. Start the MCP server against a page.
  2. Call evaluate_script with only sourcePath: "https://example.com/script.js" (any reachable JS URL).
  3. Observe the error: the URL is rewritten to a file:// path and the fetch never happens.

Root cause: src/tools/script.ts (resolveScriptSource, around lines 237–239) preserves only file: and forces everything else through pathToFileURL, undoing the earlier allowUrl pass-through in src/ToolHandler.ts.

Expectation

If sourcePath is an http:, https:, or file: URL, pass it through unchanged so loadResource can fetch it. Only plain filesystem paths should go through pathToFileURL. The Zod schema and docs/tool-reference.md should match this remote-URL support.

Chrome DevTools MCP version

Latest npm release 1.12.0, and current default branch main at 1d692d31ae37.

Operating system

macOS

Extra checklist
  • I want to provide a PR to fix this bug
Lingua principale
TypeScript
Stelle
59.8k
Fork
4.8k
Merge medio
2g 10h
PR unite (30g)
162

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di ChromeDevTools/chrome-devtools-mcp

Tutte le issue di ChromeDevTools/chrome-devtools-mcp

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.