Skip to content

Commit 24e96ed

Browse files
committed
rename to webstandards
1 parent 3014283 commit 24e96ed

File tree

2 files changed

+33
-33
lines changed

2 files changed

+33
-33
lines changed

src/server/streamableHttp.ts

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/**
22
* Node.js HTTP Streamable HTTP Server Transport
33
*
4-
* This is a thin wrapper around `FetchStreamableHTTPServerTransport` that provides
4+
* This is a thin wrapper around `WebStandardStreamableHTTPServerTransport` that provides
55
* compatibility with Node.js HTTP server (IncomingMessage/ServerResponse).
66
*
7-
* For web-standard environments (Cloudflare Workers, Deno, Bun), use `FetchStreamableHTTPServerTransport` directly.
7+
* For web-standard environments (Cloudflare Workers, Deno, Bun), use `WebStandardStreamableHTTPServerTransport` directly.
88
*/
99

1010
import { IncomingMessage, ServerResponse } from 'node:http';
@@ -13,28 +13,28 @@ import { Transport } from '../shared/transport.js';
1313
import { AuthInfo } from './auth/types.js';
1414
import { MessageExtraInfo, JSONRPCMessage, RequestId } from '../types.js';
1515
import {
16-
FetchStreamableHTTPServerTransport,
17-
FetchStreamableHTTPServerTransportOptions,
16+
WebStandardStreamableHTTPServerTransport,
17+
WebStandardStreamableHTTPServerTransportOptions,
1818
EventStore,
1919
StreamId,
2020
EventId
21-
} from './fetchStreamableHttp.js';
21+
} from './webStandardStreamableHttp.js';
2222

2323
// Re-export types from the core transport for backward compatibility
2424
export type { EventStore, StreamId, EventId };
2525

2626
/**
2727
* Configuration options for StreamableHTTPServerTransport
2828
*
29-
* This is an alias for FetchStreamableHTTPServerTransportOptions for backward compatibility.
29+
* This is an alias for WebStandardStreamableHTTPServerTransportOptions for backward compatibility.
3030
*/
31-
export type StreamableHTTPServerTransportOptions = FetchStreamableHTTPServerTransportOptions;
31+
export type StreamableHTTPServerTransportOptions = WebStandardStreamableHTTPServerTransportOptions;
3232

