@mcp-ts/sdk 1.3.4 → 1.3.5

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 (58) hide show
  1. package/README.md +404 -400
  2. package/dist/adapters/agui-adapter.d.mts +1 -1
  3. package/dist/adapters/agui-adapter.d.ts +1 -1
  4. package/dist/adapters/agui-middleware.d.mts +1 -1
  5. package/dist/adapters/agui-middleware.d.ts +1 -1
  6. package/dist/adapters/ai-adapter.d.mts +1 -1
  7. package/dist/adapters/ai-adapter.d.ts +1 -1
  8. package/dist/adapters/langchain-adapter.d.mts +1 -1
  9. package/dist/adapters/langchain-adapter.d.ts +1 -1
  10. package/dist/adapters/mastra-adapter.d.mts +1 -1
  11. package/dist/adapters/mastra-adapter.d.ts +1 -1
  12. package/dist/client/index.d.mts +1 -0
  13. package/dist/client/index.d.ts +1 -0
  14. package/dist/client/index.js +14 -5
  15. package/dist/client/index.js.map +1 -1
  16. package/dist/client/index.mjs +14 -5
  17. package/dist/client/index.mjs.map +1 -1
  18. package/dist/client/react.js +15 -6
  19. package/dist/client/react.js.map +1 -1
  20. package/dist/client/react.mjs +15 -6
  21. package/dist/client/react.mjs.map +1 -1
  22. package/dist/client/vue.js +15 -6
  23. package/dist/client/vue.js.map +1 -1
  24. package/dist/client/vue.mjs +15 -6
  25. package/dist/client/vue.mjs.map +1 -1
  26. package/dist/index.d.mts +1 -1
  27. package/dist/index.d.ts +1 -1
  28. package/dist/index.js +201 -158
  29. package/dist/index.js.map +1 -1
  30. package/dist/index.mjs +201 -158
  31. package/dist/index.mjs.map +1 -1
  32. package/dist/{multi-session-client-FAFpUzZ4.d.ts → multi-session-client-BYLarghq.d.ts} +29 -19
  33. package/dist/{multi-session-client-DzjmT7FX.d.mts → multi-session-client-CzhMkE0k.d.mts} +29 -19
  34. package/dist/server/index.d.mts +1 -1
  35. package/dist/server/index.d.ts +1 -1
  36. package/dist/server/index.js +193 -151
  37. package/dist/server/index.js.map +1 -1
  38. package/dist/server/index.mjs +193 -151
  39. package/dist/server/index.mjs.map +1 -1
  40. package/dist/shared/index.d.mts +2 -2
  41. package/dist/shared/index.d.ts +2 -2
  42. package/dist/shared/index.js +2 -2
  43. package/dist/shared/index.js.map +1 -1
  44. package/dist/shared/index.mjs +2 -2
  45. package/dist/shared/index.mjs.map +1 -1
  46. package/package.json +1 -1
  47. package/src/client/core/sse-client.ts +371 -354
  48. package/src/client/react/use-mcp.ts +31 -31
  49. package/src/client/vue/use-mcp.ts +77 -77
  50. package/src/server/handlers/nextjs-handler.ts +194 -197
  51. package/src/server/handlers/sse-handler.ts +62 -111
  52. package/src/server/mcp/oauth-client.ts +67 -79
  53. package/src/server/mcp/storage-oauth-provider.ts +71 -38
  54. package/src/server/storage/index.ts +15 -13
  55. package/src/server/storage/redis-backend.ts +93 -23
  56. package/src/server/storage/types.ts +12 -12
  57. package/src/shared/constants.ts +2 -2
  58. package/src/shared/event-routing.ts +28 -0
@@ -1,7 +1,7 @@
1
1
  import { b as Event, M as McpConnectionEvent, d as McpObservabilityEvent, c as McpConnectionState } from './events-CK3N--3g.js';
2
2
  import { ListToolsResult, CallToolResult, ListPromptsResult, GetPromptResult, ListResourcesResult, ReadResourceResult } from '@modelcontextprotocol/sdk/types.js';
3
3
  import { OAuthClientProvider } from '@modelcontextprotocol/sdk/client/auth.js';
4
- import { OAuthClientMetadata, OAuthClientInformation, OAuthClientInformationFull, OAuthTokens } from '@modelcontextprotocol/sdk/shared/auth.js';
4
+ import { OAuthClientMetadata, OAuthClientInformationMixed, OAuthClientInformationFull, OAuthTokens } from '@modelcontextprotocol/sdk/shared/auth.js';
5
5
 
