@mcp-ts/sdk 1.6.2 → 2.0.0

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.
Files changed (113) hide show
  1. package/README.md +12 -6
  2. package/dist/adapters/agui-adapter.d.mts +3 -3
  3. package/dist/adapters/agui-adapter.d.ts +3 -3
  4. package/dist/adapters/agui-adapter.js +4 -5
  5. package/dist/adapters/agui-adapter.js.map +1 -1
  6. package/dist/adapters/agui-adapter.mjs +4 -5
  7. package/dist/adapters/agui-adapter.mjs.map +1 -1
  8. package/dist/adapters/agui-middleware.d.mts +3 -3
  9. package/dist/adapters/agui-middleware.d.ts +3 -3
  10. package/dist/adapters/ai-adapter.d.mts +9 -3
  11. package/dist/adapters/ai-adapter.d.ts +9 -3
  12. package/dist/adapters/ai-adapter.js +20 -6
  13. package/dist/adapters/ai-adapter.js.map +1 -1
  14. package/dist/adapters/ai-adapter.mjs +20 -6
  15. package/dist/adapters/ai-adapter.mjs.map +1 -1
  16. package/dist/adapters/langchain-adapter.d.mts +3 -3
  17. package/dist/adapters/langchain-adapter.d.ts +3 -3
  18. package/dist/adapters/langchain-adapter.js +9 -6
  19. package/dist/adapters/langchain-adapter.js.map +1 -1
  20. package/dist/adapters/langchain-adapter.mjs +9 -6
  21. package/dist/adapters/langchain-adapter.mjs.map +1 -1
  22. package/dist/adapters/mastra-adapter.d.mts +1 -1
  23. package/dist/adapters/mastra-adapter.d.ts +1 -1
  24. package/dist/adapters/mastra-adapter.js +5 -1
  25. package/dist/adapters/mastra-adapter.js.map +1 -1
  26. package/dist/adapters/mastra-adapter.mjs +5 -1
  27. package/dist/adapters/mastra-adapter.mjs.map +1 -1
  28. package/dist/bin/mcp-ts.js +7 -1
  29. package/dist/bin/mcp-ts.js.map +1 -1
  30. package/dist/bin/mcp-ts.mjs +7 -1
  31. package/dist/bin/mcp-ts.mjs.map +1 -1
  32. package/dist/client/index.d.mts +2 -2
  33. package/dist/client/index.d.ts +2 -2
  34. package/dist/client/index.js +9 -13
  35. package/dist/client/index.js.map +1 -1
  36. package/dist/client/index.mjs +9 -13
  37. package/dist/client/index.mjs.map +1 -1
  38. package/dist/client/react.d.mts +7 -7
  39. package/dist/client/react.d.ts +7 -7
  40. package/dist/client/react.js +15 -19
  41. package/dist/client/react.js.map +1 -1
  42. package/dist/client/react.mjs +15 -19
  43. package/dist/client/react.mjs.map +1 -1
  44. package/dist/client/vue.d.mts +7 -7
  45. package/dist/client/vue.d.ts +7 -7
  46. package/dist/client/vue.js +14 -18
  47. package/dist/client/vue.js.map +1 -1
  48. package/dist/client/vue.mjs +14 -18
  49. package/dist/client/vue.mjs.map +1 -1
  50. package/dist/{index-DhA-OEAe.d.ts → index-C9gvpxy5.d.ts} +5 -5
  51. package/dist/{index-bFL4ZF2N.d.mts → index-eaH14_5u.d.mts} +5 -5
  52. package/dist/index.d.mts +6 -6
  53. package/dist/index.d.ts +6 -6
  54. package/dist/index.js +616 -370
  55. package/dist/index.js.map +1 -1
  56. package/dist/index.mjs +615 -370
  57. package/dist/index.mjs.map +1 -1
  58. package/dist/{multi-session-client-CHE8QpVE.d.ts → multi-session-client-BYtguGJm.d.ts} +22 -22
  59. package/dist/{multi-session-client-CQsRbxYI.d.mts → multi-session-client-DYNe6az3.d.mts} +22 -22
  60. package/dist/server/index.d.mts +31 -34
  61. package/dist/server/index.d.ts +31 -34
  62. package/dist/server/index.js +531 -256
  63. package/dist/server/index.js.map +1 -1
  64. package/dist/server/index.mjs +530 -256
  65. package/dist/server/index.mjs.map +1 -1
  66. package/dist/shared/index.d.mts +5 -5
  67. package/dist/shared/index.d.ts +5 -5
  68. package/dist/shared/index.js +76 -101
  69. package/dist/shared/index.js.map +1 -1
  70. package/dist/shared/index.mjs +76 -101
  71. package/dist/shared/index.mjs.map +1 -1
  72. package/dist/{tool-router-Dh2804tM.d.ts → tool-router-Ddtybmr0.d.ts} +71 -73
  73. package/dist/{tool-router-BVaV1udm.d.mts → tool-router-Dnd6IOKC.d.mts} +71 -73
  74. package/dist/{types-rIuN1CQi.d.mts → types-BCAG20P6.d.mts} +4 -4
  75. package/dist/{types-rIuN1CQi.d.ts → types-BCAG20P6.d.ts} +4 -4
  76. package/dist/{utils-0qmYrqoa.d.mts → utils-DELRKQPU.d.mts} +1 -1
  77. package/dist/{utils-0qmYrqoa.d.ts → utils-DELRKQPU.d.ts} +1 -1
  78. package/migrations/neon/20260513010000_install_mcp_sessions.sql +69 -0
  79. package/migrations/neon/20260513020000_add_session_cleanup_cron.sql +35 -0
  80. package/{supabase/migrations → migrations/supabase}/20260330195700_install_mcp_sessions.sql +7 -9
  81. package/package.json +14 -5
  82. package/src/adapters/ai-adapter.ts +30 -1
  83. package/src/adapters/langchain-adapter.ts +6 -2
  84. package/src/adapters/mastra-adapter.ts +6 -2
  85. package/src/bin/mcp-ts.ts +8 -1
  86. package/src/client/core/app-host.ts +1 -1
  87. package/src/client/core/sse-client.ts +12 -14
  88. package/src/client/core/types.ts +1 -1
  89. package/src/client/react/use-mcp-apps.tsx +1 -1
  90. package/src/client/react/use-mcp.ts +11 -11
  91. package/src/client/vue/use-mcp.ts +10 -10
  92. package/src/server/handlers/nextjs-handler.ts +18 -15
  93. package/src/server/handlers/sse-handler.ts +29 -29
  94. package/src/server/index.ts +1 -1
  95. package/src/server/mcp/multi-session-client.ts +17 -17
  96. package/src/server/mcp/oauth-client.ts +37 -37
  97. package/src/server/mcp/storage-oauth-provider.ts +17 -17
  98. package/src/server/storage/file-backend.ts +25 -25
  99. package/src/server/storage/index.ts +67 -10
  100. package/src/server/storage/memory-backend.ts +34 -34
  101. package/src/server/storage/neon-backend.ts +281 -0
  102. package/src/server/storage/redis-backend.ts +64 -64
  103. package/src/server/storage/sqlite-backend.ts +33 -33
  104. package/src/server/storage/supabase-backend.ts +23 -24
  105. package/src/server/storage/types.ts +18 -21
  106. package/src/shared/errors.ts +1 -1
  107. package/src/shared/index.ts +1 -2
  108. package/src/shared/meta-tools.ts +4 -6
  109. package/src/shared/schema-compressor.ts +2 -42
  110. package/src/shared/tool-index.ts +89 -84
  111. package/src/shared/tool-router.ts +0 -24
  112. package/src/shared/types.ts +4 -4
  113. /package/{supabase/migrations → migrations/supabase}/20260421010000_add_session_cleanup_cron.sql +0 -0