3333
/**
3434
* Server transport for Streamable HTTP: this implements the MCP Streamable HTTP transport specification.
3535
* It supports both SSE streaming and direct HTTP responses.
3636
*
37-
* This is a wrapper around `FetchStreamableHTTPServerTransport` that provides Node.js HTTP compatibility.
37+
* This is a wrapper around `WebStandardStreamableHTTPServerTransport` that provides Node.js HTTP compatibility.
3838
* It uses the `@hono/node-server` library to convert between Node.js HTTP and Web Standard APIs.
3939
*
4040
* Usage example:
@@ -68,20 +68,20 @@ export type StreamableHTTPServerTransportOptions = FetchStreamableHTTPServerTran
6868
* - No session validation is performed
6969
*/
7070
export class StreamableHTTPServerTransport implements Transport {
71-
private _fetchTransport: FetchStreamableHTTPServerTransport;
71+
private _webStandardTransport: WebStandardStreamableHTTPServerTransport;
7272
private _requestListener: ReturnType<typeof getRequestListener>;
7373
// Store auth and parsedBody per request for passing through to handleRequest
7474
private _requestContext: WeakMap<Request, { authInfo?: AuthInfo; parsedBody?: unknown }> = new WeakMap();
7575

7676
constructor(options: StreamableHTTPServerTransportOptions) {
77-
this._fetchTransport = new FetchStreamableHTTPServerTransport(options);
77+
this._webStandardTransport = new WebStandardStreamableHTTPServerTransport(options);
7878

79-
// Create a request listener that wraps the fetch transport
79+
// Create a request listener that wraps the web standard transport
8080
// getRequestListener converts Node.js HTTP to Web Standard and properly handles SSE streaming
8181
this._requestListener = getRequestListener(async (webRequest: Request) => {
8282
// Get context if available (set during handleRequest)
8383
const context = this._requestContext.get(webRequest);
84-
return this._fetchTransport.handleRequest(webRequest, {
84+
return this._webStandardTransport.handleRequest(webRequest, {
8585
authInfo: context?.authInfo,
8686
parsedBody: context?.parsedBody
8787
});
@@ -92,69 +92,69 @@ export class StreamableHTTPServerTransport implements Transport {
9292
* Gets the session ID for this transport instance.
9393
*/
9494
get sessionId(): string | undefined {
95-
return this._fetchTransport.sessionId;
95+
return this._webStandardTransport.sessionId;
9696
}
9797

9898
/**
9999
* Sets callback for when the transport is closed.
100100
*/
101101
set onclose(handler: (() => void) | undefined) {
102-
this._fetchTransport.onclose = handler;
102+
this._webStandardTransport.onclose = handler;
103103
}
104104

105105
get onclose(): (() => void) | undefined {
106-
return this._fetchTransport.onclose;
106+
return this._webStandardTransport.onclose;
107107
}
108108

109109
/**
110110
* Sets callback for transport errors.
111111
*/
112112
set onerror(handler: ((error: Error) => void) | undefined) {
113-
this._fetchTransport.onerror = handler;
113+
this._webStandardTransport.onerror = handler;
114114
}
115115

116116
get onerror(): ((error: Error) => void) | undefined {
117-
return this._fetchTransport.onerror;
117+
return this._webStandardTransport.onerror;
118118
}
119119

120120
/**
121121
* Sets callback for incoming messages.
122122
*/
123123
set onmessage(handler: ((message: JSONRPCMessage, extra?: MessageExtraInfo) => void) | undefined) {
124-
this._fetchTransport.onmessage = handler;
124+
this._webStandardTransport.onmessage = handler;
125125
}
126126

127127
get onmessage(): ((message: JSONRPCMessage, extra?: MessageExtraInfo) => void) | undefined {
128-
return this._fetchTransport.onmessage;
128+
return this._webStandardTransport.onmessage;
129129
}
130130

131131
/**
132132
* Starts the transport. This is required by the Transport interface but is a no-op
133133
* for the Streamable HTTP transport as connections are managed per-request.
134134
*/
135135
async start(): Promise<void> {
136-
return this._fetchTransport.start();
136+
return this._webStandardTransport.start();
137137
}
138138

139139
/**
140140
* Closes the transport and all active connections.
141141
*/
142142
async close(): Promise<void> {
143-
return this._fetchTransport.close();
143+
return this._webStandardTransport.close();
144144
}
145145

146146
/**
147147
* Sends a JSON-RPC message through the transport.
148148
*/
149149
async send(message: JSONRPCMessage, options?: { relatedRequestId?: RequestId }): Promise<void> {
150-
return this._fetchTransport.send(message, options);
150+
return this._webStandardTransport.send(message, options);
151151
}
152152

153153
/**
154154
* Handles an incoming HTTP request, whether GET or POST.
155155
*
156156
* This method converts Node.js HTTP objects to Web Standard Request/Response
157-
* and delegates to the underlying FetchStreamableHTTPServerTransport.
157+
* and delegates to the underlying WebStandardStreamableHTTPServerTransport.
158158
*
159159
* @param req - Node.js IncomingMessage, optionally with auth property from middleware
160160
* @param res - Node.js ServerResponse
@@ -167,7 +167,7 @@ export class StreamableHTTPServerTransport implements Transport {
167167

168168
// Create a custom handler that includes our context
169169
const handler = getRequestListener(async (webRequest: Request) => {
170-
return this._fetchTransport.handleRequest(webRequest, {
170+
return this._webStandardTransport.handleRequest(webRequest, {
171171
authInfo,
172172
parsedBody
173173
});
@@ -184,14 +184,14 @@ export class StreamableHTTPServerTransport implements Transport {
184184
* client will reconnect after the retry interval specified in the priming event.
185185
*/
186186
closeSSEStream(requestId: RequestId): void {
187-
this._fetchTransport.closeSSEStream(requestId);
187+
this._webStandardTransport.closeSSEStream(requestId);
188188
}
189189

190190
/**
191191
* Close the standalone GET SSE stream, triggering client reconnection.
192192
* Use this to implement polling behavior for server-initiated notifications.
193193
*/
194194
closeStandaloneSSEStream(): void {
195-
this._fetchTransport.closeStandaloneSSEStream();
195+
this._webStandardTransport.closeStandaloneSSEStream();
196196
}
197197
}
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ interface StreamMapping {
7373
}
7474

7575
/**
76-
* Configuration options for FetchStreamableHTTPServerTransport
76+
* Configuration options for WebStandardStreamableHTTPServerTransport
7777
*/
78-
export interface FetchStreamableHTTPServerTransportOptions {
78+
export interface WebStandardStreamableHTTPServerTransportOptions {
7979
/**
8080
* Function that generates a session ID for the transport.
8181
* The session ID SHOULD be globally unique and cryptographically secure (e.g., a securely generated UUID, a JWT, or a cryptographic hash)
@@ -99,7 +99,7 @@ export interface FetchStreamableHTTPServerTransportOptions {
9999
* Useful in cases when you need to clean up resources associated with the session.
100100
* Note that this is different from the transport closing, if you are handling
101101
* HTTP requests from multiple nodes you might want to close each
102-
* FetchStreamableHTTPServerTransport after a request is completed while still keeping the
102+
* WebStandardStreamableHTTPServerTransport after a request is completed while still keeping the
103103
* session open/running.
104104
* @param sessionId The session ID that was closed
105105
*/
@@ -173,12 +173,12 @@ export interface HandleRequestOptions {
173173
*
174174
* ```typescript
175175
* // Stateful mode - server sets the session ID
176-
* const statefulTransport = new FetchStreamableHTTPServerTransport({
176+
* const statefulTransport = new WebStandardStreamableHTTPServerTransport({
177177
* sessionIdGenerator: () => crypto.randomUUID(),
178178
* });
179179
*
180180
* // Stateless mode - explicitly set session ID to undefined
181-
* const statelessTransport = new FetchStreamableHTTPServerTransport({
181+
* const statelessTransport = new WebStandardStreamableHTTPServerTransport({
182182
* sessionIdGenerator: undefined,
183183
* });
184184
*
@@ -206,7 +206,7 @@ export interface HandleRequestOptions {
206206
* - No Session ID is included in any responses
207207
* - No session validation is performed
208208
*/
209-
export class FetchStreamableHTTPServerTransport implements Transport {
209+
export class WebStandardStreamableHTTPServerTransport implements Transport {
210210
// when sessionId is not set (undefined), it means the transport is in stateless mode
211211
private sessionIdGenerator: (() => string) | undefined;
212212
private _started: boolean = false;
@@ -229,7 +229,7 @@ export class FetchStreamableHTTPServerTransport implements Transport {
229229
onerror?: (error: Error) => void;
230230
onmessage?: (message: JSONRPCMessage, extra?: MessageExtraInfo) => void;
231231

232-
constructor(options: FetchStreamableHTTPServerTransportOptions) {
232+
constructor(options: WebStandardStreamableHTTPServerTransportOptions) {
233233
this.sessionIdGenerator = options.sessionIdGenerator;
234234
this._enableJsonResponse = options.enableJsonResponse ?? false;
235235
this._eventStore = options.eventStore;

0 commit comments

Comments
 (0)