Skip to content

fix: accept omitted arguments for zero-arg web_search_help prompt - #362

Open
serhiizghama wants to merge 3 commits into
exa-labs:mainfrom
serhiizghama:fix/zero-arg-prompt-rejects-omitted-arguments
Open

fix: accept omitted arguments for zero-arg web_search_help prompt#362
serhiizghama wants to merge 3 commits into
exa-labs:mainfrom
serhiizghama:fix/zero-arg-prompt-rejects-omitted-arguments

Conversation

@serhiizghama

Copy link
Copy Markdown

Problem

The web_search_help prompt declares no arguments, but prompts/get fails when a client omits params.arguments:

MCP error -32602: Invalid arguments for prompt web_search_help:
Invalid input: expected object, received undefined

Root cause is in src/mcp-handler.ts, where the prompt is registered with an empty args schema:

server.prompt(
  "web_search_help",
  "Get help with web search using Exa",
  {},            // ← empty args schema
  async () => { ... }
);

Passing {} selects the SDK's prompt(name, description, argsSchema, cb) overload. The SDK then builds z.object({}) and, in the prompts/get handler, runs argsSchema.parse(request.params.arguments). When arguments is omitted, that becomes z.object({}).parse(undefined) → "expected object, received undefined".

This breaks spec-compliant clients that drop empty maps. For example the official Go SDK:

type GetPromptParams struct {
  Arguments map[string]string `json:"arguments,omitempty"`
  Name      string            `json:"name"`
}

A nil/empty map is omitted under omitempty, so a zero-argument prompt request is serialized without arguments and is rejected. Per the MCP spec params.arguments is 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), and prompts/get succeeds whether arguments is 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 that web_search_help is registered without an args schema and that its handler resolves with no arguments.
  • npm run typecheck — clean.
  • npm run build — clean.

@vercel

vercel Bot commented Jun 16, 2026

Copy link
Copy Markdown

@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
@serhiizghama

Copy link
Copy Markdown
Author

Rebased on main — only a comment conflict where the note landed next to the prompt registration. The fix (dropping the empty {} args schema so omitted arguments are accepted) and its tests are unchanged. 5/5 green.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

prompts/get rejects omitted optional arguments for zero-argument prompt web_search_help

1 participant