Skip to content

Test MCP version gates and continuation receive policies - #3037

Open
HarshPopat23 wants to merge 3 commits into
sourcemeta:mainfrom
HarshPopat23:test/mcp-conformance-version-properties
Open

HarshPopat23 wants to merge 3 commits into
sourcemeta:mainfrom
HarshPopat23:test/mcp-conformance-version-properties

Conversation

@HarshPopat23

@HarshPopat23 HarshPopat23 commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Add focused conformance tests for MCP metadata, parameter headers and continuations across the four supported protocol revisions.

This PR changes only test coverage and its CMake registration. Production validation behavior, public APIs and benchmarks remain unchanged.

Changes

Version-specific conformance matrix

Exercise explicit expectations across:

  • 2025-03-26
  • 2025-06-18
  • 2025-11-25
  • 2026-07-28

Verify request-metadata requirements, continuation availability and rejection of parameter-header validation under unsupported revisions.

Deterministic property tests

  • Round-trip all 95 printable ASCII bytes through parameter-header generation and validation.
  • Reject a changed argument value for every generated ASCII fixture.
  • Verify Unicode header values, including surrounding whitespace.
  • Check all 25 combinations of five continuation tokens, covering empty strings, casing, whitespace and Unicode.
  • Reject unsolicited continuation state tokens.

These tests use explicit expected outcomes rather than deriving expectations from the feature helpers under test.

Root-identifier receive policy

Separate rejection of non-file identifiers from characterization of the current prefix-based receive behavior.

The tests explicitly identify acceptance of file://bad space and file:// as current behavior—not evidence that these are valid URIs.

Maintainer guidance requested

The [2026-07-28 schema](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/main/schema/2026-07-28/schema.ts) requires root identifiers to start with file:// and annotates the field with @format uri.

Should continuation validation additionally enforce complete URI syntax, or retain the existing prefix-based receive policy?

No stricter URI checks are introduced pending agreement.

Verification

  • GCC 13.3, Linux, Release build passed.
  • Complete MCP suite: 1,429 passed, zero failed, including nine new tests.
  • Repository clang-format and clang-tidy checks passed.
  • Runnable acceptance checks were reverified.
  • Published source matches the locally verified files.

Scope and limitations

These are bounded, deterministic property tests—not exhaustive protocol certification or fuzz testing.

This PR does not implement resource authorization, filesystem containment, SSRF protection or continuation replay protection. It preserves the existing application boundaries.

No internal Markdown notes, additional dependencies or performance claims are included.

Add a version-specific conformance matrix and deterministic header and state-echo properties. Characterize existing root-prefix receive behavior without tightening URI policy.

Signed-off-by: HarshPopat23 <musichk61@gmail.com>
@augmentcode

augmentcode Bot commented Oct 28, 2026

Copy link
Copy Markdown
🤖 Augment PR Summary

Summary: Adds focused MCP conformance and receive-policy coverage.

  • Registers nine new tests in the existing MCP CMake target.
  • Covers all four supported protocol revisions.
  • Checks request-metadata version acceptance and rejection.
  • Verifies continuation support and legacy parameter-header rejection.
  • Round-trips all 95 printable ASCII bytes with changed-body negative controls.
  • Exercises Unicode header values, including surrounding whitespace.
  • Checks all 25 state-token combinations and rejects unsolicited state.
  • Separates non-file root rejection from current prefix-based acceptance.
Scope: Preserves production behavior and public APIs; stricter URI validation remains undecided.

🤖 Was this summary useful? React with 👍 or 👎

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review completed. No suggestions at this time.

Comment augment review to trigger a new review at any time.

Comment thread test/mcp/mcp_conformance_test.cc Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please use the existing test files to add tests where relevant. If you think about it, all tests we have are by definition "conformance" as that's the point!

Comment thread test/mcp/mcp_conformance_test.cc Outdated
}

TEST(conformance_continuation_rejects_unsolicited_state_property) {
for (const auto *const token : {"", "state", "STATE"}) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also try to avoid using loops in tests. This should really be 3 different tests. In general, a good unit test should be sequential and direct.

Move header and continuation coverage into the relevant suites. Replace loop-driven cases with self-contained sequential tests and remove the conformance fixture and CMake entry.

Signed-off-by: HarshPopat23 <musichk61@gmail.com>
@HarshPopat23
HarshPopat23 requested a review from jviotti October 28, 2026 14:39
Comment thread test/mcp/mcp_notifications_test.cc Outdated

TEST(validate_continuation_root_uppercase_scheme) {
const auto input{sourcemeta::core::parse_json(
R"JSON({"_meta": {"io.modelcontextprotocol/protocolVersion": "2026-07-28", "io.modelcontextprotocol/clientCapabilities": {}}, "requestState": "state", "inputResponses": {"r": {"roots": [{"uri": "FILE:///tmp"}]}}})JSON")};

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Much better! But can we prettify all JSON documents on all the new tests? Otherwise these big lines are very hard to read. There is no reason why they have to be a single stringified line?

Keep fixture values and assertions unchanged while making nested metadata and continuation documents readable.

Signed-off-by: HarshPopat23 <musichk61@gmail.com>
@HarshPopat23
HarshPopat23 requested a review from jviotti October 28, 2026 14:50

This branch has not been deployed

No deployments
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.

2 participants