Skip to content

fix(mcp): accept case-variant SSE media types - #7748

Closed
cjagwani wants to merge 2 commits into
mainfrom
codex/fix-mcp-sse-tool-discovery
Closed

fix(mcp): accept case-variant SSE media types#7748
cjagwani wants to merge 2 commits into
mainfrom
codex/fix-mcp-sse-tool-discovery

Conversation

@cjagwani

@cjagwani cjagwani commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fix managed MCP tool discovery when a compliant Streamable HTTP server returns an SSE response media type with case variation or parameters. Upgrade the official MCP SDK to its parsed media-type implementation and make the regression session part of every reviewed runtime image build.

Related Issue

Fixes #7726

Changes

  • Pin @modelcontextprotocol/sdk to 1.30.0, refresh the exact lock, and record the adjacent-release, provenance, vulnerability, bundle, and license review.
  • Add a real initializenotifications/initializedtools/list → session cleanup fixture using Text/Event-Stream; Charset=UTF-8.
  • Stage and run that fixture in the shared reviewed runtime installer used by all agent image builds.

This restores the generic Streamable HTTP/SSE contract accepted in #6901 and implemented in #7591. It does not add a provider-specific integration or compatibility layer.

Type of Change

  • Code change (feature, bug fix, or refactor)
  • Code change with doc updates
  • Doc only (prose changes, no code sample modifications)
  • Doc only (includes code sample changes)

Quality Gates

  • Tests added or updated for changed behavior
  • Existing tests cover changed behavior — justification:
  • Tests not applicable — justification:
  • Docs updated for user-facing behavior changes
  • Docs not applicable — justification: this restores the existing documented Streamable HTTP discovery lifecycle without changing commands, flags, configuration, schemas, or supported integrations.
  • Sensitive paths changed (security, policy, credentials, preflight, onboarding, inference, runner, sandbox, or messaging)
  • Sensitive-path review completed or maintainer-approved waiver recorded — reviewer/approval link/justification: Codex security review passed all nine repository categories; the credential placeholder, authorization, SSRF, policy, and final-image boundaries are unchanged, and the exact dependency pin is signature-, attestation-, license-, and audit-verified.
  • Non-success, skipped, or missing CI check accepted by maintainer — check name, approval link, and follow-up issue:

Documentation Writer Review

  • Documentation writer subagent reviewed the completed changes
  • Result: no-docs-needed
  • Evidence: Existing docs already specify the standard Streamable HTTP discovery lifecycle. The fix restores that contract for a valid response media-type form and adds no user-facing surface. No docs/ or fern/ files changed.
  • Agent: Codex Desktop

DGX Station Hardware Evidence

  • Tested on DGX Station
  • Tested commit:
  • Station profile/scenario:
  • Result:
  • Supporting evidence:

Verification

  • PR description includes a Signed-off-by: line and every commit appears as Verified in GitHub
  • Normal pre-commit, commit-msg, and pre-push hooks passed, or npm run check:diff passed when hooks were skipped or unavailable
  • Targeted behavior tests pass for the current change set, or tests are marked not applicable above — npm --prefix tools/mcp-tool-discovery-runtime test; runtime typecheck/bundle/audit; 12 CLI runtime unit tests; 15 build-context and image-contract integration tests.
  • Applicable broad gate passed — npm test for broad runtime/test-harness changes; npm run check for repo-wide validation/coverage changes — command/result:
  • Quality Gates section completed with required justifications or waivers
  • No secrets, API keys, or credentials committed
  • npm run docs builds without warnings (doc changes only)
  • Doc pages follow the style guide (doc changes only)
  • New doc pages include SPDX header and frontmatter (new pages only)

Signed-off-by: Charan Jagwani cjagwani@nvidia.com

Signed-off-by: Charan Jagwani <cjagwani@nvidia.com>
@cjagwani cjagwani added area: cli Command line interface, flags, terminal UX, or output area: integrations Third-party service integration behavior bug-fix PR fixes a bug or regression labels Jul 28, 2026
@cjagwani cjagwani self-assigned this Jul 28, 2026
@cjagwani cjagwani added area: cli Command line interface, flags, terminal UX, or output area: integrations Third-party service integration behavior bug-fix PR fixes a bug or regression labels Jul 28, 2026
@github-code-quality

github-code-quality Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Code Coverage Overview

Languages: TypeScript

