Skip to content

[v1.x] test(e2e): cover tools/call and prompts/get without arguments - #2931

Merged
felixweinberger merged 3 commits into
v1.xfrom
test/e2e-omitted-arguments-v1x
Oct 2, 2026
Merged

felixweinberger merged 3 commits into
v1.xfrom
test/e2e-omitted-arguments-v1x

Conversation

@claude

@claude claude Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Requested by Felix Weinberger · Slack thread

Motivation and Context

Refs #1869

Before: the v1.x e2e manifest covered only a schema-less prompt fetched without arguments (prompts:get:no-args) and an empty-object arguments: {} for a prompt with a required argument (prompts:get:missing-required-args) and for a typed tool (mcpserver:tool:input-validation). #2045 made a request that omits the arguments field entirely count as {} for both tools/call and prompts/get, but nothing in the e2e suite exercised that wire shape, so a regression would not have been caught here.

After: four new requirement ids, each run on every transport and entry arm the v1.x suite covers (inMemory, stdio, streamableHttp, streamableHttpStateless, sse), with the request verified on the wire to carry no arguments key:

  • tools:call:omitted-args:all-optional — a tool whose inputs are all optional, called via callTool({ name }), runs and its handler receives {}.
  • tools:call:omitted-args:required — a tool with a required argument, called with no arguments, is refused as an input validation error (isError: true result whose text names the argument) and the handler does not run.
  • prompts:get:omitted-args:all-optional — a prompt whose argsSchema is all optional, fetched via getPrompt({ name }), returns its messages and its handler receives {}.
  • prompts:get:omitted-args:required — a prompt with a required argument, fetched with no arguments, rejects with -32602 and a message naming the argument.

Existing ids are untouched. This is the v1.x port of #2928 (main), extended to tools.

With #2045's ?? {} reverted the all-optional tool case fails with an isError result Input validation error: Invalid arguments for tool list-files: Invalid input: expected object, received undefined; with it, it passes.
With #2045's ?? {} reverted the all-optional prompt case fails with MCP error -32602: Invalid arguments for prompt code-review: Invalid input: expected object, received undefined; with it, it passes.
(The two required-argument cases also fail under the revert, because the message then says expected object, received undefined instead of naming the missing argument.)

How Has This Been Tested

  • npx vitest run test/e2e/scenarios/tools.test.ts test/e2e/scenarios/prompts.test.ts -t omitted-args: 20/20 cells pass (4 ids x 5 transports).
  • npm run test:e2e (what the test-e2e CI job runs, including the coverage.test.ts manifest gates): 25 files, 1135 tests, all passing.
  • Revert proof as described above: temporarily removed ?? {} in src/server/mcp.ts for tools and prompts, all 20 cells fail; restored, all 20 pass; git status shows only test/e2e files changed.
  • npm run check (tsgo typecheck, eslint, prettier --check .): clean.

Breaking Changes

None, test-only.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Other: tests only

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed
  • I have added a changeset (not needed: tests only, v1.x)

🤖 Generated with Claude Code

https://claude.ai/code/session_012VRbFCp41otcScXE1YY3es


Generated by Claude Code

Add four requirement ids exercising a tools/call or prompts/get request
that omits the `arguments` field entirely (not `arguments: {}`): an
all-optional tool and prompt run with the handler receiving `{}`, and a
tool/prompt with a required argument is refused with a message naming it.
Tests only; locks in the behavior #2045 introduced on v1.x.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_012VRbFCp41otcScXE1YY3es
@claude
claude Bot requested a review from a team as a code owner October 2, 2026 16:28
@changeset-bot

changeset-bot Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: c965f6e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@modelcontextprotocol/sdk@2931

commit: c965f6e

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing blocking. The comments below are optional suggestions. There is no need to push a fix for them before merging.

One optional note from this repository's REVIEW.md or CLAUDE.md checks was not posted as a comment, over this review's limit for such notes; it is on this commit's check card.

Comment thread test/e2e/scenarios/tools.test.ts Outdated
Comment thread test/e2e/requirements.ts Outdated
Comment thread test/e2e/scenarios/tools.test.ts
…error

Also narrow the captured request with isJSONRPCRequest instead of a cast.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_012VRbFCp41otcScXE1YY3es

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I re-reviewed the follow-up commit and didn't find any bugs; the isJSONRPCRequest narrowing now replaces the cast at both capture sites. Because this adds four spec-sourced entries to the conformance manifest, a maintainer look at the wording is still worthwhile.

What was reviewed:

  • Traced both required-arg assertions against src/server/mcp.ts: tools go through the blanket catch into createToolError (so isError: true with "Input validation error ... at query"), prompts throw McpError(InvalidParams, "... at text") — both regexes and stringContaining checks are satisfiable by the single text element.
  • Confirmed tapWire is called after wire() (it throws if the client has no transport) and that received/handlerCalls live outside the factory for stateless hosting.
  • Confirmed isJSONRPCRequest is exported from src/types.ts and each new requirement id has a matching verifies() call; I was not able to execute vitest in this environment, so the pass claims in the description are unverified here.
Extended reasoning...

The PR is test-only: four new entries in test/e2e/requirements.ts plus matching verifies() tests in test/e2e/scenarios/tools.test.ts and prompts.test.ts covering tools/call and prompts/get with the arguments field omitted. It touches no security-sensitive surface. The second commit addressed the earlier type-cast nit in code, but the open thread on whether 'tools:call:omitted-args:required' should be spec-sourced with knownFailures or moved to an sdk-sourced id is a manifest-classification judgment for maintainers, and all changed paths fall under the wildcard CODEOWNERS entry. I could not run the test suite in this sandbox, so correctness was verified by reading McpServer's validation and error-wrapping paths rather than by execution.

@felixweinberger
felixweinberger merged commit 588d51d into v1.x Oct 2, 2026
12 checks passed
@felixweinberger
felixweinberger deleted the test/e2e-omitted-arguments-v1x branch October 2, 2026 16:53
@claude claude Bot mentioned this pull request Oct 2, 2026
@claude claude Bot added the v1 Issues / PRs related to v1.x label Oct 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v1 Issues / PRs related to v1.x

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants