Commit graph typescript-sdk/src/server/streamableHttp.ts
Author SHA1 Message Date
Matt
67ba7adbb7
feat: fetch transport (#1209)
Co-authored-by: Felix Weinberger <3823880+felixweinberger@users.noreply.github.com>
2025-12-15 17:28:10 +00:00
Konstantin Konstantinov
a606fb1790
SPEC COMPLIANCE: Remove loose/passthrough types not allowed/defined by MCP spec + Task types (#1242) 2025-12-09 11:52:23 +00:00
Matt
fbf5fc9b02
Protocol date validation (#1247) 2025-12-08 17:46:34 +00:00
Felix Weinberger
2f76ac8856
fix: skip priming events and closeSSEStream for old protocol versions (#1233) 2025-12-04 15:19:14 +02:00
Wuma
7c9257cdf5
refactor: make Server class framework-agnostic by moving express to separate module (#1223) 2025-12-03 11:58:42 +00:00
Paul Carleton
09623e2aa5
Merge commit from fork
* Add secure default for DNS rebinding, use in examples

* Update README examples to use createMcpExpressApp, bump to 1.23.0

- Update all server examples to use createMcpExpressApp() for secure defaults
- Rewrite DNS Rebinding Protection section to document new middleware approach
- Bump version from 1.23.0-beta.0 to 1.23.0

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Add IPv6 support, allowedHosts option, and warning for unprotected servers

- Use native URL API to parse Host headers (handles IPv6 correctly)
- Add [::1] (IPv6 localhost) to localhostHostValidation
- Add ::1 to list of localhost hosts that get automatic protection
- Add allowedHosts option to createMcpExpressApp for custom host validation
- Warn when binding to 0.0.0.0 or :: without allowedHosts configured
- Add tests for IPv6 and allowedHosts functionality

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Update remaining examples to use createMcpExpressApp and add DNS rebinding docs

- Update simpleTaskInteractive.ts, ssePollingExample.ts, and elicitationUrlExample.ts
  to use createMcpExpressApp() instead of express() + express.json()
- Add DNS rebinding protection section to docs/server.md explaining how to use
  createMcpExpressApp() and hostHeaderValidation middleware

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-02 13:23:06 +00:00
Jacopo Cappellato
608360047d
Modify Origin header validation in validateRequestHeaders (streamableHttp.ts and sse.ts) to allow requests without an Origin, as they are not relevant to server DNS rebinding protection. (#1205) 2025-12-02 09:56:09 +00:00
Felix Weinberger
4b651b8fe1
feat: add closeStandaloneSSEStream for GET stream polling (#1203) 2025-12-01 17:01:20 +00:00
Felix Weinberger
fab7e1e9b3
feat: add closeSSEStream callback to RequestHandlerExtra (#1166) 2025-12-01 16:18:29 +00:00
Felix Weinberger
3c50d07e9f
feat: implement SEP-1699 SSE polling via server-side disconnect (#1129) 2025-11-25 17:19:40 +00:00
Inna Harper
1150b1d843
run prettier (#995) 2025-10-02 18:21:00 +01:00
Jakub Kopecký
24b3972931
fix: prevent streamable http wite after end from crashing the node process (#933) 2025-09-17 10:51:37 +01:00
Jerome
0ddf6827b6
feat: support async callbacks for onsessioninitialized and onsessionclosed
Updated StreamableHTTPServerTransport to support both sync and async callbacks:
- Changed callback types to return void | Promise<void>
- Used await Promise.resolve() to handle both sync and async callbacks
- Added comprehensive tests for async callback functionality
- Errors in callbacks now properly propagate to HTTP responses

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-09 14:48:40 +01:00
Jerome
52e22ad7cb
Refactor ondelete hook to onsessionclosed in StreamableHTTPServerTransport
- Renamed ondelete callback to onsessionclosed for better clarity
- Moved callback from public property to private field following options pattern
- Added comprehensive JSDoc documentation explaining the callback's purpose
- Updated DELETE request handler to use the new callback structure

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-07 14:57:41 +01:00
Jerome
afb8971569
Add ondelete hook to StreamableHTTPServerTransport
Adds optional ondelete callback that fires when DELETE request is received, providing the sessionId for cleanup handling.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-07 14:44:35 +01:00
David Dworken
185fb23f34
Merge branch 'main' into main 2025-06-26 16:10:00 -07:00
Konstantin Konstantinov
606c278668
clean up tests - remove mockRequestInfo 2025-06-25 16:24:30 +03:00
Konstantin Konstantinov
166da76b00
extra parameter - remain optional for backwards compatibility 2025-06-24 19:39:37 +03:00
David Dworken
188c1d3680
Merge branch 'main' into main 2025-06-16 14:08:53 -07:00
Konstantin Konstantinov
e714050642
Merge branch 'main' into request-propagation-in-tools 2025-06-14 01:10:58 +03:00
Konstantin Konstantinov
db9ba7b419
raw request propagation in tools - implementation, unit tests, types 2025-06-14 01:08:02 +03:00
Olivier Chafik
33257f14d4
switch to optional Transport.setProtocolVersion 2025-06-13 13:36:04 +01:00
Olivier Chafik
4aaa26d900
remove protocol version mismatch warning 2025-06-13 13:35:38 +01:00
Olivier Chafik
bb0592bd50
add supported versions to error message 2025-06-12 18:42:51 +01:00
Olivier Chafik
84971c83ea
Set Mcp-Protocol-Version in client requests after init, and warn when it doesn't match negotiated version (it SHOULD match) 2025-06-11 17:29:09 +01:00
David Dworken
ab900839fb
Invert variable to improve code readability 2025-05-30 09:06:01 -07:00
David Dworken
ebf2535b90
Add protections for streamable HTTP too 2025-05-29 13:52:30 -07:00
ihrpr
bac916e804
Merge pull request #399 from its-nikhil/FEAT-auth-ctx-streamable-http
[FEAT] added support for AuthInfo in extra for StreamableHTTPServerTransport
2025-05-14 14:30:28 +01:00
ihrpr
7e18c70169
Merge pull request #403 from botengyao/fix-comments-stateless
comment: fix stateless comments that no session-id is included in any responses
2025-04-28 18:39:31 +01:00
ihrpr
dbd439ec57
Merge pull request #406 from botengyao/format-issue
nit: fix the comment format in the streamableHTTP.ts
2025-04-28 18:31:14 +01:00
Michael Hart
67ad0bd773
Ensure JSONRPCError messages are sent for streamable http
Prior to this, any JSONRPCError message sent when `enableJsonResponse` is true would be ignored (and response.end() never called)
2025-04-25 22:18:18 +10:00
Boteng Yao
868fc7b432 fix format 2025-04-25 03:43:05 +00:00
Boteng Yao
414cb11898 fix stateless comments 2025-04-25 01:42:36 +00:00
Nikhil Taneja
4b5c16fae0 [FEAT] added unit test for StreamableHTTPServerTransport with AuthInfo 2025-04-24 23:26:21 +05:30
Nikhil Taneja
37ca02d36d [FEAT] added support for AuthInfo in extra for StreamableHTTPServerTransport 2025-04-24 19:22:55 +05:30
ihrpr
3f95b76dcf
Merge pull request #338 from TomasRup/fix-example-in-stateless
stateless had a wrong example
2025-04-23 22:30:36 +01:00
Tomas Petras Rupšys
d61e59defe
Update src/server/streamableHttp.ts
Co-authored-by: ihrpr <inna.hrpr@gmail.com>
2025-04-22 14:20:08 +03:00
ihrpr
37fc7d2ca8
fix check to skip session validation for stateless mode 2025-04-21 14:56:12 +01:00
Cliff Hall
88f962d463
Merge branch 'main' into patch-1 2025-04-18 15:13:12 -04:00
ihrpr
0bf8b376df
examples for stateless servers 2025-04-18 11:46:17 +01:00
qikaigao
1df348710b
Update streamableHttp.ts 2025-04-17 15:38:12 -07:00
qikaigao
0058c30032
Update src/server/streamableHttp.ts
Co-authored-by: Cliff Hall <cliff@futurescale.com>
2025-04-17 11:08:34 -07:00
Cliff Hall
d88308bbfe
Merge branch 'main' into patch-1 2025-04-17 13:48:12 -04:00
ihrpr
64653f54bd
Merge pull request #351 from modelcontextprotocol/ihrpr/clean-up-examples
StreamableHttp - Update examples and README
2025-04-17 18:32:20 +01:00
ihrpr
f10d1ff93f
change sessionIdGenerator to be either undefined or generate a string 2025-04-17 18:22:11 +01:00
Cliff Hall
3048a6ffcf
Merge branch 'main' into patch-1 2025-04-17 13:18:42 -04:00
ihrpr
5dba9477ff
small fixes after suggested changes 2025-04-17 17:34:15 +01:00
ihrpr
a5144dc022
use utility to check for message types 2025-04-16 11:34:21 +01:00
ihrpr
585dc06708
introduce onsessioninitialized to avoid race conditions 2025-04-16 11:09:47 +01:00
ihrpr
84c2618c1e
Merge branch 'resumability' into ihrpr/resume-long-running-requests 2025-04-15 16:42:24 +01:00