fix: accept omitted arguments for zero-arg web_search_help prompt - #362
Open
serhiizghama wants to merge 3 commits into
Open
fix: accept omitted arguments for zero-arg web_search_help prompt#362serhiizghama wants to merge 3 commits into
serhiizghama wants to merge 3 commits into
Conversation
|
@serhiizghama is attempting to deploy a commit to the Exa Team on Vercel. A member of the Team first needs to authorize it. |
…-rejects-omitted-arguments # Conflicts: # src/mcp-handler.ts
Author
|
Rebased on main — only a comment conflict where the note landed next to the prompt registration. The fix (dropping the empty |
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
The
web_search_helpprompt declares no arguments, butprompts/getfails when a client omitsparams.arguments:Root cause is in
src/mcp-handler.ts, where the prompt is registered with an empty args schema:Passing
{}selects the SDK'sprompt(name, description, argsSchema, cb)overload. The SDK then buildsz.object({})and, in theprompts/gethandler, runsargsSchema.parse(request.params.arguments). Whenargumentsis omitted, that becomesz.object({}).parse(undefined)→ "expected object, received undefined".This breaks spec-compliant clients that drop empty maps. For example the official Go SDK:
A
nil/empty map is omitted underomitempty, so a zero-argument prompt request is serialized withoutargumentsand is rejected. Per the MCP specparams.argumentsis optional, so a no-argument prompt should accept its absence.Fixes #358.
Solution
Drop the empty args schema so registration uses the
prompt(name, description, cb)overload. With no args schema the SDK skips argument validation entirely (if (prompt.argsSchema)is false → the no-arg callback branch runs), andprompts/getsucceeds whetherargumentsis omitted or{}.The prompt takes no arguments, so removing the empty schema has no functional downside — there is nothing to validate.
Testing
npm test— 91/91 pass, including a new regression assertion thatweb_search_helpis registered without an args schema and that its handler resolves with no arguments.npm run typecheck— clean.npm run build— clean.