TypeScript / code-coverage/plugin

The overall coverage in commit f41ab0d in the codex/fix-mcp-sse-to... branch remains at 96%, unchanged from commit 7f4b490 in the main branch.


Updated July 28, 2026 18:45 UTC

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Updates the MCP SDK, adds case-variant SSE discovery coverage, refreshes runtime bundle verification, and stages the new test file in the sandbox build context with matching fixture expectations.

Changes

MCP SDK update and validation

Layer / File(s) Summary
SDK upgrade and SSE client coverage
tools/mcp-tool-discovery-runtime/package.json, tools/mcp-tool-discovery-runtime/streamable-http-client.test.ts
Pins SDK 1.30.0 and tests MCP discovery over Streamable HTTP, including SSE responses, headers, sessions, and protocol values.
Bundle and regeneration verification
tools/mcp-tool-discovery-runtime/build-runtime.ts, tools/mcp-tool-discovery-runtime/install-reviewed-runtime.sh, tools/mcp-tool-discovery-runtime/dependency-review.md
Adds content-type to the reviewed bundle, runs the new test during installation, and records updated SDK migration and verification details.
Sandbox staging integration
src/lib/sandbox/build-context.ts, test/sandbox-build-context.test.ts, tsconfig.cli.json
Stages streamable-http-client.test.ts, excludes it from the CLI TypeScript project, and verifies its presence in the build-context fixture.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: cv

Sequence Diagram(s)

sequenceDiagram
  participant Test as streamable-http-client.test.ts
  participant Discovery as runMcpToolDiscoverySession
  participant Transport as StreamableHTTPClientTransport
  participant Server as MCP HTTP server
  Test->>Discovery: Start discovery session
  Discovery->>Transport: Send MCP requests
  Transport->>Server: initialize, tools/list, notification, DELETE
  Server-->>Transport: Return SSE-formatted responses
  Transport-->>Discovery: Provide parsed discovery result
  Discovery-->>Test: Publish discovered tool
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The PR upgrades the MCP SDK and adds coverage for SSE media-type variants, matching the tool-discovery failure described in #7726.
Out of Scope Changes check ✅ Passed The added script, fixture staging, and dependency-review updates all support the MCP discovery fix and test flow.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: accepting case-variant SSE media types in MCP tool discovery.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-mcp-sse-tool-discovery

Comment @coderabbitai help to get the list of available commands.

Signed-off-by: Charan Jagwani <cjagwani@nvidia.com>
@github-actions

github-actions Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

PR Review Advisor — No blocking findings reported

Advisor assessment: No blocking advisor findings reported
Next action: No advisor follow-up needed.
Findings: 0 blockers · 0 warnings · 0 suggestions

Model lanes

  • GPT-5.6 Terra (primary): Completed · high confidence · 0 blockers · 0 warnings · 0 suggestions
  • Nemotron 3 Ultra (second opinion): Completed · high confidence · 1 blocker · 0 warnings · 0 suggestions
  • Model comparison: normalized findings differ; normalized E2E selections differ; Nemotron reported 1 more blocker, the same number of warnings, the same number of suggestions.

Nemotron output stays in workflow artifacts and does not change the assessment above.

E2E guidance

Advisory only. E2E / PR Gate selects and runs jobs independently.

Recommended E2E: None

1 optional E2E recommendation
  • mcp-bridge

Workflow run details

This automated review informs maintainers. Warnings and suggestions do not require a response. A maintainer decides whether to merge.

@cjagwani

Copy link
Copy Markdown
Collaborator Author

Superseded by #7760, which preserves this exact patch on current main with a fresh GitHub-verified branch because repository rules prohibit force-pushing this published branch.

@cjagwani cjagwani closed this Jul 28, 2026
apurvvkumaria pushed a commit that referenced this pull request Jul 28, 2026
<!-- markdownlint-disable MD041 -->
## Summary

Fix managed MCP tool discovery when a compliant Streamable HTTP server
returns an SSE response media type with case variation or parameters.
Upgrade the official MCP SDK to its parsed media-type implementation and
make the regression session part of every reviewed runtime image build.

This replaces #7748 with the same patch on current `main`; the published
branch could not be rebased because repository rules forbid
force-pushes.

## Related Issue

Fixes #7726

## Changes

