@1mcp/agent 0.29.0-beta5 → 0.29.0-beta6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/constants/mcp.d.ts +1 -1
- package/build/constants/mcp.js +1 -1
- package/build/transport/http/restorableStreamableTransport.d.ts +56 -11
- package/build/transport/http/restorableStreamableTransport.d.ts.map +1 -1
- package/build/transport/http/restorableStreamableTransport.js +93 -21
- package/build/transport/http/restorableStreamableTransport.js.map +1 -1
- package/build/transport/http/routes/streamableHttpRoutes.d.ts +2 -1
- package/build/transport/http/routes/streamableHttpRoutes.d.ts.map +1 -1
- package/build/transport/http/routes/streamableHttpRoutes.js +77 -238
- package/build/transport/http/routes/streamableHttpRoutes.js.map +1 -1
- package/build/transport/http/utils/sdkInternals.d.ts +32 -0
- package/build/transport/http/utils/sdkInternals.d.ts.map +1 -0
- package/build/transport/http/utils/sdkInternals.js +6 -0
- package/build/transport/http/utils/sdkInternals.js.map +1 -0
- package/build/transport/http/utils/sessionService.d.ts +76 -0
- package/build/transport/http/utils/sessionService.d.ts.map +1 -0
- package/build/transport/http/utils/sessionService.js +232 -0
- package/build/transport/http/utils/sessionService.js.map +1 -0
- package/package.json +1 -1
package/build/constants/mcp.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { ClientCapabilities, ServerCapabilities } from '@modelcontextprotocol/sd
|
|
|
5
5
|
export declare const MCP_CONFIG_FILE = "mcp.json";
|
|
6
6
|
export declare const MCP_INSTRUCTIONS_TEMPLATE_FILE = "instructions-template.md";
|
|
7
7
|
export declare const MCP_SERVER_NAME = "1mcp";
|
|
8
|
-
export declare const MCP_SERVER_VERSION = "0.29.0-
|
|
8
|
+
export declare const MCP_SERVER_VERSION = "0.29.0-beta6";
|
|
9
9
|
export declare const MCP_URI_SEPARATOR = "_1mcp_";
|
|
10
10
|
/**
|
|
11
11
|
* Default maximum number of MCP servers to load concurrently
|
package/build/constants/mcp.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
export const MCP_CONFIG_FILE = 'mcp.json';
|
|
3
3
|
export const MCP_INSTRUCTIONS_TEMPLATE_FILE = 'instructions-template.md';
|
|
4
4
|
export const MCP_SERVER_NAME = '1mcp';
|
|
5
|
-
export const MCP_SERVER_VERSION = '0.29.0-
|
|
5
|
+
export const MCP_SERVER_VERSION = '0.29.0-beta6';
|
|
6
6
|
export const MCP_URI_SEPARATOR = '_1mcp_';
|
|
7
7
|
/**
|
|
8
8
|
* Default maximum number of MCP servers to load concurrently
|
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Metadata about a transport's restoration state, used for debugging
|
|
4
|
+
* and monitoring session restoration flow.
|
|
4
5
|
*/
|
|
5
6
|
export interface RestorationInfo {
|
|
6
7
|
isRestored: boolean;
|
|
7
8
|
sessionId?: string;
|
|
8
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* Result type for operations that may fail.
|
|
12
|
+
* Uses discriminated union to make invalid states unrepresentable.
|
|
13
|
+
*/
|
|
14
|
+
export type OperationResult = {
|
|
15
|
+
success: true;
|
|
16
|
+
error?: never;
|
|
17
|
+
} | {
|
|
18
|
+
success: false;
|
|
19
|
+
error: string;
|
|
20
|
+
};
|
|
9
21
|
/**
|
|
10
22
|
* RestorableStreamableHTTPServerTransport extends the MCP SDK's StreamableHTTPServerTransport
|
|
11
23
|
* to provide proper session restoration capabilities with type-safe access to internal properties.
|
|
@@ -13,22 +25,55 @@ export interface RestorationInfo {
|
|
|
13
25
|
* This wrapper class encapsulates the initialization logic needed for restored sessions,
|
|
14
26
|
* providing a clean interface that's less likely to break with SDK updates.
|
|
15
27
|
*
|
|
28
|
+
* @remarks
|
|
29
|
+
* The class works by:
|
|
30
|
+
* 1. Storing a restored sessionId that overrides the SDK's getter
|
|
31
|
+
* 2. Providing methods to safely access and modify internal SDK properties
|
|
32
|
+
* 3. Returning success/failure status from operations for proper error handling
|
|
33
|
+
*
|
|
16
34
|
* @example
|
|
17
35
|
* ```typescript
|
|
18
|
-
* //
|
|
36
|
+
* // SessionService handles the full restoration flow:
|
|
19
37
|
* const transport = new RestorableStreamableHTTPServerTransport({
|
|
20
|
-
* sessionIdGenerator: () =>
|
|
38
|
+
* sessionIdGenerator: () => originalSessionId,
|
|
21
39
|
* });
|
|
22
|
-
* transport.markAsInitialized();
|
|
23
|
-
*
|
|
24
|
-
* //
|
|
25
|
-
* if (transport.isRestored()) {
|
|
26
|
-
* // Handle restored session logic
|
|
27
|
-
* }
|
|
40
|
+
* const initResult = transport.markAsInitialized();
|
|
41
|
+
* transport.setSessionId(originalSessionId);
|
|
42
|
+
* // Now transport.isRestored() returns true
|
|
28
43
|
* ```
|
|
29
44
|
*/
|
|
30
45
|
export declare class RestorableStreamableHTTPServerTransport extends StreamableHTTPServerTransport {
|
|
31
46
|
private _isRestored;
|
|
47
|
+
private _restoredSessionId?;
|
|
48
|
+
/**
|
|
49
|
+
* Sets the sessionId for a restored session.
|
|
50
|
+
*
|
|
51
|
+
* When restoring a session, we need to ensure the sessionId is available immediately
|
|
52
|
+
* without waiting for the sessionIdGenerator to be called by the SDK. This method
|
|
53
|
+
* directly sets the sessionId on the underlying transport.
|
|
54
|
+
*
|
|
55
|
+
* @param sessionId - The sessionId to set for the restored session
|
|
56
|
+
* @returns OperationResult indicating success or failure with error details
|
|
57
|
+
*/
|
|
58
|
+
setSessionId(sessionId: string): OperationResult;
|
|
59
|
+
/**
|
|
60
|
+
* Override sessionId getter to return restored sessionId if available.
|
|
61
|
+
*
|
|
62
|
+
* This ensures that even if the underlying transport hasn't generated the sessionId yet,
|
|
63
|
+
* we return the correct restored sessionId. If no restored session ID exists, delegates
|
|
64
|
+
* to the parent class's getter by manually accessing the property descriptor.
|
|
65
|
+
*
|
|
66
|
+
* @remarks
|
|
67
|
+
* We cannot use `super.sessionId` directly because this override shadows the parent's
|
|
68
|
+
* getter. Instead, we use Object.getOwnPropertyDescriptor to access the parent's
|
|
69
|
+
* property descriptor and call its getter with the correct context.
|
|
70
|
+
*
|
|
71
|
+
* Type assertion to `object` is safe here because we know the prototype chain exists:
|
|
72
|
+
* this -> RestorableStreamableHTTPServerTransport -> StreamableHTTPServerTransport -> Object.prototype
|
|
73
|
+
* Object.getOwnPropertyDescriptor requires an object type, and TypeScript cannot infer this
|
|
74
|
+
* from the double getPrototypeOf call.
|
|
75
|
+
*/
|
|
76
|
+
get sessionId(): string | undefined;
|
|
32
77
|
/**
|
|
33
78
|
* Marks the transport as initialized for restored sessions.
|
|
34
79
|
*
|
|
@@ -37,9 +82,9 @@ export declare class RestorableStreamableHTTPServerTransport extends StreamableH
|
|
|
37
82
|
* The MCP SDK checks the _initialized flag and rejects requests if it's false.
|
|
38
83
|
* This method safely sets that flag to allow the restored session to work.
|
|
39
84
|
*
|
|
40
|
-
* @
|
|
85
|
+
* @returns OperationResult indicating success or failure with error details
|
|
41
86
|
*/
|
|
42
|
-
markAsInitialized():
|
|
87
|
+
markAsInitialized(): OperationResult;
|
|
43
88
|
/**
|
|
44
89
|
* Returns whether this transport was created for a restored session.
|
|
45
90
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"restorableStreamableTransport.d.ts","sourceRoot":"","sources":["../../../src/transport/http/restorableStreamableTransport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAC;
|
|
1
|
+
{"version":3,"file":"restorableStreamableTransport.d.ts","sourceRoot":"","sources":["../../../src/transport/http/restorableStreamableTransport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAC;AAKnG;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,KAAK,CAAC,EAAE,KAAK,CAAA;CAAE,GAAG;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEnG;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBAAa,uCAAwC,SAAQ,6BAA6B;IACxF,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,kBAAkB,CAAC,CAAS;IAEpC;;;;;;;;;OASG;IACH,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,eAAe;IAwBhD;;;;;;;;;;;;;;;;OAgBG;IACH,IAAa,SAAS,IAAI,MAAM,GAAG,SAAS,CAiB3C;IAED;;;;;;;;;OASG;IACH,iBAAiB,IAAI,eAAe;IAyBpC;;;;OAIG;IACH,UAAU,IAAI,OAAO;IAIrB;;;;OAIG;IACH,kBAAkB,IAAI,eAAe;CAUtC"}
|
|
@@ -7,22 +7,95 @@ import logger from '../../logger/logger.js';
|
|
|
7
7
|
* This wrapper class encapsulates the initialization logic needed for restored sessions,
|
|
8
8
|
* providing a clean interface that's less likely to break with SDK updates.
|
|
9
9
|
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* The class works by:
|
|
12
|
+
* 1. Storing a restored sessionId that overrides the SDK's getter
|
|
13
|
+
* 2. Providing methods to safely access and modify internal SDK properties
|
|
14
|
+
* 3. Returning success/failure status from operations for proper error handling
|
|
15
|
+
*
|
|
10
16
|
* @example
|
|
11
17
|
* ```typescript
|
|
12
|
-
* //
|
|
18
|
+
* // SessionService handles the full restoration flow:
|
|
13
19
|
* const transport = new RestorableStreamableHTTPServerTransport({
|
|
14
|
-
* sessionIdGenerator: () =>
|
|
20
|
+
* sessionIdGenerator: () => originalSessionId,
|
|
15
21
|
* });
|
|
16
|
-
* transport.markAsInitialized();
|
|
17
|
-
*
|
|
18
|
-
* //
|
|
19
|
-
* if (transport.isRestored()) {
|
|
20
|
-
* // Handle restored session logic
|
|
21
|
-
* }
|
|
22
|
+
* const initResult = transport.markAsInitialized();
|
|
23
|
+
* transport.setSessionId(originalSessionId);
|
|
24
|
+
* // Now transport.isRestored() returns true
|
|
22
25
|
* ```
|
|
23
26
|
*/
|
|
24
27
|
export class RestorableStreamableHTTPServerTransport extends StreamableHTTPServerTransport {
|
|
25
28
|
_isRestored = false;
|
|
29
|
+
_restoredSessionId;
|
|
30
|
+
/**
|
|
31
|
+
* Sets the sessionId for a restored session.
|
|
32
|
+
*
|
|
33
|
+
* When restoring a session, we need to ensure the sessionId is available immediately
|
|
34
|
+
* without waiting for the sessionIdGenerator to be called by the SDK. This method
|
|
35
|
+
* directly sets the sessionId on the underlying transport.
|
|
36
|
+
*
|
|
37
|
+
* @param sessionId - The sessionId to set for the restored session
|
|
38
|
+
* @returns OperationResult indicating success or failure with error details
|
|
39
|
+
*/
|
|
40
|
+
setSessionId(sessionId) {
|
|
41
|
+
this._restoredSessionId = sessionId;
|
|
42
|
+
try {
|
|
43
|
+
// Access the underlying _webStandardTransport where sessionId is stored
|
|
44
|
+
// StreamableHTTPServerTransport is a wrapper with getter-only sessionId
|
|
45
|
+
// The actual sessionId is on _webStandardTransport which allows setting
|
|
46
|
+
const internalTransport = this;
|
|
47
|
+
const webStandardTransport = internalTransport._webStandardTransport;
|
|
48
|
+
if (webStandardTransport) {
|
|
49
|
+
webStandardTransport.sessionId = sessionId;
|
|
50
|
+
return { success: true };
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
success: false,
|
|
54
|
+
error: 'No webStandardTransport found - SDK internal structure may have changed or transport is not properly initialized',
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
59
|
+
logger.warn(`Failed to set sessionId "${sessionId}" on underlying transport: ${errorMessage}`);
|
|
60
|
+
return { success: false, error: errorMessage };
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Override sessionId getter to return restored sessionId if available.
|
|
65
|
+
*
|
|
66
|
+
* This ensures that even if the underlying transport hasn't generated the sessionId yet,
|
|
67
|
+
* we return the correct restored sessionId. If no restored session ID exists, delegates
|
|
68
|
+
* to the parent class's getter by manually accessing the property descriptor.
|
|
69
|
+
*
|
|
70
|
+
* @remarks
|
|
71
|
+
* We cannot use `super.sessionId` directly because this override shadows the parent's
|
|
72
|
+
* getter. Instead, we use Object.getOwnPropertyDescriptor to access the parent's
|
|
73
|
+
* property descriptor and call its getter with the correct context.
|
|
74
|
+
*
|
|
75
|
+
* Type assertion to `object` is safe here because we know the prototype chain exists:
|
|
76
|
+
* this -> RestorableStreamableHTTPServerTransport -> StreamableHTTPServerTransport -> Object.prototype
|
|
77
|
+
* Object.getOwnPropertyDescriptor requires an object type, and TypeScript cannot infer this
|
|
78
|
+
* from the double getPrototypeOf call.
|
|
79
|
+
*/
|
|
80
|
+
get sessionId() {
|
|
81
|
+
// First check if we have a restored sessionId
|
|
82
|
+
if (this._restoredSessionId) {
|
|
83
|
+
return this._restoredSessionId;
|
|
84
|
+
}
|
|
85
|
+
// Otherwise delegate to parent class's getter directly
|
|
86
|
+
// Use Object.getOwnPropertyDescriptor to get the parent's property descriptor
|
|
87
|
+
// and call the getter with the parent's context
|
|
88
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
89
|
+
const proto = Object.getPrototypeOf(Object.getPrototypeOf(this));
|
|
90
|
+
if (!proto)
|
|
91
|
+
return undefined;
|
|
92
|
+
const descriptor = Object.getOwnPropertyDescriptor(proto, 'sessionId');
|
|
93
|
+
if (descriptor?.get) {
|
|
94
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
95
|
+
return descriptor.get.call(this);
|
|
96
|
+
}
|
|
97
|
+
return undefined;
|
|
98
|
+
}
|
|
26
99
|
/**
|
|
27
100
|
* Marks the transport as initialized for restored sessions.
|
|
28
101
|
*
|
|
@@ -31,27 +104,29 @@ export class RestorableStreamableHTTPServerTransport extends StreamableHTTPServe
|
|
|
31
104
|
* The MCP SDK checks the _initialized flag and rejects requests if it's false.
|
|
32
105
|
* This method safely sets that flag to allow the restored session to work.
|
|
33
106
|
*
|
|
34
|
-
* @
|
|
107
|
+
* @returns OperationResult indicating success or failure with error details
|
|
35
108
|
*/
|
|
36
109
|
markAsInitialized() {
|
|
37
110
|
try {
|
|
38
111
|
// Use type-safe interface to access internal SDK properties
|
|
39
|
-
//
|
|
40
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment
|
|
112
|
+
// MCP SDK private property _initialized is not exposed in public types
|
|
41
113
|
const internalTransport = this;
|
|
42
|
-
//
|
|
43
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
114
|
+
// Accessing private SDK property for session restoration functionality
|
|
44
115
|
if (internalTransport._initialized !== undefined) {
|
|
45
|
-
//
|
|
46
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
116
|
+
// Setting private SDK property to mark session as initialized for restoration
|
|
47
117
|
internalTransport._initialized = true;
|
|
48
118
|
}
|
|
119
|
+
// Note: If _initialized is undefined, we still mark as restored since the SDK may have changed
|
|
120
|
+
// This provides graceful degradation while allowing session restoration to proceed
|
|
49
121
|
this._isRestored = true;
|
|
50
122
|
logger.debug('Transport marked as initialized for restored session');
|
|
123
|
+
return { success: true };
|
|
51
124
|
}
|
|
52
125
|
catch (error) {
|
|
53
|
-
|
|
54
|
-
|
|
126
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
127
|
+
logger.warn(`Failed to mark transport as initialized: ${errorMessage}`);
|
|
128
|
+
this._isRestored = false;
|
|
129
|
+
return { success: false, error: errorMessage };
|
|
55
130
|
}
|
|
56
131
|
}
|
|
57
132
|
/**
|
|
@@ -69,13 +144,10 @@ export class RestorableStreamableHTTPServerTransport extends StreamableHTTPServe
|
|
|
69
144
|
*/
|
|
70
145
|
getRestorationInfo() {
|
|
71
146
|
// Use type-safe interface to access potentially private sessionId
|
|
72
|
-
// Reason: sessionId property may not be exposed in public SDK types
|
|
73
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment
|
|
74
147
|
const internalTransport = this;
|
|
75
148
|
return {
|
|
76
149
|
isRestored: this._isRestored,
|
|
77
|
-
//
|
|
78
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment
|
|
150
|
+
// Accessing potentially private sessionId property for debugging
|
|
79
151
|
sessionId: internalTransport.sessionId,
|
|
80
152
|
};
|
|
81
153
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"restorableStreamableTransport.js","sourceRoot":"","sources":["../../../src/transport/http/restorableStreamableTransport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAC;AAEnG,OAAO,MAAM,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"restorableStreamableTransport.js","sourceRoot":"","sources":["../../../src/transport/http/restorableStreamableTransport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAC;AAEnG,OAAO,MAAM,MAAM,uBAAuB,CAAC;AAkB3C;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,OAAO,uCAAwC,SAAQ,6BAA6B;IAChF,WAAW,GAAG,KAAK,CAAC;IACpB,kBAAkB,CAAU;IAEpC;;;;;;;;;OASG;IACH,YAAY,CAAC,SAAiB;QAC5B,IAAI,CAAC,kBAAkB,GAAG,SAAS,CAAC;QACpC,IAAI,CAAC;YACH,wEAAwE;YACxE,wEAAwE;YACxE,wEAAwE;YACxE,MAAM,iBAAiB,GAAG,IAA8C,CAAC;YACzE,MAAM,oBAAoB,GAAG,iBAAiB,CAAC,qBAAqB,CAAC;YACrE,IAAI,oBAAoB,EAAE,CAAC;gBACzB,oBAAoB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C,CAAC;YAEzE,uEAAuE;YACvE,IAAI,iBAAiB,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;gBACjD,8EAA8E;gBAC9E,iBAAiB,CAAC,YAAY,GAAG,IAAI,CAAC;YACxC,CAAC;YACD,+FAA+F;YAC/F,mFAAmF;YAEnF,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;YACxB,MAAM,CAAC,KAAK,CAAC,sDAAsD,CAAC,CAAC;YACrE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QAC3B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAC5E,MAAM,CAAC,IAAI,CAAC,4CAA4C,YAAY,EAAE,CAAC,CAAC;YACxE,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;YACzB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC;QACjD,CAAC;IACH,CAAC;IAED;;;;OAIG;IACH,UAAU;QACR,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAED;;;;OAIG;IACH,kBAAkB;QAChB,kEAAkE;QAClE,MAAM,iBAAiB,GAAG,IAA8C,CAAC;QAEzE,OAAO;YACL,UAAU,EAAE,IAAI,CAAC,WAAW;YAC5B,iEAAiE;YACjE,SAAS,EAAE,iBAAiB,CAAC,SAAS;SACvC,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AsyncLoadingOrchestrator } from '../../../core/capabilities/asyncLoadingOrchestrator.js';
|
|
2
2
|
import { ServerManager } from '../../../core/server/serverManager.js';
|
|
3
3
|
import { StreamableSessionRepository } from '../../../transport/http/storage/streamableSessionRepository.js';
|
|
4
|
+
import { SessionService } from '../../../transport/http/utils/sessionService.js';
|
|
4
5
|
import { RequestHandler, Router } from 'express';
|
|
5
|
-
export declare function setupStreamableHttpRoutes(router: Router, serverManager: ServerManager, sessionRepository: StreamableSessionRepository, authMiddleware: RequestHandler, availabilityMiddleware?: RequestHandler, asyncOrchestrator?: AsyncLoadingOrchestrator, customTemplate?: string): void;
|
|
6
|
+
export declare function setupStreamableHttpRoutes(router: Router, serverManager: ServerManager, sessionRepository: StreamableSessionRepository, authMiddleware: RequestHandler, availabilityMiddleware?: RequestHandler, asyncOrchestrator?: AsyncLoadingOrchestrator, customTemplate?: string, injectedSessionService?: SessionService): void;
|
|
6
7
|
//# sourceMappingURL=streamableHttpRoutes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"streamableHttpRoutes.d.ts","sourceRoot":"","sources":["../../../../src/transport/http/routes/streamableHttpRoutes.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,wBAAwB,EAAE,MAAM,oDAAoD,CAAC;AAC9F,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"streamableHttpRoutes.d.ts","sourceRoot":"","sources":["../../../../src/transport/http/routes/streamableHttpRoutes.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,wBAAwB,EAAE,MAAM,oDAAoD,CAAC;AAC9F,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAWlE,OAAO,EAAE,2BAA2B,EAAE,MAAM,4DAA4D,CAAC;AAEzG,OAAO,EAAE,cAAc,EAAE,MAAM,6CAA6C,CAAC;AAE7E,OAAO,EAAW,cAAc,EAAY,MAAM,EAAE,MAAM,SAAS,CAAC;AAsDpE,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,aAAa,EAC5B,iBAAiB,EAAE,2BAA2B,EAC9C,cAAc,EAAE,cAAc,EAC9B,sBAAsB,CAAC,EAAE,cAAc,EACvC,iBAAiB,CAAC,EAAE,wBAAwB,EAC5C,cAAc,CAAC,EAAE,MAAM,EACvB,sBAAsB,CAAC,EAAE,cAAc,GACtC,IAAI,CAqJN"}
|
|
@@ -1,85 +1,29 @@
|
|
|
1
1
|
import { randomUUID } from 'node:crypto';
|
|
2
|
-
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
|
3
2
|
import { ErrorCode } from '@modelcontextprotocol/sdk/types.js';
|
|
4
3
|
import { AUTH_CONFIG, STREAMABLE_HTTP_ENDPOINT } from '../../../constants.js';
|
|
5
|
-
import { ServerStatus } from '../../../core/types/index.js';
|
|
6
4
|
import logger from '../../../logger/logger.js';
|
|
7
5
|
import { getPresetName, getTagExpression, getTagFilterMode, getTagQuery, getValidatedTags, } from '../../../transport/http/middlewares/scopeAuthMiddleware.js';
|
|
8
6
|
import tagsExtractor from '../../../transport/http/middlewares/tagsExtractor.js';
|
|
9
|
-
import { RestorableStreamableHTTPServerTransport } from '../../../transport/http/restorableStreamableTransport.js';
|
|
10
7
|
import { extractContextFromMeta } from '../../../transport/http/utils/contextExtractor.js';
|
|
8
|
+
import { SessionService } from '../../../transport/http/utils/sessionService.js';
|
|
11
9
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
10
|
+
* Builds the inbound connection config from request data.
|
|
11
|
+
*
|
|
12
|
+
* @param res - Express response object containing validated middleware data
|
|
13
|
+
* @param req - Express request object
|
|
14
|
+
* @param customTemplate - Optional custom template to include
|
|
15
|
+
* @returns The inbound connection configuration
|
|
14
16
|
*/
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
// Create new transport with the original session ID using wrapper class
|
|
26
|
-
const transport = new RestorableStreamableHTTPServerTransport({
|
|
27
|
-
sessionIdGenerator: () => sessionId,
|
|
28
|
-
});
|
|
29
|
-
// Mark the transport as initialized for restored session
|
|
30
|
-
// The wrapper class safely handles the SDK's internal _initialized flag
|
|
31
|
-
transport.markAsInitialized();
|
|
32
|
-
// Safely set sessionId if possible
|
|
33
|
-
try {
|
|
34
|
-
transport.sessionId = sessionId;
|
|
35
|
-
}
|
|
36
|
-
catch (error) {
|
|
37
|
-
logger.warn('Could not set sessionId on restored transport:', error);
|
|
38
|
-
}
|
|
39
|
-
// Convert config context to ContextData format if available
|
|
40
|
-
const contextData = config.context
|
|
41
|
-
? {
|
|
42
|
-
project: config.context.project || {},
|
|
43
|
-
user: config.context.user || {},
|
|
44
|
-
environment: config.context.environment || {},
|
|
45
|
-
timestamp: config.context.timestamp,
|
|
46
|
-
sessionId: config.context.sessionId || sessionId,
|
|
47
|
-
version: config.context.version,
|
|
48
|
-
transport: config.context.transport,
|
|
49
|
-
}
|
|
50
|
-
: undefined;
|
|
51
|
-
// Reconnect with the original configuration and context
|
|
52
|
-
await serverManager.connectTransport(transport, sessionId, config, contextData);
|
|
53
|
-
// Initialize notifications for async loading if enabled
|
|
54
|
-
if (asyncOrchestrator) {
|
|
55
|
-
const inboundConnection = serverManager.getServer(sessionId);
|
|
56
|
-
if (inboundConnection) {
|
|
57
|
-
asyncOrchestrator.initializeNotifications(inboundConnection);
|
|
58
|
-
logger.debug(`Async loading notifications initialized for restored session ${sessionId}`);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
// Set up handlers for the restored transport
|
|
62
|
-
transport.onclose = () => {
|
|
63
|
-
serverManager.disconnectTransport(sessionId);
|
|
64
|
-
sessionRepository.delete(sessionId);
|
|
65
|
-
};
|
|
66
|
-
transport.onerror = (error) => {
|
|
67
|
-
logger.error(`Streamable HTTP transport error for session ${sessionId}:`, error);
|
|
68
|
-
const server = serverManager.getServer(sessionId);
|
|
69
|
-
if (server) {
|
|
70
|
-
server.status = ServerStatus.Error;
|
|
71
|
-
server.lastError = error instanceof Error ? error : new Error(String(error));
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
// Update last accessed time with dual-trigger persistence
|
|
75
|
-
sessionRepository.updateAccess(sessionId);
|
|
76
|
-
logger.info(`Successfully restored streamable session: ${sessionId} (restored: ${transport.isRestored()})`);
|
|
77
|
-
return transport;
|
|
78
|
-
}
|
|
79
|
-
catch (error) {
|
|
80
|
-
logger.error(`Failed to restore streamable session ${sessionId}:`, error);
|
|
81
|
-
return null;
|
|
82
|
-
}
|
|
17
|
+
function buildConfigFromRequest(res, req, customTemplate) {
|
|
18
|
+
return {
|
|
19
|
+
tags: getValidatedTags(res),
|
|
20
|
+
tagExpression: getTagExpression(res),
|
|
21
|
+
tagFilterMode: getTagFilterMode(res),
|
|
22
|
+
tagQuery: getTagQuery(res),
|
|
23
|
+
presetName: getPresetName(res),
|
|
24
|
+
enablePagination: req.query.pagination === 'true',
|
|
25
|
+
customTemplate,
|
|
26
|
+
};
|
|
83
27
|
}
|
|
84
28
|
/**
|
|
85
29
|
* Sets up client disconnect detection for a request/response pair.
|
|
@@ -109,12 +53,13 @@ function setupDisconnectDetection(req, res, sessionId, serverManager) {
|
|
|
109
53
|
}
|
|
110
54
|
});
|
|
111
55
|
}
|
|
112
|
-
export function setupStreamableHttpRoutes(router, serverManager, sessionRepository, authMiddleware, availabilityMiddleware, asyncOrchestrator, customTemplate) {
|
|
56
|
+
export function setupStreamableHttpRoutes(router, serverManager, sessionRepository, authMiddleware, availabilityMiddleware, asyncOrchestrator, customTemplate, injectedSessionService) {
|
|
113
57
|
const middlewares = [tagsExtractor, authMiddleware];
|
|
114
58
|
// Add availability middleware if provided
|
|
115
59
|
if (availabilityMiddleware) {
|
|
116
60
|
middlewares.push(availabilityMiddleware);
|
|
117
61
|
}
|
|
62
|
+
const sessionService = injectedSessionService || new SessionService(serverManager, sessionRepository, asyncOrchestrator);
|
|
118
63
|
router.post(STREAMABLE_HTTP_ENDPOINT, ...middlewares, async (req, res) => {
|
|
119
64
|
try {
|
|
120
65
|
let transport;
|
|
@@ -122,147 +67,43 @@ export function setupStreamableHttpRoutes(router, serverManager, sessionReposito
|
|
|
122
67
|
if (!sessionId) {
|
|
123
68
|
// Generate new session ID
|
|
124
69
|
const id = AUTH_CONFIG.SERVER.STREAMABLE_SESSION.ID_PREFIX + randomUUID();
|
|
125
|
-
|
|
126
|
-
sessionIdGenerator: () => id,
|
|
127
|
-
});
|
|
128
|
-
// Use validated tags and tag expression from scope auth middleware
|
|
129
|
-
const tags = getValidatedTags(res);
|
|
130
|
-
const tagExpression = getTagExpression(res);
|
|
131
|
-
const tagFilterMode = getTagFilterMode(res);
|
|
132
|
-
const tagQuery = getTagQuery(res);
|
|
133
|
-
const presetName = getPresetName(res);
|
|
134
|
-
const config = {
|
|
135
|
-
tags,
|
|
136
|
-
tagExpression,
|
|
137
|
-
tagFilterMode,
|
|
138
|
-
tagQuery,
|
|
139
|
-
presetName,
|
|
140
|
-
enablePagination: req.query.pagination === 'true',
|
|
141
|
-
customTemplate,
|
|
142
|
-
};
|
|
70
|
+
const config = buildConfigFromRequest(res, req, customTemplate);
|
|
143
71
|
// Extract context from _meta field (from STDIO proxy)
|
|
144
72
|
const context = extractContextFromMeta(req);
|
|
145
|
-
|
|
146
|
-
|
|
73
|
+
const createResult = await sessionService.createSession(config, context || undefined, id);
|
|
74
|
+
transport = createResult.transport;
|
|
75
|
+
// Log warning if session was not persisted
|
|
76
|
+
if (!createResult.persisted) {
|
|
77
|
+
logger.warn(`New session ${id} was created but not persisted: ${createResult.persistenceError}`);
|
|
147
78
|
}
|
|
148
|
-
// Include full context in config for session persistence
|
|
149
|
-
const configWithContext = {
|
|
150
|
-
...config,
|
|
151
|
-
context: context || undefined,
|
|
152
|
-
};
|
|
153
|
-
// Pass context to ServerManager for template processing (only if valid)
|
|
154
|
-
const validContext = context && context.project && context.user && context.environment ? context : undefined;
|
|
155
|
-
await serverManager.connectTransport(transport, id, configWithContext, validContext);
|
|
156
|
-
// Persist session configuration with full context for restoration
|
|
157
|
-
sessionRepository.create(id, configWithContext);
|
|
158
|
-
// Initialize notifications for async loading if enabled
|
|
159
|
-
if (asyncOrchestrator) {
|
|
160
|
-
const inboundConnection = serverManager.getServer(id);
|
|
161
|
-
if (inboundConnection) {
|
|
162
|
-
asyncOrchestrator.initializeNotifications(inboundConnection);
|
|
163
|
-
logger.debug(`Async loading notifications initialized for Streamable HTTP session ${id}`);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
transport.onclose = () => {
|
|
167
|
-
serverManager.disconnectTransport(id);
|
|
168
|
-
sessionRepository.delete(id);
|
|
169
|
-
};
|
|
170
|
-
transport.onerror = (error) => {
|
|
171
|
-
logger.error(`Streamable HTTP transport error for session ${id}:`, error);
|
|
172
|
-
const server = serverManager.getServer(id);
|
|
173
|
-
if (server) {
|
|
174
|
-
server.status = ServerStatus.Error;
|
|
175
|
-
server.lastError = error instanceof Error ? error : new Error(String(error));
|
|
176
|
-
}
|
|
177
|
-
};
|
|
178
79
|
}
|
|
179
80
|
else {
|
|
180
|
-
|
|
181
|
-
if (!
|
|
182
|
-
//
|
|
81
|
+
transport = await sessionService.getSession(sessionId);
|
|
82
|
+
if (!transport) {
|
|
83
|
+
// Session restoration failed - create new session with provided ID (handles proxy use case)
|
|
84
|
+
logger.error(`Session restoration failed for ${sessionId}, creating new session as fallback`);
|
|
85
|
+
const config = buildConfigFromRequest(res, req, customTemplate);
|
|
86
|
+
// Extract context from _meta field (from STDIO proxy)
|
|
183
87
|
const context = extractContextFromMeta(req);
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
if (!restoredTransport) {
|
|
190
|
-
// Session restoration failed - create new session with provided ID (handles proxy use case)
|
|
191
|
-
logger.info(`🆕 Session restoration failed, creating new session with provided ID: ${sessionId}`);
|
|
192
|
-
transport = new StreamableHTTPServerTransport({
|
|
193
|
-
sessionIdGenerator: () => sessionId,
|
|
194
|
-
});
|
|
195
|
-
// Use validated tags and tag expression from scope auth middleware
|
|
196
|
-
const tags = getValidatedTags(res);
|
|
197
|
-
const tagExpression = getTagExpression(res);
|
|
198
|
-
const tagFilterMode = getTagFilterMode(res);
|
|
199
|
-
const tagQuery = getTagQuery(res);
|
|
200
|
-
const presetName = getPresetName(res);
|
|
201
|
-
const config = {
|
|
202
|
-
tags,
|
|
203
|
-
tagExpression,
|
|
204
|
-
tagFilterMode,
|
|
205
|
-
tagQuery,
|
|
206
|
-
presetName,
|
|
207
|
-
enablePagination: req.query.pagination === 'true',
|
|
208
|
-
customTemplate,
|
|
209
|
-
};
|
|
210
|
-
// Extract context from _meta field (from STDIO proxy)
|
|
211
|
-
const context = extractContextFromMeta(req);
|
|
212
|
-
if (context && context.project?.name && context.sessionId) {
|
|
213
|
-
logger.info(`🔗 New session with provided ID and context: ${context.project.name} (${context.sessionId})`);
|
|
214
|
-
}
|
|
215
|
-
// Pass context to ServerManager for template processing (only if valid)
|
|
216
|
-
const validContext = context && context.project && context.user && context.environment ? context : undefined;
|
|
217
|
-
await serverManager.connectTransport(transport, sessionId, config, validContext);
|
|
218
|
-
// Persist session configuration for restoration with context
|
|
219
|
-
sessionRepository.create(sessionId, config);
|
|
220
|
-
// Initialize notifications for async loading if enabled
|
|
221
|
-
if (asyncOrchestrator) {
|
|
222
|
-
const inboundConnection = serverManager.getServer(sessionId);
|
|
223
|
-
if (inboundConnection) {
|
|
224
|
-
asyncOrchestrator.initializeNotifications(inboundConnection);
|
|
225
|
-
logger.debug(`Async loading notifications initialized for Streamable HTTP session ${sessionId}`);
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
transport.onclose = () => {
|
|
229
|
-
serverManager.disconnectTransport(sessionId);
|
|
230
|
-
sessionRepository.delete(sessionId);
|
|
231
|
-
};
|
|
232
|
-
transport.onerror = (error) => {
|
|
233
|
-
logger.error(`Streamable HTTP transport error for session ${sessionId}:`, error);
|
|
234
|
-
const server = serverManager.getServer(sessionId);
|
|
235
|
-
if (server) {
|
|
236
|
-
server.status = ServerStatus.Error;
|
|
237
|
-
server.lastError = error instanceof Error ? error : new Error(String(error));
|
|
238
|
-
}
|
|
239
|
-
};
|
|
88
|
+
const createResult = await sessionService.createSession(config, context || undefined, sessionId);
|
|
89
|
+
transport = createResult.transport;
|
|
90
|
+
// Log warning if session was not persisted
|
|
91
|
+
if (!createResult.persisted) {
|
|
92
|
+
logger.warn(`Fallback session ${sessionId} was created but not persisted: ${createResult.persistenceError}`);
|
|
240
93
|
}
|
|
241
|
-
else {
|
|
242
|
-
transport = restoredTransport;
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
else if (existingTransport instanceof StreamableHTTPServerTransport ||
|
|
246
|
-
existingTransport instanceof RestorableStreamableHTTPServerTransport) {
|
|
247
|
-
transport = existingTransport;
|
|
248
|
-
// Update last accessed time for active sessions with dual-trigger persistence
|
|
249
|
-
sessionRepository.updateAccess(sessionId);
|
|
250
|
-
}
|
|
251
|
-
else {
|
|
252
|
-
res.status(400).json({
|
|
253
|
-
error: {
|
|
254
|
-
code: ErrorCode.InvalidParams,
|
|
255
|
-
message: 'Session already exists but uses a different transport protocol',
|
|
256
|
-
},
|
|
257
|
-
});
|
|
258
|
-
return;
|
|
259
94
|
}
|
|
260
95
|
}
|
|
261
96
|
await transport.handleRequest(req, res, req.body);
|
|
262
97
|
}
|
|
263
98
|
catch (error) {
|
|
264
|
-
|
|
265
|
-
|
|
99
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
100
|
+
logger.error('Streamable HTTP POST error:', { error: errorMessage, sessionId: req.headers['mcp-session-id'] });
|
|
101
|
+
res.status(500).json({
|
|
102
|
+
error: {
|
|
103
|
+
code: ErrorCode.InternalError,
|
|
104
|
+
message: 'An internal server error occurred while processing the request',
|
|
105
|
+
},
|
|
106
|
+
});
|
|
266
107
|
}
|
|
267
108
|
});
|
|
268
109
|
router.get(STREAMABLE_HTTP_ENDPOINT, ...middlewares, async (req, res) => {
|
|
@@ -277,32 +118,29 @@ export function setupStreamableHttpRoutes(router, serverManager, sessionReposito
|
|
|
277
118
|
});
|
|
278
119
|
return;
|
|
279
120
|
}
|
|
280
|
-
|
|
121
|
+
const transport = await sessionService.getSession(sessionId);
|
|
281
122
|
if (!transport) {
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
},
|
|
290
|
-
});
|
|
291
|
-
return;
|
|
292
|
-
}
|
|
293
|
-
transport = restoredTransport;
|
|
294
|
-
}
|
|
295
|
-
else {
|
|
296
|
-
// Update last accessed time for active sessions with dual-trigger persistence
|
|
297
|
-
sessionRepository.updateAccess(sessionId);
|
|
123
|
+
res.status(404).json({
|
|
124
|
+
error: {
|
|
125
|
+
code: ErrorCode.InvalidParams,
|
|
126
|
+
message: 'No active streamable HTTP session found for the provided sessionId',
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
return;
|
|
298
130
|
}
|
|
299
131
|
// Set up disconnect detection for SSE stream (GET endpoint maintains persistent connection)
|
|
300
132
|
setupDisconnectDetection(req, res, sessionId, serverManager);
|
|
301
133
|
await transport.handleRequest(req, res, req.body);
|
|
302
134
|
}
|
|
303
135
|
catch (error) {
|
|
304
|
-
|
|
305
|
-
|
|
136
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
137
|
+
logger.error('Streamable HTTP GET error:', { error: errorMessage, sessionId: req.headers['mcp-session-id'] });
|
|
138
|
+
res.status(500).json({
|
|
139
|
+
error: {
|
|
140
|
+
code: ErrorCode.InternalError,
|
|
141
|
+
message: 'An internal server error occurred while processing the request',
|
|
142
|
+
},
|
|
143
|
+
});
|
|
306
144
|
}
|
|
307
145
|
});
|
|
308
146
|
router.delete(STREAMABLE_HTTP_ENDPOINT, ...middlewares, async (req, res) => {
|
|
@@ -317,28 +155,29 @@ export function setupStreamableHttpRoutes(router, serverManager, sessionReposito
|
|
|
317
155
|
});
|
|
318
156
|
return;
|
|
319
157
|
}
|
|
320
|
-
|
|
158
|
+
const transport = await sessionService.getSession(sessionId);
|
|
321
159
|
if (!transport) {
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
},
|
|
330
|
-
});
|
|
331
|
-
return;
|
|
332
|
-
}
|
|
333
|
-
transport = restoredTransport;
|
|
160
|
+
res.status(404).json({
|
|
161
|
+
error: {
|
|
162
|
+
code: ErrorCode.InvalidParams,
|
|
163
|
+
message: 'No active streamable HTTP session found for the provided sessionId',
|
|
164
|
+
},
|
|
165
|
+
});
|
|
166
|
+
return;
|
|
334
167
|
}
|
|
335
168
|
await transport.handleRequest(req, res);
|
|
336
169
|
// Delete session from storage after explicit delete request
|
|
337
|
-
|
|
170
|
+
await sessionService.deleteSession(sessionId);
|
|
338
171
|
}
|
|
339
172
|
catch (error) {
|
|
340
|
-
|
|
341
|
-
|
|
173
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
174
|
+
logger.error('Streamable HTTP DELETE error:', { error: errorMessage, sessionId: req.headers['mcp-session-id'] });
|
|
175
|
+
res.status(500).json({
|
|
176
|
+
error: {
|
|
177
|
+
code: ErrorCode.InternalError,
|
|
178
|
+
message: 'An internal server error occurred while processing the request',
|
|
179
|
+
},
|
|
180
|
+
});
|
|
342
181
|
}
|
|
343
182
|
});
|
|
344
183
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"streamableHttpRoutes.js","sourceRoot":"","sources":["../../../../src/transport/http/routes/streamableHttpRoutes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAC;AACnG,OAAO,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAE/D,OAAO,EAAE,WAAW,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAG1E,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,MAAM,MAAM,uBAAuB,CAAC;AAC3C,OAAO,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gBACf,qDAAqD;gBACrD,MAAM,iBAAiB,GAAG,MAAM,cAAc,CAAC,SAAS,EAAE,aAAa,EAAE,iBAAiB,EAAE,iBAAiB,CAAC,CAAC;gBAC/G,IAAI,CAAC,iBAAiB,EAAE,CAAC;oBACvB,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;wBACnB,KAAK,EAAE;4BACL,IAAI,EAAE,SAAS,CAAC,aAAa;4BAC7B,OAAO,EAAE,oEAAoE;yBAC9E;qBACF,CAAC,CAAC;oBACH,OAAO;gBACT,CAAC;gBACD,SAAS,GAAG,iBAAiB,CAAC;YAChC,CAAC;YACD,MAAM,SAAS,CAAC,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;YACxC,4DAA4D;YAC5D,iBAAiB,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QACtC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,KAAK,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;YAC9C,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;QACxB,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
1
|
+
{"version":3,"file":"streamableHttpRoutes.js","sourceRoot":"","sources":["../../../../src/transport/http/routes/streamableHttpRoutes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC,OAAO,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAE/D,OAAO,EAAE,WAAW,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAG1E,OAAO,MAAM,MAAM,uBAAuB,CAAC;AAC3C,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EAChB,WAAW,EACX,gBAAgB,GACjB,MAAM,wDAAwD,CAAC;AAChE,OAAO,aAAa,MAAM,kDAAkD,CAAC;AAG7E,OAAO,EAAE,sBAAsB,EA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,CAAC,CAAC;YACxC,4DAA4D;YAC5D,MAAM,cAAc,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;QAChD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAC5E,MAAM,CAAC,KAAK,CAAC,+BAA+B,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,GAAG,CAAC,OAAO,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC;YACjH,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;gBACnB,KAAK,EAAE;oBACL,IAAI,EAAE,SAAS,CAAC,aAAa;oBAC7B,OAAO,EAAE,gEAAgE;iBAC1E;aACF,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for internal properties of the MCP SDK that are not exposed
|
|
3
|
+
* in the public API but are needed for session restoration functionality.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Interface representing the internal structure of the web standard transport
|
|
7
|
+
* used within StreamableHTTPServerTransport
|
|
8
|
+
*/
|
|
9
|
+
export interface InternalWebStandardTransport {
|
|
10
|
+
sessionId: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Interface representing the internal structure of StreamableHTTPServerTransport
|
|
14
|
+
* exposing private properties needed for restoration
|
|
15
|
+
*/
|
|
16
|
+
export interface InternalStreamableTransport {
|
|
17
|
+
/**
|
|
18
|
+
* The underlying web standard transport instance
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
_webStandardTransport?: InternalWebStandardTransport;
|
|
22
|
+
/**
|
|
23
|
+
* Flag indicating if the transport has been initialized
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
_initialized?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Session ID from public interface
|
|
29
|
+
*/
|
|
30
|
+
sessionId?: string;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=sdkInternals.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdkInternals.d.ts","sourceRoot":"","sources":["../../../../src/transport/http/utils/sdkInternals.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,MAAM,WAAW,4BAA4B;IAC3C,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,MAAM,WAAW,2BAA2B;IAC1C;;;OAGG;IACH,qBAAqB,CAAC,EAAE,4BAA4B,CAAC;IAErD;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdkInternals.js","sourceRoot":"","sources":["../../../../src/transport/http/utils/sdkInternals.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
|
2
|
+
import { AsyncLoadingOrchestrator } from '../../../core/capabilities/asyncLoadingOrchestrator.js';
|
|
3
|
+
import { ServerManager } from '../../../core/server/serverManager.js';
|
|
4
|
+
import { InboundConnectionConfig } from '../../../core/types/index.js';
|
|
5
|
+
import { RestorableStreamableHTTPServerTransport } from '../../../transport/http/restorableStreamableTransport.js';
|
|
6
|
+
import { StreamableSessionRepository } from '../../../transport/http/storage/streamableSessionRepository.js';
|
|
7
|
+
import type { ContextData } from '../../../types/context.js';
|
|
8
|
+
/**
|
|
9
|
+
* Result type for session restoration operations.
|
|
10
|
+
*/
|
|
11
|
+
export interface SessionRestoreResult {
|
|
12
|
+
transport: RestorableStreamableHTTPServerTransport | null;
|
|
13
|
+
error?: string;
|
|
14
|
+
errorType?: 'not_found' | 'transport_failed' | 'connection_failed' | 'context_invalid';
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Result type for session creation operations.
|
|
18
|
+
* Indicates whether the session was successfully persisted to storage.
|
|
19
|
+
*/
|
|
20
|
+
export interface SessionCreateResult {
|
|
21
|
+
transport: StreamableHTTPServerTransport | RestorableStreamableHTTPServerTransport;
|
|
22
|
+
persisted: boolean;
|
|
23
|
+
persistenceError?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Service to handle session management logic for Streamable HTTP transport.
|
|
27
|
+
* Encapsulates creation, restoration, and cleanup of sessions.
|
|
28
|
+
*/
|
|
29
|
+
export declare class SessionService {
|
|
30
|
+
private serverManager;
|
|
31
|
+
private sessionRepository;
|
|
32
|
+
private asyncOrchestrator?;
|
|
33
|
+
constructor(serverManager: ServerManager, sessionRepository: StreamableSessionRepository, asyncOrchestrator?: AsyncLoadingOrchestrator | undefined);
|
|
34
|
+
/**
|
|
35
|
+
* Retrieves an existing session transport or tries to restore it.
|
|
36
|
+
*
|
|
37
|
+
* @param sessionId - The session ID to retrieve
|
|
38
|
+
* @returns The transport if found or restored successfully, null otherwise
|
|
39
|
+
*/
|
|
40
|
+
getSession(sessionId: string): Promise<StreamableHTTPServerTransport | RestorableStreamableHTTPServerTransport | null>;
|
|
41
|
+
/**
|
|
42
|
+
* Restores a session from persistent storage.
|
|
43
|
+
*
|
|
44
|
+
* @param sessionId - The session ID to restore
|
|
45
|
+
* @returns SessionRestoreResult with transport or error details
|
|
46
|
+
*/
|
|
47
|
+
restoreSession(sessionId: string): Promise<SessionRestoreResult>;
|
|
48
|
+
/**
|
|
49
|
+
* Creates a new session with the given configuration.
|
|
50
|
+
*
|
|
51
|
+
* @param config - The inbound connection configuration
|
|
52
|
+
* @param context - Optional context data for the session
|
|
53
|
+
* @param providedSessionId - Optional session ID to use instead of generating one
|
|
54
|
+
* @returns SessionCreateResult with transport and persistence status
|
|
55
|
+
* @throws Error if session creation fails (but not if persistence fails)
|
|
56
|
+
*/
|
|
57
|
+
createSession(config: InboundConnectionConfig, context?: Partial<ContextData>, providedSessionId?: string): Promise<SessionCreateResult>;
|
|
58
|
+
/**
|
|
59
|
+
* Deletes a session and cleans up resources.
|
|
60
|
+
*
|
|
61
|
+
* @param sessionId - The session ID to delete
|
|
62
|
+
*/
|
|
63
|
+
deleteSession(sessionId: string): Promise<void>;
|
|
64
|
+
/**
|
|
65
|
+
* Initializes async loading notifications for a session.
|
|
66
|
+
*
|
|
67
|
+
* This method should be called after connecting a transport to enable
|
|
68
|
+
* the async orchestrator to send capability updates to the client.
|
|
69
|
+
* Only applicable when async loading is enabled.
|
|
70
|
+
*
|
|
71
|
+
* @param sessionId - The session ID to initialize notifications for
|
|
72
|
+
*/
|
|
73
|
+
private initializeNotifications;
|
|
74
|
+
private setupTransportHandlers;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=sessionService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessionService.d.ts","sourceRoot":"","sources":["../../../../src/transport/http/utils/sessionService.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAC;AAGnG,OAAO,EAAE,wBAAwB,EAAE,MAAM,oDAAoD,CAAC;AAC9F,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,uBAAuB,EAAgB,MAAM,0BAA0B,CAAC;AAEjF,OAAO,EAAE,uCAAuC,EAAE,MAAM,sDAAsD,CAAC;AAC/G,OAAO,EAAE,2BAA2B,EAAE,MAAM,4DAA4D,CAAC;AACzG,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEzD;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,uCAAuC,GAAG,IAAI,CAAC;IAC1D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,WAAW,GAAG,kBAAkB,GAAG,mBAAmB,GAAG,iBAAiB,CAAC;CACxF;AAED;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC,SAAS,EAAE,6BAA6B,GAAG,uCAAuC,CAAC;IACnF,SAAS,EAAE,OAAO,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAYD;;;GAGG;AACH,qBAAa,cAAc;IAEvB,OAAO,CAAC,aAAa;IACrB,OAAO,CAAC,iBAAiB;IACzB,OAAO,CAAC,iBAAiB,CAAC;gBAFlB,aAAa,EAAE,aAAa,EAC5B,iBAAiB,EAAE,2BAA2B,EAC9C,iBAAiB,CAAC,EAAE,wBAAwB,YAAA;IAGtD;;;;;OAKG;IACG,UAAU,CACd,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,6BAA6B,GAAG,uCAAuC,GAAG,IAAI,CAAC;IA4B1F;;;;;OAKG;IACG,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAuEtE;;;;;;;;OAQG;IACG,aAAa,CACjB,MAAM,EAAE,uBAAuB,EAC/B,OAAO,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,EAC9B,iBAAiB,CAAC,EAAE,MAAM,GACzB,OAAO,CAAC,mBAAmB,CAAC;IA2D/B;;;;OAIG;IACG,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAWrD;;;;;;;;OAQG;IACH,OAAO,CAAC,uBAAuB;IAU/B,OAAO,CAAC,sBAAsB;CAkB/B"}
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
|
3
|
+
import { AUTH_CONFIG } from '../../../constants.js';
|
|
4
|
+
import { ServerStatus } from '../../../core/types/index.js';
|
|
5
|
+
import logger from '../../../logger/logger.js';
|
|
6
|
+
import { RestorableStreamableHTTPServerTransport } from '../../../transport/http/restorableStreamableTransport.js';
|
|
7
|
+
/**
|
|
8
|
+
* Validates a session ID format.
|
|
9
|
+
*
|
|
10
|
+
* @param sessionId - The session ID to validate
|
|
11
|
+
* @returns true if the session ID is valid, false otherwise
|
|
12
|
+
*/
|
|
13
|
+
function isValidSessionId(sessionId) {
|
|
14
|
+
return typeof sessionId === 'string' && sessionId.trim().length > 0;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Service to handle session management logic for Streamable HTTP transport.
|
|
18
|
+
* Encapsulates creation, restoration, and cleanup of sessions.
|
|
19
|
+
*/
|
|
20
|
+
export class SessionService {
|
|
21
|
+
serverManager;
|
|
22
|
+
sessionRepository;
|
|
23
|
+
asyncOrchestrator;
|
|
24
|
+
constructor(serverManager, sessionRepository, asyncOrchestrator) {
|
|
25
|
+
this.serverManager = serverManager;
|
|
26
|
+
this.sessionRepository = sessionRepository;
|
|
27
|
+
this.asyncOrchestrator = asyncOrchestrator;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Retrieves an existing session transport or tries to restore it.
|
|
31
|
+
*
|
|
32
|
+
* @param sessionId - The session ID to retrieve
|
|
33
|
+
* @returns The transport if found or restored successfully, null otherwise
|
|
34
|
+
*/
|
|
35
|
+
async getSession(sessionId) {
|
|
36
|
+
// Validate sessionId
|
|
37
|
+
if (!isValidSessionId(sessionId)) {
|
|
38
|
+
logger.debug('Invalid sessionId provided to getSession');
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
const existingTransport = this.serverManager.getTransport(sessionId);
|
|
42
|
+
if (existingTransport) {
|
|
43
|
+
// Verify the transport is the correct type for this endpoint
|
|
44
|
+
if (existingTransport instanceof StreamableHTTPServerTransport ||
|
|
45
|
+
existingTransport instanceof RestorableStreamableHTTPServerTransport) {
|
|
46
|
+
// Update last accessed time for active sessions
|
|
47
|
+
this.sessionRepository.updateAccess(sessionId);
|
|
48
|
+
return existingTransport;
|
|
49
|
+
}
|
|
50
|
+
// Transport exists but is wrong type (e.g., STDIO), so it's not usable here
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
// Try to restore from persistent storage
|
|
54
|
+
const result = await this.restoreSession(sessionId);
|
|
55
|
+
return result.transport;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Restores a session from persistent storage.
|
|
59
|
+
*
|
|
60
|
+
* @param sessionId - The session ID to restore
|
|
61
|
+
* @returns SessionRestoreResult with transport or error details
|
|
62
|
+
*/
|
|
63
|
+
async restoreSession(sessionId) {
|
|
64
|
+
try {
|
|
65
|
+
const sessionData = this.sessionRepository.get(sessionId);
|
|
66
|
+
if (!sessionData) {
|
|
67
|
+
logger.debug(`No persisted session found for: ${sessionId}`);
|
|
68
|
+
return { transport: null, errorType: 'not_found' };
|
|
69
|
+
}
|
|
70
|
+
const config = sessionData;
|
|
71
|
+
logger.info(`Restoring streamable session: ${sessionId}`);
|
|
72
|
+
// Create new transport with the original session ID using wrapper class
|
|
73
|
+
const transport = new RestorableStreamableHTTPServerTransport({
|
|
74
|
+
sessionIdGenerator: () => sessionId,
|
|
75
|
+
});
|
|
76
|
+
// Mark the transport as initialized for restored session
|
|
77
|
+
const initResult = transport.markAsInitialized();
|
|
78
|
+
if (!initResult.success) {
|
|
79
|
+
logger.warn(`Failed to mark transport ${sessionId} as initialized: ${initResult.error}`);
|
|
80
|
+
return { transport: null, error: initResult.error, errorType: 'transport_failed' };
|
|
81
|
+
}
|
|
82
|
+
// Set the sessionId for the restored session
|
|
83
|
+
const setSessionResult = transport.setSessionId(sessionId);
|
|
84
|
+
if (!setSessionResult.success) {
|
|
85
|
+
logger.warn(`Failed to set sessionId ${sessionId}: ${setSessionResult.error}`);
|
|
86
|
+
return { transport: null, error: setSessionResult.error, errorType: 'transport_failed' };
|
|
87
|
+
}
|
|
88
|
+
// Convert config context to ContextData format if available
|
|
89
|
+
const context = config.context;
|
|
90
|
+
const contextData = context
|
|
91
|
+
? {
|
|
92
|
+
project: context.project || { name: 'unknown' },
|
|
93
|
+
user: context.user || {},
|
|
94
|
+
environment: context.environment || {},
|
|
95
|
+
timestamp: context.timestamp || new Date().toISOString(),
|
|
96
|
+
sessionId: context.sessionId || sessionId,
|
|
97
|
+
version: context.version || 'unknown',
|
|
98
|
+
transport: context.transport || { type: 'unknown' },
|
|
99
|
+
}
|
|
100
|
+
: undefined;
|
|
101
|
+
// Reconnect with the original configuration and context
|
|
102
|
+
try {
|
|
103
|
+
await this.serverManager.connectTransport(transport, sessionId, config, contextData);
|
|
104
|
+
}
|
|
105
|
+
catch (connectError) {
|
|
106
|
+
const errorMessage = connectError instanceof Error ? connectError.message : String(connectError);
|
|
107
|
+
logger.error(`Failed to connect transport ${sessionId}:`, connectError);
|
|
108
|
+
return { transport: null, error: errorMessage, errorType: 'connection_failed' };
|
|
109
|
+
}
|
|
110
|
+
// Initialize notifications
|
|
111
|
+
this.initializeNotifications(sessionId);
|
|
112
|
+
// Set up handlers
|
|
113
|
+
this.setupTransportHandlers(transport, sessionId);
|
|
114
|
+
// Update last accessed time
|
|
115
|
+
this.sessionRepository.updateAccess(sessionId);
|
|
116
|
+
logger.info(`Successfully restored streamable session: ${sessionId} (restored: ${transport.isRestored()})`);
|
|
117
|
+
return { transport };
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
121
|
+
logger.error(`Failed to restore streamable session ${sessionId}:`, error);
|
|
122
|
+
return { transport: null, error: errorMessage, errorType: 'transport_failed' };
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Creates a new session with the given configuration.
|
|
127
|
+
*
|
|
128
|
+
* @param config - The inbound connection configuration
|
|
129
|
+
* @param context - Optional context data for the session
|
|
130
|
+
* @param providedSessionId - Optional session ID to use instead of generating one
|
|
131
|
+
* @returns SessionCreateResult with transport and persistence status
|
|
132
|
+
* @throws Error if session creation fails (but not if persistence fails)
|
|
133
|
+
*/
|
|
134
|
+
async createSession(config, context, providedSessionId) {
|
|
135
|
+
const sessionId = providedSessionId || AUTH_CONFIG.SERVER.STREAMABLE_SESSION.ID_PREFIX + randomUUID();
|
|
136
|
+
let transport;
|
|
137
|
+
try {
|
|
138
|
+
transport = new StreamableHTTPServerTransport({
|
|
139
|
+
sessionIdGenerator: () => sessionId,
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
catch (error) {
|
|
143
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
144
|
+
logger.error(`Failed to create transport for session ${sessionId}:`, error);
|
|
145
|
+
throw new Error(`Session creation failed: transport initialization error - ${errorMessage}`);
|
|
146
|
+
}
|
|
147
|
+
if (context && context.project?.name && context.sessionId) {
|
|
148
|
+
logger.info(`New session with context: ${context.project.name} (${context.sessionId})${providedSessionId ? ` (ID: ${providedSessionId})` : ''}`);
|
|
149
|
+
}
|
|
150
|
+
// Include full context in config for session persistence
|
|
151
|
+
const configWithContext = {
|
|
152
|
+
...config,
|
|
153
|
+
context: context || undefined,
|
|
154
|
+
};
|
|
155
|
+
// Pass context to ServerManager
|
|
156
|
+
const validContext = context && context.project && context.user && context.environment ? context : undefined;
|
|
157
|
+
try {
|
|
158
|
+
await this.serverManager.connectTransport(transport, sessionId, configWithContext, validContext);
|
|
159
|
+
}
|
|
160
|
+
catch (error) {
|
|
161
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
162
|
+
logger.error(`Failed to connect transport ${sessionId}:`, error);
|
|
163
|
+
throw new Error(`Session creation failed: connection error - ${errorMessage}`);
|
|
164
|
+
}
|
|
165
|
+
// Try to persist session to storage
|
|
166
|
+
let persisted = false;
|
|
167
|
+
let persistenceError;
|
|
168
|
+
try {
|
|
169
|
+
this.sessionRepository.create(sessionId, configWithContext);
|
|
170
|
+
persisted = true;
|
|
171
|
+
}
|
|
172
|
+
catch (error) {
|
|
173
|
+
persistenceError = error instanceof Error ? error.message : String(error);
|
|
174
|
+
logger.warn(`Failed to persist session ${sessionId} to repository: ${persistenceError}`);
|
|
175
|
+
// Continue anyway - transport is connected, just not persisted
|
|
176
|
+
}
|
|
177
|
+
// Initialize notifications
|
|
178
|
+
this.initializeNotifications(sessionId);
|
|
179
|
+
// Set up handlers
|
|
180
|
+
this.setupTransportHandlers(transport, sessionId);
|
|
181
|
+
return { transport, persisted, persistenceError };
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Deletes a session and cleans up resources.
|
|
185
|
+
*
|
|
186
|
+
* @param sessionId - The session ID to delete
|
|
187
|
+
*/
|
|
188
|
+
async deleteSession(sessionId) {
|
|
189
|
+
try {
|
|
190
|
+
this.sessionRepository.delete(sessionId);
|
|
191
|
+
}
|
|
192
|
+
catch (error) {
|
|
193
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
194
|
+
logger.error(`Failed to delete session ${sessionId} from repository: ${errorMessage}`);
|
|
195
|
+
// Consider: should this throw? Or is best-effort deletion acceptable?
|
|
196
|
+
// At minimum, the error is logged for monitoring
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Initializes async loading notifications for a session.
|
|
201
|
+
*
|
|
202
|
+
* This method should be called after connecting a transport to enable
|
|
203
|
+
* the async orchestrator to send capability updates to the client.
|
|
204
|
+
* Only applicable when async loading is enabled.
|
|
205
|
+
*
|
|
206
|
+
* @param sessionId - The session ID to initialize notifications for
|
|
207
|
+
*/
|
|
208
|
+
initializeNotifications(sessionId) {
|
|
209
|
+
if (this.asyncOrchestrator) {
|
|
210
|
+
const inboundConnection = this.serverManager.getServer(sessionId);
|
|
211
|
+
if (inboundConnection) {
|
|
212
|
+
this.asyncOrchestrator.initializeNotifications(inboundConnection);
|
|
213
|
+
logger.debug(`Async loading notifications initialized for Streamable HTTP session ${sessionId}`);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
setupTransportHandlers(transport, sessionId) {
|
|
218
|
+
transport.onclose = () => {
|
|
219
|
+
this.serverManager.disconnectTransport(sessionId);
|
|
220
|
+
this.sessionRepository.delete(sessionId);
|
|
221
|
+
};
|
|
222
|
+
transport.onerror = (error) => {
|
|
223
|
+
logger.error(`Streamable HTTP transport error for session ${sessionId}:`, error);
|
|
224
|
+
const server = this.serverManager.getServer(sessionId);
|
|
225
|
+
if (server) {
|
|
226
|
+
server.status = ServerStatus.Error;
|
|
227
|
+
server.lastError = error instanceof Error ? error : new Error(String(error));
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
//# sourceMappingURL=sessionService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessionService.js","sourceRoot":"","sources":["../../../../src/transport/http/utils/sessionService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAC;AAEnG,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD,OAAO,EAA2B,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACjF,OAAO,MAAM,MAAM,uBAAuB,CAAC;AAC3C,OAAO,EAAE,uCAAuC,EAAE,MAAM,sDAAsD,CAAC;AAuB/G;;;;;GAKG;AACH,SAAS,gBAAgB,CAAC,SAAiB;IACzC,OAAO,OAAO,SAAS,KAAK,QAAQ,IAAI,SAAS,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC;AACtE,CAAC;AAED;;;GAGG;AACH,MAAM,OAAO,cAAc;IAEf;IACA;IACA;IAHV,YACU,aAA4B,EAC5B,iBAA8C,EAC9C,iBAA4C;QAF5C,kBAAa,GAAb,aAAa,CAAe;QAC5B,sBAAiB,GAAjB,iBAAiB,CAA6B;QAC9C,sBAAiB,GAAjB,iBAAiB,CAA2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