mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 17:46:45 +00:00
Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in> Co-authored-by: JP van Oosten <jp@n8n.io>
27 lines
772 B
TypeScript
27 lines
772 B
TypeScript
import { SSEServerTransport } from '@modelcontextprotocol/sdk/server/sse.js';
|
|
import type { JSONRPCMessage } from '@modelcontextprotocol/sdk/types.js';
|
|
import type { Response } from 'express';
|
|
|
|
export type CompressionResponse = Response & {
|
|
/**
|
|
* `flush()` is defined in the compression middleware.
|
|
* This is necessary because the compression middleware sometimes waits
|
|
* for a certain amount of data before sending the data to the client
|
|
*/
|
|
flush: () => void;
|
|
};
|
|
|
|
export class FlushingSSEServerTransport extends SSEServerTransport {
|
|
constructor(
|
|
_endpoint: string,
|
|
private response: CompressionResponse,
|
|
) {
|
|
super(_endpoint, response);
|
|
}
|
|
|
|
async send(message: JSONRPCMessage): Promise<void> {
|
|
await super.send(message);
|
|
this.response.flush();
|
|
}
|
|
}
|