Skip to content

Conversation

@kxbnb
Copy link

@kxbnb kxbnb commented Jan 25, 2026

Summary

Per the MCP spec, invalid session IDs should return 404 Not Found (to signal the client should start a new session), while missing session IDs should return 400 Bad Request.

Previous code returned 400 for both cases. This fix differentiates:

  • POST without session ID + not init request → 400
  • POST/GET/DELETE with unknown session ID → 404

Updated examples

  • jsonResponseStreamableHttp.ts
  • simpleStreamableHttp.ts
  • standaloneSseWithGetStreamableHttp.ts
  • elicitationFormExample.ts
  • elicitationUrlExample.ts
  • simpleTaskInteractive.ts

Test plan

  • All examples updated consistently
  • TypeScript typecheck passes (pnpm typecheck:all)

Fixes #389

🤖 Generated with Claude Code

Per spec:
- Missing session ID (when required) → 400 Bad Request
- Invalid/unknown session ID → 404 Not Found

Previous code returned 400 for both cases. This fix differentiates:
- POST without session ID + not init request → 400
- POST/GET/DELETE with unknown session ID → 404

Updated examples:
- jsonResponseStreamableHttp.ts
- simpleStreamableHttp.ts
- standaloneSseWithGetStreamableHttp.ts
- elicitationFormExample.ts
- elicitationUrlExample.ts
- simpleTaskInteractive.ts

Fixes modelcontextprotocol#389

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@kxbnb kxbnb requested a review from a team as a code owner January 25, 2026 13:33
@changeset-bot
Copy link

changeset-bot bot commented Jan 25, 2026

⚠️ No Changeset found

Latest commit: 5281701

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.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

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
Copy link

pkg-pr-new bot commented Jan 25, 2026

Open in StackBlitz

@modelcontextprotocol/client

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/client@1424

@modelcontextprotocol/server

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/server@1424

@modelcontextprotocol/express

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/express@1424

@modelcontextprotocol/hono

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/hono@1424

@modelcontextprotocol/node

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/node@1424

commit: 5281701

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.

Streamable HTTP examples use incorrect status code for invalid session IDs

1 participant