@mcp-ts/sdk 1.3.3 → 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.
- package/README.md +404 -405
- package/dist/adapters/agui-adapter.d.mts +1 -1
- package/dist/adapters/agui-adapter.d.ts +1 -1
- package/dist/adapters/agui-middleware.d.mts +1 -1
- package/dist/adapters/agui-middleware.d.ts +1 -1
- package/dist/adapters/ai-adapter.d.mts +1 -1
- package/dist/adapters/ai-adapter.d.ts +1 -1
- package/dist/adapters/langchain-adapter.d.mts +1 -1
- package/dist/adapters/langchain-adapter.d.ts +1 -1
- package/dist/adapters/mastra-adapter.d.mts +1 -1
- package/dist/adapters/mastra-adapter.d.ts +1 -1
- package/dist/client/index.d.mts +1 -0
- package/dist/client/index.d.ts +1 -0
- package/dist/client/index.js +14 -5
- package/dist/client/index.js.map +1 -1
- package/dist/client/index.mjs +14 -5
- package/dist/client/index.mjs.map +1 -1
- package/dist/client/react.js +15 -6
- package/dist/client/react.js.map +1 -1
- package/dist/client/react.mjs +15 -6
- package/dist/client/react.mjs.map +1 -1
- package/dist/client/vue.js +15 -6
- package/dist/client/vue.js.map +1 -1
- package/dist/client/vue.mjs +15 -6
- package/dist/client/vue.mjs.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +201 -158
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +201 -158
- package/dist/index.mjs.map +1 -1
- package/dist/{multi-session-client-FAFpUzZ4.d.ts → multi-session-client-BYLarghq.d.ts} +29 -19
- package/dist/{multi-session-client-DzjmT7FX.d.mts → multi-session-client-CzhMkE0k.d.mts} +29 -19
- package/dist/server/index.d.mts +1 -1
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.js +193 -151
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +193 -151
- package/dist/server/index.mjs.map +1 -1
- package/dist/shared/index.d.mts +2 -2
- package/dist/shared/index.d.ts +2 -2
- package/dist/shared/index.js +2 -2
- package/dist/shared/index.js.map +1 -1
- package/dist/shared/index.mjs +2 -2
- package/dist/shared/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/client/core/sse-client.ts +371 -354
- package/src/client/react/use-mcp.ts +31 -31
- package/src/client/vue/use-mcp.ts +77 -77
- package/src/server/handlers/nextjs-handler.ts +194 -197
- package/src/server/handlers/sse-handler.ts +62 -111
- package/src/server/mcp/oauth-client.ts +67 -79
- package/src/server/mcp/storage-oauth-provider.ts +71 -38
- package/src/server/storage/index.ts +15 -13
- package/src/server/storage/redis-backend.ts +93 -23
- package/src/server/storage/types.ts +12 -12
- package/src/shared/constants.ts +2 -2
- 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,
|
|
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
|
-
|
|
33
|
-
|
|
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
|
|
40
|
-
* @param
|
|
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(
|
|
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<
|
|
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(
|
|
89
|
+
checkState(_state: string): Promise<{
|
|
80
90
|
valid: boolean;
|
|
81
91
|
serverId?: string;
|
|
82
92
|
error?: string;
|
|
83
93
|
}>;
|
|
84
|
-
consumeState(
|
|
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,
|
|
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
|
-
|
|
33
|
-
|
|
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
|
|
40
|
-
* @param
|
|
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(
|
|
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<
|
|
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(
|
|
89
|
+
checkState(_state: string): Promise<{
|
|
80
90
|
valid: boolean;
|
|
81
91
|
serverId?: string;
|
|
82
92
|
error?: string;
|
|
83
93
|
}>;
|
|
84
|
-
consumeState(
|
|
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>;
|
package/dist/server/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { M as MCPClient, a as MultiSessionClient, S as StorageOAuthClientProvider } from '../multi-session-client-
|
|
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';
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { M as MCPClient, a as MultiSessionClient, S as StorageOAuthClientProvider } from '../multi-session-client-
|
|
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';
|