@@ -22,7 +22,7 @@ interface AgentsOAuthProvider extends OAuthClientProvider {
22
22
  setTokenExpiresAt(expiresAt: number): void;
23
23
  }
24
24
  interface StorageOAuthClientProviderOptions {
25
- identity: string;
25
+ userId: string;
26
26
  serverId: string;
27
27
  sessionId: string;
28
28
  redirectUrl: string;
@@ -36,10 +36,10 @@ interface StorageOAuthClientProviderOptions {
36
36
  }
37
37
  /**
38
38
  * Storage-backed OAuth provider implementation for MCP
39
- * Stores OAuth tokens, client information, and PKCE verifiers using the configured StorageBackend
39
+ * Stores OAuth tokens, client information, and PKCE verifiers using the configured SessionStore
40
40
  */
41
41
  declare class StorageOAuthClientProvider implements AgentsOAuthProvider {
42
- readonly identity: string;
42
+ readonly userId: string;
43
43
  readonly serverId: string;
44
44
  readonly sessionId: string;
45
45
  readonly redirectUrl: string;
@@ -53,7 +53,7 @@ declare class StorageOAuthClientProvider implements AgentsOAuthProvider {
53
53
  private onRedirectCallback?;
54
54
  private tokenExpiresAt?;
55
55
  /**
56
- * Creates a new storage-backed OAuth provider
56
+ * Creates a new session-backed OAuth provider
57
57
  * @param options - Provider configuration
58
58
  */
59
59
  constructor(options: StorageOAuthClientProviderOptions);
@@ -61,12 +61,12 @@ declare class StorageOAuthClientProvider implements AgentsOAuthProvider {
61
61
  get clientId(): string | undefined;
62
62
  set clientId(clientId_: string | undefined);
63
63
  /**
64
- * Loads OAuth data from storage session
64
+ * Loads OAuth data from the session store
65
65
  * @private
66
66
  */
67
67
  private getSessionData;
68
68
  /**
69
- * Saves OAuth data to storage
69
+ * Saves OAuth data to the session store
70
70
  * @param data - Partial OAuth data to save
71
71
  * @private
72
72
  * @throws Error if session doesn't exist (session must be created by controller layer)
@@ -105,13 +105,13 @@ declare class StorageOAuthClientProvider implements AgentsOAuthProvider {
105
105
  /**
106
106
  * Supported MCP transport types
107
107
  */
108
- type TransportType = 'sse' | 'streamable_http';
108
+ type TransportType = 'sse' | 'streamable-http';
109
109
  interface MCPOAuthClientOptions {
110
110
  serverUrl?: string;
111
111
  serverName?: string;
112
112
  callbackUrl?: string;
113
113
  onRedirect?: (url: string) => void;
114
- identity: string;
114
+ userId: string;
115
115
  serverId?: string; /** Optional - loaded from session if not provided */
116
116
  sessionId: string; /** Required - primary key for session lookup */
117
117
  transportType?: TransportType;
@@ -133,7 +133,7 @@ declare class MCPClient {
133
133
  private client;
134
134
  oauthProvider: AgentsOAuthProvider | null;
135
135
  private transport;
136
- private identity;
136
+ private userId;
137
137
  private serverId?;
138
138
  private sessionId;
139
139
  private serverName?;
@@ -158,7 +158,7 @@ declare class MCPClient {
158
158
  private currentState;
159
159
  /**
160
160
  * Creates a new MCP client instance
161
- * Can be initialized with minimal options (identity + sessionId) for session restoration
161
+ * Can be initialized with minimal options (userId + sessionId) for session restoration
162
162
  * @param options - Client configuration options
163
163
  */
164
164
  constructor(options: MCPOAuthClientOptions);
@@ -196,7 +196,7 @@ declare class MCPClient {
196
196
  */
197
197
  private initialize;
198
198
  /**
199
- * Saves current session state to storage
199
+ * Saves current session state to the session store
200
200
  * Creates new session if it doesn't exist, updates if it does
201
201
  * @param ttl - Time-to-live in seconds (defaults to 12hr for connected sessions)
202
202
  * @param active - Session status marker used to avoid unnecessary TTL rewrites
@@ -316,7 +316,7 @@ declare class MCPClient {
316
316
  getCallbackUrl(): string;
317
317
  /**
318
318
  * Gets the transport type being used
319
- * @returns Transport type (defaults to 'streamable_http')
319
+ * @returns Transport type (defaults to 'streamable-http')
320
320
  */
321
321
  getTransportType(): TransportType;
322
322
  /**
@@ -338,15 +338,15 @@ declare class MCPClient {
338
338
  * Gets MCP server configuration for all active user sessions
339
339
  * Loads sessions from Redis, validates OAuth tokens, refreshes if expired
340
340
  * Returns ready-to-use configuration with valid auth headers
341
- * @param identity - User ID to fetch sessions for
341
+ * @param userId - User ID to fetch sessions for
342
342
  * @returns Object keyed by sanitized server labels containing transport, url, headers, etc.
343
343
  * @static
344
344
  */
345
- static getMcpServerConfig(identity: string): Promise<Record<string, any>>;
345
+ static getMcpServerConfig(userId: string): Promise<Record<string, any>>;
346
346
  }
347
347
 
348
348
  /**
349
- * Manages multiple MCP connections for a single user identity.
349
+ * Manages multiple MCP connections for a single user.
350
350
  * Allows aggregating tools from all connected servers.
351
351
  */
352
352
  interface MultiSessionOptions {
@@ -367,7 +367,7 @@ interface MultiSessionOptions {
367
367
  retryDelay?: number;
368
368
  }
369
369
  /**
370
- * Manages multiple MCP client connections for a single user identity.
370
+ * Manages multiple MCP client connections for a single user.
371
371
  *
372
372
  * On a traditional long-running server, you can cache this instance per user
373
373
  * so the connections stay alive between requests. On serverless, a new instance
@@ -376,18 +376,18 @@ interface MultiSessionOptions {
376
376
  */
377
377
  declare class MultiSessionClient {
378
378
  private clients;
379
- private identity;
379
+ private userId;
380
380
  private options;
381
381
  /**
382
- * Creates a new MultiSessionClient for the given user identity.
382
+ * Creates a new MultiSessionClient for the given user userId.
383
383
  *
384
- * @param identity - A unique string identifying the user (e.g. user ID or email).
384
+ * @param userId - A unique string identifying the user (e.g. user ID or email).
385
385
  * @param options - Optional tuning for connection timeout, retry count, and retry delay.
386
386
  * Falls back to sensible defaults if not provided.
387
387
  */
388
- constructor(identity: string, options?: MultiSessionOptions);
388
+ constructor(userId: string, options?: MultiSessionOptions);
389
389
  /**
390
- * Fetches all sessions for this identity from storage and returns only the
390
+ * Fetches all sessions for this userId from storage and returns only the
391
391
  * ones that are ready to connect.
392
392
  *
393
393
  * A session is considered connectable when:
@@ -436,7 +436,7 @@ declare class MultiSessionClient {
436
436
  */
437
437
  private establishConnectionWithRetries;
438
438
  /**
439
- * The main entry point. Fetches all active sessions for this identity from
439
+ * The main entry point. Fetches all active sessions for this userId from
440
440
  * storage and establishes connections to all of them in batches.
441
441
  *
442
442
  * Call this once after creating the client. On traditional servers, you can
@@ -22,7 +22,7 @@ interface AgentsOAuthProvider extends OAuthClientProvider {
22
22
  setTokenExpiresAt(expiresAt: number): void;
23
23
  }
24
24
  interface StorageOAuthClientProviderOptions {
25
- identity: string;
25
+ userId: string;
26
26
  serverId: string;
27
27
  sessionId: string;
28
28
  redirectUrl: string;
@@ -36,10 +36,10 @@ interface StorageOAuthClientProviderOptions {
36
36
  }
37
37
  /**
38
38
  * Storage-backed OAuth provider implementation for MCP
39
- * Stores OAuth tokens, client information, and PKCE verifiers using the configured StorageBackend
39
+ * Stores OAuth tokens, client information, and PKCE verifiers using the configured SessionStore
40
40
  */
41
41
  declare class StorageOAuthClientProvider implements AgentsOAuthProvider {
42
- readonly identity: string;
42
+ readonly userId: string;
43
43
  readonly serverId: string;
44
44
  readonly sessionId: string;
45
45
  readonly redirectUrl: string;
@@ -53,7 +53,7 @@ declare class StorageOAuthClientProvider implements AgentsOAuthProvider {
53
53
  private onRedirectCallback?;
54
54
  private tokenExpiresAt?;
55
55
  /**
56
- * Creates a new storage-backed OAuth provider
56
+ * Creates a new session-backed OAuth provider
57
57
  * @param options - Provider configuration
58
58
  */
59
59
  constructor(options: StorageOAuthClientProviderOptions);
@@ -61,12 +61,12 @@ declare class StorageOAuthClientProvider implements AgentsOAuthProvider {
61
61
  get clientId(): string | undefined;
62
62
  set clientId(clientId_: string | undefined);
63
63
  /**
64
- * Loads OAuth data from storage session
64
+ * Loads OAuth data from the session store
65
65
  * @private
66
66
  */
67
67
  private getSessionData;
68
68
  /**
69
- * Saves OAuth data to storage
69
+ * Saves OAuth data to the session store
70
70
  * @param data - Partial OAuth data to save
71
71
  * @private
72
72
  * @throws Error if session doesn't exist (session must be created by controller layer)
@@ -105,13 +105,13 @@ declare class StorageOAuthClientProvider implements AgentsOAuthProvider {
105
105
  /**
106
106
  * Supported MCP transport types
107
107
  */
108
- type TransportType = 'sse' | 'streamable_http';
108
+ type TransportType = 'sse' | 'streamable-http';
109
109
  interface MCPOAuthClientOptions {
110
110
  serverUrl?: string;
111
111
  serverName?: string;
112
112
  callbackUrl?: string;
113
113
  onRedirect?: (url: string) => void;
114
- identity: string;
114
+ userId: string;
115
115
  serverId?: string; /** Optional - loaded from session if not provided */
116
116
  sessionId: string; /** Required - primary key for session lookup */
117
117
  transportType?: TransportType;
@@ -133,7 +133,7 @@ declare class MCPClient {
133
133
  private client;
134
134
  oauthProvider: AgentsOAuthProvider | null;
135
135
  private transport;
136
- private identity;
136
+ private userId;
137
137
  private serverId?;
138
138
  private sessionId;
139
139
  private serverName?;
@@ -158,7 +158,7 @@ declare class MCPClient {
158
158
  private currentState;
159
159
  /**
160
160
  * Creates a new MCP client instance
161
- * Can be initialized with minimal options (identity + sessionId) for session restoration
161
+ * Can be initialized with minimal options (userId + sessionId) for session restoration
162
162
  * @param options - Client configuration options
163
163
  */
164
164
  constructor(options: MCPOAuthClientOptions);
@@ -196,7 +196,7 @@ declare class MCPClient {
196
196
  */
197
197
  private initialize;
198
198
  /**
199
- * Saves current session state to storage
199
+ * Saves current session state to the session store
200
200
  * Creates new session if it doesn't exist, updates if it does
201
201
  * @param ttl - Time-to-live in seconds (defaults to 12hr for connected sessions)
202
202
  * @param active - Session status marker used to avoid unnecessary TTL rewrites
@@ -316,7 +316,7 @@ declare class MCPClient {
316
316
  getCallbackUrl(): string;
317
317
  /**
318
318
  * Gets the transport type being used
319
- * @returns Transport type (defaults to 'streamable_http')
319
+ * @returns Transport type (defaults to 'streamable-http')
320
320
  */
321
321
  getTransportType(): TransportType;
322
322
  /**
@@ -338,15 +338,15 @@ declare class MCPClient {
338
338
  * Gets MCP server configuration for all active user sessions
339
339
  * Loads sessions from Redis, validates OAuth tokens, refreshes if expired
340
340
  * Returns ready-to-use configuration with valid auth headers
341
- * @param identity - User ID to fetch sessions for
341
+ * @param userId - User ID to fetch sessions for
342
342
  * @returns Object keyed by sanitized server labels containing transport, url, headers, etc.
343
343
  * @static
344
344
  */
345
- static getMcpServerConfig(identity: string): Promise<Record<string, any>>;
345
+ static getMcpServerConfig(userId: string): Promise<Record<string, any>>;
346
346
  }
347
347
 
348
348
  /**
349
- * Manages multiple MCP connections for a single user identity.
349
+ * Manages multiple MCP connections for a single user.
350
350
  * Allows aggregating tools from all connected servers.
351
351
  */
352
352
  interface MultiSessionOptions {
@@ -367,7 +367,7 @@ interface MultiSessionOptions {
367
367
  retryDelay?: number;
368
368
  }
369
369
  /**
370
- * Manages multiple MCP client connections for a single user identity.
370
+ * Manages multiple MCP client connections for a single user.
371
371
  *
372
372
  * On a traditional long-running server, you can cache this instance per user
373
373
  * so the connections stay alive between requests. On serverless, a new instance
@@ -376,18 +376,18 @@ interface MultiSessionOptions {
376
376
  */
377
377
  declare class MultiSessionClient {
378
378
  private clients;
379
- private identity;
379
+ private userId;
380
380
  private options;
381
381
  /**
382
- * Creates a new MultiSessionClient for the given user identity.
382
+ * Creates a new MultiSessionClient for the given user userId.
383
383
  *
384
- * @param identity - A unique string identifying the user (e.g. user ID or email).
384
+ * @param userId - A unique string identifying the user (e.g. user ID or email).
385
385
  * @param options - Optional tuning for connection timeout, retry count, and retry delay.
386
386
  * Falls back to sensible defaults if not provided.
387
387
  */
388
- constructor(identity: string, options?: MultiSessionOptions);
388
+ constructor(userId: string, options?: MultiSessionOptions);
389
389
  /**
390
- * Fetches all sessions for this identity from storage and returns only the
390
+ * Fetches all sessions for this userId from storage and returns only the
391
391
  * ones that are ready to connect.
392
392
  *
393
393
  * A session is considered connectable when:
@@ -436,7 +436,7 @@ declare class MultiSessionClient {
436
436
  */
437
437
  private establishConnectionWithRetries;
438
438
  /**
439
- * The main entry point. Fetches all active sessions for this identity from
439
+ * The main entry point. Fetches all active sessions for this userId from
440
440
  * storage and establishes connections to all of them in batches.
441
441
  *
442
442
  * Call this once after creating the client. On traditional servers, you can
@@ -1,23 +1,23 @@
1
- export { M as MCPClient, a as MultiSessionClient, S as StorageOAuthClientProvider } from '../multi-session-client-CQsRbxYI.mjs';
2
- export { U as UnauthorizedError, s as sanitizeServerLabel } from '../utils-0qmYrqoa.mjs';
1
+ export { M as MCPClient, a as MultiSessionClient, S as StorageOAuthClientProvider } from '../multi-session-client-DYNe6az3.mjs';
2
+ export { U as UnauthorizedError, s as sanitizeServerLabel } from '../utils-DELRKQPU.mjs';
3
3
  import { OAuthClientInformationMixed, OAuthTokens } from '@modelcontextprotocol/sdk/shared/auth.js';
4
4
  export { OAuthClientInformation, OAuthClientInformationFull, OAuthClientMetadata, OAuthTokens } from '@modelcontextprotocol/sdk/shared/auth.js';
5
5
  import { M as McpConnectionEvent, d as McpObservabilityEvent } from '../events-CK3N--3g.mjs';
6
6
  export { D as Disposable, E as Emitter, b as Event, c as McpConnectionState } from '../events-CK3N--3g.mjs';
7
- import { q as McpRpcResponse, p as McpRpcRequest } from '../types-rIuN1CQi.mjs';
8
- export { a as CallToolRequest, b as CallToolResponse, f as ConnectRequest, g as ConnectResponse, m as ListToolsResponse, T as ToolClient, u as ToolClientProvider, v as ToolInfo } from '../types-rIuN1CQi.mjs';
7
+ import { r as McpRpcResponse, q as McpRpcRequest } from '../types-BCAG20P6.mjs';
8
+ export { a as CallToolRequest, b as CallToolResponse, f as ConnectRequest, g as ConnectResponse, n as ListToolsResponse, T as ToolClient, u as ToolClientProvider, v as ToolInfo } from '../types-BCAG20P6.mjs';
9
9
  export { CallToolResult, ListToolsResult, Tool } from '@modelcontextprotocol/sdk/types.js';
10
10
  import '@modelcontextprotocol/sdk/client/auth.js';
11
11
 
12
- interface SessionData {
12
+ interface Session {
13
13
  sessionId: string;
14
14
  serverId?: string;
15
15
  serverName?: string;
16
16
  serverUrl: string;
17
- transportType: 'sse' | 'streamable_http';
17
+ transportType: 'sse' | 'streamable-http';
18
18
  callbackUrl: string;
19
19
  createdAt: number;
20
- identity: string;
20
+ userId: string;
21
21
  headers?: Record<string, string>;
22
22
  /**
23
23
  * Session status marker used for TTL transitions:
@@ -32,9 +32,9 @@ interface SessionData {
32
32
  clientId?: string;
33
33
  }
34
34
  /**
35
- * Interface for MCP Session Storage Backends
35
+ * Interface for MCP session stores.
36
36
  */
37
- interface StorageBackend {
37
+ interface SessionStore {
38
38
  /**
39
39
  * Optional initialization (e.g., database connection)
40
40
  */
@@ -43,43 +43,40 @@ interface StorageBackend {
43
43
  * Generates a unique session ID
44
44
  */
45
45
  generateSessionId(): string;
46
- /**
47
- * Stores or updates a session
48
- */
49
46
  /**
50
47
  * Creates a new session. Throws if session already exists.
51
48
  * @param session - Session data to create
52
49
  * @param ttl - Optional TTL in seconds (defaults to backend's default)
53
50
  */
54
- createSession(session: SessionData, ttl?: number): Promise<void>;
51
+ create(session: Session, ttl?: number): Promise<void>;
55
52
  /**
56
53
  * Updates an existing session with partial data. Throws if session does not exist.
57
- * @param identity - User identity
54
+ * @param userId - User identifier
58
55
  * @param sessionId - Session identifier
59
56
  * @param data - Partial session data to update
60
57
  * @param ttl - Optional TTL in seconds (defaults to backend's default)
61
58
  */
62
- updateSession(identity: string, sessionId: string, data: Partial<SessionData>, ttl?: number): Promise<void>;
59
+ update(userId: string, sessionId: string, data: Partial<Session>, ttl?: number): Promise<void>;
63
60
  /**
64
61
  * Retrieves a session
65
62
  */
66
- getSession(identity: string, sessionId: string): Promise<SessionData | null>;
63
+ get(userId: string, sessionId: string): Promise<Session | null>;
67
64
  /**
68
- * Gets full session data for all of an identity's sessions
65
+ * Gets full session data for all sessions owned by a user
69
66
  */
70
- getIdentitySessionsData(identity: string): Promise<SessionData[]>;
67
+ list(userId: string): Promise<Session[]>;
71
68
  /**
72
69
  * Removes a session
73
70
  */
74
- removeSession(identity: string, sessionId: string): Promise<void>;
71
+ delete(userId: string, sessionId: string): Promise<void>;
75
72
  /**
76
- * Gets all sessions IDs of an identity
73
+ * Gets all session IDs owned by a user
77
74
  */
78
- getIdentityMcpSessions(identity: string): Promise<string[]>;
75
+ listIds(userId: string): Promise<string[]>;
79
76
  /**
80
77
  * Gets all session IDs across all users (Admin)
81
78
  */
82
- getAllSessionIds(): Promise<string[]>;
79
+ listAllIds(): Promise<string[]>;
83
80
  /**
84
81
  * Clears all sessions (Admin)
85
82
  */
@@ -87,7 +84,7 @@ interface StorageBackend {
87
84
  /**
88
85
  * Clean up expired sessions
89
86
  */
90
- cleanupExpiredSessions(): Promise<void>;
87
+ cleanupExpired(): Promise<void>;
91
88
  /**
92
89
  * Disconnect from storage backend
93
90
  */
@@ -98,7 +95,7 @@ interface StorageBackend {
98
95
  * Global session store instance
99
96
  * Uses lazy initialization with a Proxy to handle async setup transparently
100
97
  */
101
- declare const storage: StorageBackend;
98
+ declare const sessions: SessionStore;
102
99
 
103
100
  /**
104
101
  * SSE (Server-Sent Events) Handler for MCP Connections
@@ -122,9 +119,9 @@ interface ClientMetadata {
122
119
  }
123
120
  interface SSEHandlerOptions {
124
121
  /** User/Client identifier */
125
- identity: string;
122
+ userId: string;
126
123
  /** Optional callback for authentication/authorization */
127
- onAuth?: (identity: string) => Promise<boolean>;
124
+ onAuth?: (userId: string) => Promise<boolean>;
128
125
  /** Heartbeat interval in milliseconds @default 30000 */
129
126
  heartbeatInterval?: number;
130
127
  /** Static OAuth client metadata defaults (for all connections) */
@@ -139,7 +136,7 @@ interface SSEHandlerOptions {
139
136
  declare class SSEConnectionManager {
140
137
  private readonly options;
141
138
  private readonly sendEvent;
142
- private readonly identity;
139
+ private readonly userId;
143
140
  private readonly clients;
144
141
  private heartbeatTimer?;
145
142
  private isActive;
@@ -158,9 +155,9 @@ declare class SSEConnectionManager {
158
155
  */
159
156
  handleRequest(request: McpRpcRequest): Promise<McpRpcResponse>;
160
157
  /**
161
- * Get all sessions for the current identity
158
+ * Get all sessions for the current userId
162
159
  */
163
- private getSessions;
160
+ private listSessions;
164
161
  /**
165
162
  * Connect to an MCP server
166
163
  */
@@ -184,7 +181,7 @@ declare class SSEConnectionManager {
184
181
  /**
185
182
  * Restore and validate an existing session
186
183
  */
187
- private restoreSession;
184
+ private getSession;
188
185
  /**
189
186
  * Complete OAuth authorization flow
190
187
  */
@@ -235,9 +232,9 @@ declare function createSSEHandler(options: SSEHandlerOptions): (req: {
235
232
 
236
233
  interface NextMcpHandlerOptions {
237
234
  /**
238
- * Extract identity from request (default: from 'identity' query param)
235
+ * Extract userId from request (default: from 'userId' query param)
239
236
  */
240
- getIdentity?: (request: Request) => string | null;
237
+ getUserId?: (request: Request) => string | null;
241
238
  /**
242
239
  * Extract auth token from request (default: from 'token' query param or Authorization header)
243
240
  */
@@ -246,7 +243,7 @@ interface NextMcpHandlerOptions {
246
243
  * Authenticate user and verify access (optional)
247
244
  * Return true if user is authenticated, false otherwise
248
245
  */
249
- authenticate?: (identity: string, token: string | null) => Promise<boolean> | boolean;
246
+ authenticate?: (userId: string, token: string | null) => Promise<boolean> | boolean;
250
247
  /**
251
248
  * Heartbeat interval in milliseconds (default: 30000)
252
249
  */
@@ -265,4 +262,4 @@ declare function createNextMcpHandler(options?: NextMcpHandlerOptions): {
265
262
  POST: (request: Request) => Promise<Response>;
266
263
  };
267
264
 
268
- export { type ClientMetadata, McpConnectionEvent, McpObservabilityEvent, McpRpcRequest, McpRpcResponse, type NextMcpHandlerOptions, SSEConnectionManager, type SSEHandlerOptions, type StorageBackend, createNextMcpHandler, createSSEHandler, storage };
265
+ export { type ClientMetadata, McpConnectionEvent, McpObservabilityEvent, McpRpcRequest, McpRpcResponse, type NextMcpHandlerOptions, SSEConnectionManager, type SSEHandlerOptions, type SessionStore, createNextMcpHandler, createSSEHandler, sessions };
@@ -1,23 +1,23 @@
1
- export { M as MCPClient, a as MultiSessionClient, S as StorageOAuthClientProvider } from '../multi-session-client-CHE8QpVE.js';
2
- export { U as UnauthorizedError, s as sanitizeServerLabel } from '../utils-0qmYrqoa.js';
1
+ export { M as MCPClient, a as MultiSessionClient, S as StorageOAuthClientProvider } from '../multi-session-client-BYtguGJm.js';
2
+ export { U as UnauthorizedError, s as sanitizeServerLabel } from '../utils-DELRKQPU.js';
3
3
  import { OAuthClientInformationMixed, OAuthTokens } from '@modelcontextprotocol/sdk/shared/auth.js';
4
4
  export { OAuthClientInformation, OAuthClientInformationFull, OAuthClientMetadata, OAuthTokens } from '@modelcontextprotocol/sdk/shared/auth.js';
5
5
  import { M as McpConnectionEvent, d as McpObservabilityEvent } from '../events-CK3N--3g.js';
6
6
  export { D as Disposable, E as Emitter, b as Event, c as McpConnectionState } from '../events-CK3N--3g.js';
7
- import { q as McpRpcResponse, p as McpRpcRequest } from '../types-rIuN1CQi.js';
8
- export { a as CallToolRequest, b as CallToolResponse, f as ConnectRequest, g as ConnectResponse, m as ListToolsResponse, T as ToolClient, u as ToolClientProvider, v as ToolInfo } from '../types-rIuN1CQi.js';
7
+ import { r as McpRpcResponse, q as McpRpcRequest } from '../types-BCAG20P6.js';
8
+ export { a as CallToolRequest, b as CallToolResponse, f as ConnectRequest, g as ConnectResponse, n as ListToolsResponse, T as ToolClient, u as ToolClientProvider, v as ToolInfo } from '../types-BCAG20P6.js';
9
9
  export { CallToolResult, ListToolsResult, Tool } from '@modelcontextprotocol/sdk/types.js';
10
10
  import '@modelcontextprotocol/sdk/client/auth.js';
11
11
 
12
- interface SessionData {
12
+ interface Session {
13
13
  sessionId: string;
14
14
  serverId?: string;
15
15
  serverName?: string;
16
16
  serverUrl: string;
17
- transportType: 'sse' | 'streamable_http';
17
+ transportType: 'sse' | 'streamable-http';
18
18
  callbackUrl: string;
19
19
  createdAt: number;
20
- identity: string;
20
+ userId: string;
21
21
  headers?: Record<string, string>;
22
22
  /**
23
23
  * Session status marker used for TTL transitions:
@@ -32,9 +32,9 @@ interface SessionData {
32
32
  clientId?: string;
33
33
  }
34
34
  /**
35
- * Interface for MCP Session Storage Backends
35
+ * Interface for MCP session stores.
36
36
  */
37
- interface StorageBackend {
37
+ interface SessionStore {
38
38
  /**
39
39
  * Optional initialization (e.g., database connection)
40
40
  */
@@ -43,43 +43,40 @@ interface StorageBackend {
43
43
  * Generates a unique session ID
44
44
  */
45
45
  generateSessionId(): string;
46
- /**
47
- * Stores or updates a session
48
- */
49
46
  /**
50
47
  * Creates a new session. Throws if session already exists.
51
48
  * @param session - Session data to create
52
49
  * @param ttl - Optional TTL in seconds (defaults to backend's default)
53
50
  */
54
- createSession(session: SessionData, ttl?: number): Promise<void>;
51
+ create(session: Session, ttl?: number): Promise<void>;
55
52
  /**
56
53
  * Updates an existing session with partial data. Throws if session does not exist.
57
- * @param identity - User identity
54
+ * @param userId - User identifier
58
55
  * @param sessionId - Session identifier
59
56
  * @param data - Partial session data to update
60
57
  * @param ttl - Optional TTL in seconds (defaults to backend's default)
61
58
  */
62
- updateSession(identity: string, sessionId: string, data: Partial<SessionData>, ttl?: number): Promise<void>;
59
+ update(userId: string, sessionId: string, data: Partial<Session>, ttl?: number): Promise<void>;
63
60
  /**
64
61
  * Retrieves a session
65
62
  */
66
- getSession(identity: string, sessionId: string): Promise<SessionData | null>;
63
+ get(userId: string, sessionId: string): Promise<Session | null>;
67
64
  /**
68
- * Gets full session data for all of an identity's sessions
65
+ * Gets full session data for all sessions owned by a user
69
66
  */
70
- getIdentitySessionsData(identity: string): Promise<SessionData[]>;
67
+ list(userId: string): Promise<Session[]>;
71
68
  /**
72
69
  * Removes a session
73
70
  */
74
- removeSession(identity: string, sessionId: string): Promise<void>;
71
+ delete(userId: string, sessionId: string): Promise<void>;
75
72
  /**
76
- * Gets all sessions IDs of an identity
73
+ * Gets all session IDs owned by a user
77
74
  */
78
- getIdentityMcpSessions(identity: string): Promise<string[]>;
75
+ listIds(userId: string): Promise<string[]>;
79
76
  /**
80
77
  * Gets all session IDs across all users (Admin)
81
78
  */
82
- getAllSessionIds(): Promise<string[]>;
79
+ listAllIds(): Promise<string[]>;
83
80
  /**
84
81
  * Clears all sessions (Admin)
85
82
  */
@@ -87,7 +84,7 @@ interface StorageBackend {
87
84
  /**
88
85
  * Clean up expired sessions
89
86
  */
90
- cleanupExpiredSessions(): Promise<void>;
87
+ cleanupExpired(): Promise<void>;
91
88
  /**
92
89
  * Disconnect from storage backend
93
90
  */
@@ -98,7 +95,7 @@ interface StorageBackend {
98
95
  * Global session store instance
99
96
  * Uses lazy initialization with a Proxy to handle async setup transparently
100
97
  */
101
- declare const storage: StorageBackend;
98
+ declare const sessions: SessionStore;
102
99
 
103
100
  /**
104
101
  * SSE (Server-Sent Events) Handler for MCP Connections
@@ -122,9 +119,9 @@ interface ClientMetadata {
122
119
  }
123
120
  interface SSEHandlerOptions {
124
121
  /** User/Client identifier */
125
- identity: string;
122
+ userId: string;
126
123
  /** Optional callback for authentication/authorization */
127
- onAuth?: (identity: string) => Promise<boolean>;
124
+ onAuth?: (userId: string) => Promise<boolean>;
128
125
  /** Heartbeat interval in milliseconds @default 30000 */
129
126
  heartbeatInterval?: number;
130
127
  /** Static OAuth client metadata defaults (for all connections) */
@@ -139,7 +136,7 @@ interface SSEHandlerOptions {
139
136
  declare class SSEConnectionManager {
140
137
  private readonly options;
141
138
  private readonly sendEvent;
142
- private readonly identity;
139
+ private readonly userId;
143
140
  private readonly clients;
144
141
  private heartbeatTimer?;
145
142
  private isActive;
@@ -158,9 +155,9 @@ declare class SSEConnectionManager {
158
155
  */
159
156
  handleRequest(request: McpRpcRequest): Promise<McpRpcResponse>;
160
157
  /**
161
- * Get all sessions for the current identity
158
+ * Get all sessions for the current userId
162
159
  */
163
- private getSessions;
160
+ private listSessions;
164
161
  /**
165
162
  * Connect to an MCP server
166
163
  */
@@ -184,7 +181,7 @@ declare class SSEConnectionManager {
184
181
  /**
185
182
  * Restore and validate an existing session
186
183
  */
187
- private restoreSession;
184
+ private getSession;
188
185
  /**
189
186
  * Complete OAuth authorization flow
190
187
  */
@@ -235,9 +232,9 @@ declare function createSSEHandler(options: SSEHandlerOptions): (req: {
235
232
 
236
233
  interface NextMcpHandlerOptions {
237
234
  /**
238
- * Extract identity from request (default: from 'identity' query param)
235
+ * Extract userId from request (default: from 'userId' query param)
239
236
  */
240
- getIdentity?: (request: Request) => string | null;
237
+ getUserId?: (request: Request) => string | null;
241
238
  /**
242
239
  * Extract auth token from request (default: from 'token' query param or Authorization header)
243
240
  */
@@ -246,7 +243,7 @@ interface NextMcpHandlerOptions {
246
243
  * Authenticate user and verify access (optional)
247
244
  * Return true if user is authenticated, false otherwise
248
245
  */
249
- authenticate?: (identity: string, token: string | null) => Promise<boolean> | boolean;
246
+ authenticate?: (userId: string, token: string | null) => Promise<boolean> | boolean;
250
247
  /**
251
248
  * Heartbeat interval in milliseconds (default: 30000)
252
249
  */
@@ -265,4 +262,4 @@ declare function createNextMcpHandler(options?: NextMcpHandlerOptions): {
265
262
  POST: (request: Request) => Promise<Response>;
266
263
  };
267
264
 
268
- export { type ClientMetadata, McpConnectionEvent, McpObservabilityEvent, McpRpcRequest, McpRpcResponse, type NextMcpHandlerOptions, SSEConnectionManager, type SSEHandlerOptions, type StorageBackend, createNextMcpHandler, createSSEHandler, storage };
265
+ export { type ClientMetadata, McpConnectionEvent, McpObservabilityEvent, McpRpcRequest, McpRpcResponse, type NextMcpHandlerOptions, SSEConnectionManager, type SSEHandlerOptions, type SessionStore, createNextMcpHandler, createSSEHandler, sessions };