6
6
  /**
7
7
  * Extension of OAuthClientProvider interface with additional methods
@@ -21,33 +21,43 @@ interface AgentsOAuthProvider extends OAuthClientProvider {
21
21
  isTokenExpired(): boolean;
22
22
  setTokenExpiresAt(expiresAt: number): void;
23
23
  }
24
+ interface StorageOAuthClientProviderOptions {
25
+ identity: string;
26
+ serverId: string;
27
+ sessionId: string;
28
+ redirectUrl: string;
29
+ clientName?: string;
30
+ clientUri?: string;
31
+ logoUri?: string;
32
+ policyUri?: string;
33
+ clientId?: string;
34
+ clientSecret?: string;
35
+ onRedirect?: (url: string) => void;
36
+ }
24
37
  /**
25
38
  * Storage-backed OAuth provider implementation for MCP
26
39
  * Stores OAuth tokens, client information, and PKCE verifiers using the configured StorageBackend
27
40
  */
28
41
  declare class StorageOAuthClientProvider implements AgentsOAuthProvider {
29
- identity: string;
30
- serverId: string;
31
- sessionId: string;
32
- clientName: string;
33
- baseRedirectUrl: string;
42
+ readonly identity: string;
43
+ readonly serverId: string;
44
+ readonly sessionId: string;
45
+ readonly redirectUrl: string;
46
+ private readonly clientName?;
47
+ private readonly clientUri?;
48
+ private readonly logoUri?;
49
+ private readonly policyUri?;
50
+ private readonly clientSecret?;
34
51
  private _authUrl;
35
52
  private _clientId;
36
53
  private onRedirectCallback?;
37
54
  private tokenExpiresAt?;
38
55
  /**
39
- * Creates a new Storage-backed OAuth provider
40
- * @param identity - User/Client identifier
41
- * @param serverId - Server identifier (for tracking which server this OAuth session belongs to)
42
- * @param sessionId - Session identifier (used as OAuth state)
43
- * @param clientName - OAuth client name
44
- * @param baseRedirectUrl - OAuth callback URL
45
- * @param onRedirect - Optional callback when redirect to authorization is needed
56
+ * Creates a new storage-backed OAuth provider
57
+ * @param options - Provider configuration
46
58
  */
47
- constructor(identity: string, serverId: string, sessionId: string, clientName: string, baseRedirectUrl: string, onRedirect?: (url: string) => void);
59
+ constructor(options: StorageOAuthClientProviderOptions);
48
60
  get clientMetadata(): OAuthClientMetadata;
49
- get clientUri(): string;
50
- get redirectUrl(): string;
51
61
  get clientId(): string | undefined;
52
62
  set clientId(clientId_: string | undefined);
53
63
  /**
@@ -65,7 +75,7 @@ declare class StorageOAuthClientProvider implements AgentsOAuthProvider {
65
75
  /**
66
76
  * Retrieves stored OAuth client information
67
77
  */
68
- clientInformation(): Promise<OAuthClientInformation | undefined>;
78
+ clientInformation(): Promise<OAuthClientInformationMixed | undefined>;
69
79
  /**
70
80
  * Stores OAuth client information
71
81
  */
@@ -76,12 +86,12 @@ declare class StorageOAuthClientProvider implements AgentsOAuthProvider {
76
86
  saveTokens(tokens: OAuthTokens): Promise<void>;
77
87
  get authUrl(): string | undefined;
78
88
  state(): Promise<string>;
79
- checkState(state: string): Promise<{
89
+ checkState(_state: string): Promise<{
80
90
  valid: boolean;
81
91
  serverId?: string;
82
92
  error?: string;
83
93
  }>;
84
- consumeState(state: string): Promise<void>;
94
+ consumeState(_state: string): Promise<void>;
85
95
  redirectToAuthorization(authUrl: URL): Promise<void>;
86
96
  invalidateCredentials(scope: "all" | "client" | "tokens" | "verifier"): Promise<void>;
87
97
  saveCodeVerifier(verifier: string): Promise<void>;
@@ -1,7 +1,7 @@
1
1
  import { b as Event, M as McpConnectionEvent, d as McpObservabilityEvent, c as McpConnectionState } from './events-CK3N--3g.mjs';
2
2
  import { ListToolsResult, CallToolResult, ListPromptsResult, GetPromptResult, ListResourcesResult, ReadResourceResult } from '@modelcontextprotocol/sdk/types.js';
3
3
  import { OAuthClientProvider } from '@modelcontextprotocol/sdk/client/auth.js';
4
- import { OAuthClientMetadata, OAuthClientInformation, OAuthClientInformationFull, OAuthTokens } from '@modelcontextprotocol/sdk/shared/auth.js';
4
+ import { OAuthClientMetadata, OAuthClientInformationMixed, OAuthClientInformationFull, OAuthTokens } from '@modelcontextprotocol/sdk/shared/auth.js';
5
5
 
6
6
  /**
7
7
  * Extension of OAuthClientProvider interface with additional methods
@@ -21,33 +21,43 @@ interface AgentsOAuthProvider extends OAuthClientProvider {
21
21
  isTokenExpired(): boolean;
22
22
  setTokenExpiresAt(expiresAt: number): void;
23
23
  }
24
+ interface StorageOAuthClientProviderOptions {
25
+ identity: string;
26
+ serverId: string;
27
+ sessionId: string;
28
+ redirectUrl: string;
29
+ clientName?: string;
30
+ clientUri?: string;
31
+ logoUri?: string;
32
+ policyUri?: string;
33
+ clientId?: string;
34
+ clientSecret?: string;
35
+ onRedirect?: (url: string) => void;
36
+ }
24
37
  /**
25
38
  * Storage-backed OAuth provider implementation for MCP
26
39
  * Stores OAuth tokens, client information, and PKCE verifiers using the configured StorageBackend
27
40
  */
28
41
  declare class StorageOAuthClientProvider implements AgentsOAuthProvider {
29
- identity: string;
30
- serverId: string;
31
- sessionId: string;
32
- clientName: string;
33
- baseRedirectUrl: string;
42
+ readonly identity: string;
43
+ readonly serverId: string;
44
+ readonly sessionId: string;
45
+ readonly redirectUrl: string;
46
+ private readonly clientName?;
47
+ private readonly clientUri?;
48
+ private readonly logoUri?;
49
+ private readonly policyUri?;
50
+ private readonly clientSecret?;
34
51
  private _authUrl;
35
52
  private _clientId;
36
53
  private onRedirectCallback?;
37
54
  private tokenExpiresAt?;
38
55
  /**
39
- * Creates a new Storage-backed OAuth provider
40
- * @param identity - User/Client identifier
41
- * @param serverId - Server identifier (for tracking which server this OAuth session belongs to)
42
- * @param sessionId - Session identifier (used as OAuth state)
43
- * @param clientName - OAuth client name
44
- * @param baseRedirectUrl - OAuth callback URL
45
- * @param onRedirect - Optional callback when redirect to authorization is needed
56
+ * Creates a new storage-backed OAuth provider
57
+ * @param options - Provider configuration
46
58
  */
47
- constructor(identity: string, serverId: string, sessionId: string, clientName: string, baseRedirectUrl: string, onRedirect?: (url: string) => void);
59
+ constructor(options: StorageOAuthClientProviderOptions);
48
60
  get clientMetadata(): OAuthClientMetadata;
49
- get clientUri(): string;
50
- get redirectUrl(): string;
51
61
  get clientId(): string | undefined;
52
62
  set clientId(clientId_: string | undefined);
53
63
  /**
@@ -65,7 +75,7 @@ declare class StorageOAuthClientProvider implements AgentsOAuthProvider {
65
75
  /**
66
76
  * Retrieves stored OAuth client information
67
77
  */
68
- clientInformation(): Promise<OAuthClientInformation | undefined>;
78
+ clientInformation(): Promise<OAuthClientInformationMixed | undefined>;
69
79
  /**
70
80
  * Stores OAuth client information
71
81
  */
@@ -76,12 +86,12 @@ declare class StorageOAuthClientProvider implements AgentsOAuthProvider {
76
86
  saveTokens(tokens: OAuthTokens): Promise<void>;
77
87
  get authUrl(): string | undefined;
78
88
  state(): Promise<string>;
79
- checkState(state: string): Promise<{
89
+ checkState(_state: string): Promise<{
80
90
  valid: boolean;
81
91
  serverId?: string;
82
92
  error?: string;
83
93
  }>;
84
- consumeState(state: string): Promise<void>;
94
+ consumeState(_state: string): Promise<void>;
85
95
  redirectToAuthorization(authUrl: URL): Promise<void>;
86
96
  invalidateCredentials(scope: "all" | "client" | "tokens" | "verifier"): Promise<void>;
87
97
  saveCodeVerifier(verifier: string): Promise<void>;
@@ -1,4 +1,4 @@
1
- export { M as MCPClient, a as MultiSessionClient, S as StorageOAuthClientProvider } from '../multi-session-client-DzjmT7FX.mjs';
1
+ export { M as MCPClient, a as MultiSessionClient, S as StorageOAuthClientProvider } from '../multi-session-client-CzhMkE0k.mjs';
2
2
  export { U as UnauthorizedError, s as sanitizeServerLabel } from '../utils-0qmYrqoa.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';
@@ -1,4 +1,4 @@
1
- export { M as MCPClient, a as MultiSessionClient, S as StorageOAuthClientProvider } from '../multi-session-client-FAFpUzZ4.js';
1
+ export { M as MCPClient, a as MultiSessionClient, S as StorageOAuthClientProvider } from '../multi-session-client-BYLarghq.js';
2
2
  export { U as UnauthorizedError, s as sanitizeServerLabel } from '../utils-0qmYrqoa.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';