- Pin `@modelcontextprotocol/sdk` to `1.30.0`, refresh the exact lock,
and record the adjacent-release, provenance, vulnerability, bundle, and
license review.
- Add a real `initialize` → `notifications/initialized` → `tools/list` →
session cleanup fixture using `Text/Event-Stream; Charset=UTF-8`.
- Stage and run that fixture in the shared reviewed runtime installer
used by all agent image builds.

This restores the generic Streamable HTTP/SSE contract accepted in #6901
and implemented in #7591. It does not add a provider-specific
integration or compatibility layer.

## Type of Change

- [x] Code change (feature, bug fix, or refactor)
- [ ] Code change with doc updates
- [ ] Doc only (prose changes, no code sample modifications)
- [ ] Doc only (includes code sample changes)

## Quality Gates

- [x] Tests added or updated for changed behavior
- [ ] Existing tests cover changed behavior — justification:
- [ ] Tests not applicable — justification:
- [ ] Docs updated for user-facing behavior changes
- [x] Docs not applicable — justification: This restores the existing
documented Streamable HTTP discovery lifecycle without changing
commands, flags, configuration, schemas, or supported integrations.
- [x] Sensitive paths changed (security, policy, credentials, preflight,
onboarding, inference, runner, sandbox, or messaging)
- [x] Sensitive-path review completed or maintainer-approved waiver
recorded — reviewer/approval link/justification: Codex security review
passed all nine repository categories; the credential placeholder,
authorization, SSRF, policy, and final-image boundaries are unchanged,
and the exact dependency pin is signature-, attestation-, license-, and
audit-verified.
- [ ] Non-success, skipped, or missing CI check accepted by maintainer —
check name, approval link, and follow-up issue:

## Documentation Writer Review

- [x] Documentation writer subagent reviewed the completed changes
- Result: `no-docs-needed`
- Evidence: Existing docs already describe Streamable HTTP discovery
generically. This restores standards-compliant handling of a valid
response media type and changes no command, flag, configuration,
workflow, supported protocol, or documented user contract. Changelog
work remains part of separate pre-tag release preparation.
- Agent: Codex Desktop `/root/replacement_docs_review`
<!-- docs-review-head-sha: 646d377 -->
<!-- docs-review-agents-blob-sha: be20a09 -->

## DGX Station Hardware Evidence

- [ ] Tested on DGX Station
- Tested commit:
- Station profile/scenario:
- Result:
- Supporting evidence:

## Verification

- [x] PR description includes a `Signed-off-by:` line and every commit
appears as `Verified` in GitHub
- [x] Normal `pre-commit`, `commit-msg`, and `pre-push` hooks passed, or
`npm run check:diff` passed when hooks were skipped or unavailable
- [x] Targeted behavior tests pass for the current change set, or tests
are marked not applicable above — reviewed-runtime session test (1
passed), CLI runtime tests (12 passed), build-context/image-contract
tests (15 passed), runtime and CLI typechecks, bundle allowlist/license
generation, zero-vulnerability production audit, 98 verified registry
signatures, and 11 verified attestations.
- [ ] Applicable broad gate passed — `npm test` for broad
runtime/test-harness changes; `npm run check` for repo-wide
validation/coverage changes — command/result:
- [x] Quality Gates section completed with required justifications or
waivers
- [x] No secrets, API keys, or credentials committed
- [ ] `npm run docs` builds without warnings (doc changes only)
- [ ] Doc pages follow the [style
guide](https://github.com/NVIDIA/NemoClaw/blob/main/docs/CONTRIBUTING.md)
(doc changes only)
- [ ] New doc pages include SPDX header and frontmatter (new pages only)

---
Signed-off-by: Charan Jagwani <cjagwani@nvidia.com>


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **New Features**
* Improved MCP tool discovery compatibility with case-variant SSE
response media types.
* Preserved session and protocol headers during tool discovery requests.

* **Bug Fixes**
* Updated the MCP runtime to ensure supported bundled content is
included correctly.

* **Tests**
* Added coverage for SSE discovery, authentication, session cleanup, and
request headers.
* Runtime installation now runs its test suite as part of verification.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Charan Jagwani <cjagwani@nvidia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: cli Command line interface, flags, terminal UX, or output area: integrations Third-party service integration behavior bug-fix PR fixes a bug or regression

Projects

None yet

Development

Successfully merging this pull request may close these issues.

nemoclaw mcp status --tools reports tool discovery failed when MCP endpoint returns SSE-format responses

1 participant