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

Open Beginner friendly
#3,453 3 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

  • #3571 by @DrSkyle — closed without merging

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
node.js, typescript

Research direction

Start with resolveScriptSource in src/tools/script.ts and compare its URL handling with the allowUrl pass-through in src/ToolHandler.ts and the loadResource behavior described in the issue. Check the Zod schema in src/tools/script.ts and the sourcePath description in docs/tool-reference.md. Done when http(s) and file URLs reach the loader unchanged, plain paths are converted, and the docs and schema agree.

Written by the indexing model from the issue text.

Description

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
Dominant language
TypeScript
Stars
59.8k
Forks
4.8k
Avg merge
2d 10h
Merged PRs (30d)
162

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ChromeDevTools/chrome-devtools-mcp

All issues in ChromeDevTools/chrome-devtools-mcp

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.