fix(web_fetch_exa): validate urls as URI; warn against API key in query string - #338
Open
serhiizghama wants to merge 3 commits into
Open
Conversation
Wrap the urls item type with z.string().url() so the generated JSON Schema exposes format: "uri" for client-side validation, and the tool rejects inputs that are clearly not URLs.
Query-string secrets leak through shell history, proxy logs, and screenshots. Drop the key from the multi-tool example and add a note pointing users at MCP client secret/header config or EXA_API_KEY.
|
@serhiizghama is attempting to deploy a commit to the Exa Team on Vercel. A member of the Team first needs to authorize it. |
|
Thanks @serhiizghama — both fixes look right to me, especially the unit test addition. Appreciate you picking this up |
Author
…alidation-and-query-string-warning # Conflicts: # README.md
Author
|
Rebased on main. The only conflict was our security note landing right next to the new Exa Agent toolset docs — kept both. The URL-validation fix and its test are unchanged. Ready when you are. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Addresses both findings raised in #334:
web_fetch_exatool schema declaresurls.itemsas a plain string. Since the tool only ever crawls URLs, advertisingformat: "uri"makes client-side validation clearer and lets MCP clients flag obviously bad inputs before a round trip.?exaApiKey=YOUR_KEY&tools=...). Query-string secrets are easy to leak through shell history, proxy logs, browser history, screenshots, and support bundles (CWE-598).Solution
src/tools/webFetch.ts: wrap the urls item type withz.string().url()so the generated JSON Schema exposesformat: "uri"and the tool rejects inputs that are clearly not URLs.README.md: dropexaApiKey=YOUR_KEYfrom the multi-tool example and add a short security note recommending the MCP client's secret/header configuration (orEXA_API_KEYfor the npm package).Testing
npm run typecheck— cleannpm test— 82 passed (added one case verifying the schema rejects non-URL strings and still accepts validhttps://URLs)