@mcp-ts/sdk 1.3.0 → 1.3.2
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 +132 -50
- package/dist/adapters/agui-adapter.d.mts +3 -3
- package/dist/adapters/agui-adapter.d.ts +3 -3
- package/dist/adapters/agui-middleware.d.mts +3 -3
- package/dist/adapters/agui-middleware.d.ts +3 -3
- package/dist/adapters/ai-adapter.d.mts +3 -3
- package/dist/adapters/ai-adapter.d.ts +3 -3
- package/dist/adapters/langchain-adapter.d.mts +3 -3
- package/dist/adapters/langchain-adapter.d.ts +3 -3
- package/dist/adapters/mastra-adapter.d.mts +3 -3
- package/dist/adapters/mastra-adapter.d.ts +3 -3
- package/dist/client/index.d.mts +4 -4
- package/dist/client/index.d.ts +4 -4
- package/dist/client/react.d.mts +9 -8
- package/dist/client/react.d.ts +9 -8
- package/dist/client/react.js +16 -4
- package/dist/client/react.js.map +1 -1
- package/dist/client/react.mjs +16 -4
- package/dist/client/react.mjs.map +1 -1
- package/dist/client/vue.d.mts +5 -5
- package/dist/client/vue.d.ts +5 -5
- package/dist/client/vue.js +11 -1
- package/dist/client/vue.js.map +1 -1
- package/dist/client/vue.mjs +11 -1
- package/dist/client/vue.mjs.map +1 -1
- package/dist/{events-BgeztGYZ.d.mts → events-CK3N--3g.d.mts} +2 -0
- package/dist/{events-BgeztGYZ.d.ts → events-CK3N--3g.d.ts} +2 -0
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +12 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +12 -11
- package/dist/index.mjs.map +1 -1
- package/dist/{multi-session-client-CxogNckF.d.mts → multi-session-client-B1DBx5yR.d.mts} +3 -10
- package/dist/{multi-session-client-cox_WXUj.d.ts → multi-session-client-DyFzyJUx.d.ts} +3 -10
- package/dist/server/index.d.mts +5 -5
- package/dist/server/index.d.ts +5 -5
- package/dist/server/index.js +12 -11
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +12 -11
- package/dist/server/index.mjs.map +1 -1
- package/dist/shared/index.d.mts +3 -3
- package/dist/shared/index.d.ts +3 -3
- package/dist/shared/index.js.map +1 -1
- package/dist/shared/index.mjs.map +1 -1
- package/dist/{types-CLccx9wW.d.mts → types-PjM1W07s.d.mts} +1 -0
- package/dist/{types-CLccx9wW.d.ts → types-PjM1W07s.d.ts} +1 -0
- package/package.json +1 -1
- package/src/client/react/index.ts +16 -16
- package/src/client/react/use-mcp-apps.tsx +214 -213
- package/src/client/react/use-mcp.ts +15 -2
- package/src/client/vue/use-mcp.ts +14 -2
- package/src/server/handlers/sse-handler.ts +4 -0
- package/src/server/mcp/oauth-client.ts +10 -17
- package/src/shared/events.ts +2 -0
- package/src/shared/types.ts +1 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { b as Event, M as McpConnectionEvent, d as McpObservabilityEvent, c as McpConnectionState } from './events-
|
|
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
|
-
import { OAuthClientMetadata, OAuthClientInformation, OAuthClientInformationFull, OAuthTokens } from '@modelcontextprotocol/sdk/shared/auth.js';
|
|
4
3
|
import { OAuthClientProvider } from '@modelcontextprotocol/sdk/client/auth.js';
|
|
4
|
+
import { OAuthClientMetadata, OAuthClientInformation, OAuthClientInformationFull, OAuthTokens } from '@modelcontextprotocol/sdk/shared/auth.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Extension of OAuthClientProvider interface with additional methods
|
|
@@ -105,12 +105,8 @@ interface MCPOAuthClientOptions {
|
|
|
105
105
|
serverId?: string; /** Optional - loaded from session if not provided */
|
|
106
106
|
sessionId: string; /** Required - primary key for session lookup */
|
|
107
107
|
transportType?: TransportType;
|
|
108
|
-
tokens?: OAuthTokens;
|
|
109
|
-
tokenExpiresAt?: number;
|
|
110
|
-
clientInformation?: OAuthClientInformationFull;
|
|
111
108
|
clientId?: string;
|
|
112
109
|
clientSecret?: string;
|
|
113
|
-
onSaveTokens?: (tokens: OAuthTokens) => void;
|
|
114
110
|
headers?: Record<string, string>;
|
|
115
111
|
/** OAuth Client Metadata (optional - user application info) */
|
|
116
112
|
clientName?: string;
|
|
@@ -135,18 +131,15 @@ declare class MCPClient {
|
|
|
135
131
|
private serverUrl;
|
|
136
132
|
private callbackUrl;
|
|
137
133
|
private onRedirect;
|
|
138
|
-
private tokens?;
|
|
139
|
-
private tokenExpiresAt?;
|
|
140
|
-
private clientInformation?;
|
|
141
134
|
private clientId?;
|
|
142
135
|
private clientSecret?;
|
|
143
|
-
private onSaveTokens?;
|
|
144
136
|
private headers?;
|
|
145
137
|
/** OAuth Client Metadata */
|
|
146
138
|
private clientName?;
|
|
147
139
|
private clientUri?;
|
|
148
140
|
private logoUri?;
|
|
149
141
|
private policyUri?;
|
|
142
|
+
private createdAt?;
|
|
150
143
|
/** Event emitters for connection lifecycle */
|
|
151
144
|
private readonly _onConnectionEvent;
|
|
152
145
|
readonly onConnectionEvent: Event<McpConnectionEvent>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { b as Event, M as McpConnectionEvent, d as McpObservabilityEvent, c as McpConnectionState } from './events-
|
|
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
|
-
import { OAuthClientMetadata, OAuthClientInformation, OAuthClientInformationFull, OAuthTokens } from '@modelcontextprotocol/sdk/shared/auth.js';
|
|
4
3
|
import { OAuthClientProvider } from '@modelcontextprotocol/sdk/client/auth.js';
|
|
4
|
+
import { OAuthClientMetadata, OAuthClientInformation, OAuthClientInformationFull, OAuthTokens } from '@modelcontextprotocol/sdk/shared/auth.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Extension of OAuthClientProvider interface with additional methods
|
|
@@ -105,12 +105,8 @@ interface MCPOAuthClientOptions {
|
|
|
105
105
|
serverId?: string; /** Optional - loaded from session if not provided */
|
|
106
106
|
sessionId: string; /** Required - primary key for session lookup */
|
|
107
107
|
transportType?: TransportType;
|
|
108
|
-
tokens?: OAuthTokens;
|
|
109
|
-
tokenExpiresAt?: number;
|
|
110
|
-
clientInformation?: OAuthClientInformationFull;
|
|
111
108
|
clientId?: string;
|
|
112
109
|
clientSecret?: string;
|
|
113
|
-
onSaveTokens?: (tokens: OAuthTokens) => void;
|
|
114
110
|
headers?: Record<string, string>;
|
|
115
111
|
/** OAuth Client Metadata (optional - user application info) */
|
|
116
112
|
clientName?: string;
|
|
@@ -135,18 +131,15 @@ declare class MCPClient {
|
|
|
135
131
|
private serverUrl;
|
|
136
132
|
private callbackUrl;
|
|
137
133
|
private onRedirect;
|
|
138
|
-
private tokens?;
|
|
139
|
-
private tokenExpiresAt?;
|
|
140
|
-
private clientInformation?;
|
|
141
134
|
private clientId?;
|
|
142
135
|
private clientSecret?;
|
|
143
|
-
private onSaveTokens?;
|
|
144
136
|
private headers?;
|
|
145
137
|
/** OAuth Client Metadata */
|
|
146
138
|
private clientName?;
|
|
147
139
|
private clientUri?;
|
|
148
140
|
private logoUri?;
|
|
149
141
|
private policyUri?;
|
|
142
|
+
private createdAt?;
|
|
150
143
|
/** Event emitters for connection lifecycle */
|
|
151
144
|
private readonly _onConnectionEvent;
|
|
152
145
|
readonly onConnectionEvent: Event<McpConnectionEvent>;
|
package/dist/server/index.d.mts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
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-B1DBx5yR.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';
|
|
5
|
-
import { M as McpConnectionEvent, d as McpObservabilityEvent } from '../events-
|
|
6
|
-
export { D as Disposable, E as Emitter, b as Event, c as McpConnectionState } from '../events-
|
|
7
|
-
import { q as McpRpcResponse, p as McpRpcRequest } from '../types-
|
|
8
|
-
export { a as CallToolRequest, b as CallToolResponse, f as ConnectRequest, g as ConnectResponse, m as ListToolsResponse, T as ToolInfo } from '../types-
|
|
5
|
+
import { M as McpConnectionEvent, d as McpObservabilityEvent } from '../events-CK3N--3g.mjs';
|
|
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-PjM1W07s.mjs';
|
|
8
|
+
export { a as CallToolRequest, b as CallToolResponse, f as ConnectRequest, g as ConnectResponse, m as ListToolsResponse, T as ToolInfo } from '../types-PjM1W07s.mjs';
|
|
9
9
|
export { CallToolResult, ListToolsResult, Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
10
10
|
import '@modelcontextprotocol/sdk/client/auth.js';
|
|
11
11
|
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
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-DyFzyJUx.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';
|
|
5
|
-
import { M as McpConnectionEvent, d as McpObservabilityEvent } from '../events-
|
|
6
|
-
export { D as Disposable, E as Emitter, b as Event, c as McpConnectionState } from '../events-
|
|
7
|
-
import { q as McpRpcResponse, p as McpRpcRequest } from '../types-
|
|
8
|
-
export { a as CallToolRequest, b as CallToolResponse, f as ConnectRequest, g as ConnectResponse, m as ListToolsResponse, T as ToolInfo } from '../types-
|
|
5
|
+
import { M as McpConnectionEvent, d as McpObservabilityEvent } from '../events-CK3N--3g.js';
|
|
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-PjM1W07s.js';
|
|
8
|
+
export { a as CallToolRequest, b as CallToolResponse, f as ConnectRequest, g as ConnectResponse, m as ListToolsResponse, T as ToolInfo } from '../types-PjM1W07s.js';
|
|
9
9
|
export { CallToolResult, ListToolsResult, Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
10
10
|
import '@modelcontextprotocol/sdk/client/auth.js';
|
|
11
11
|
|
package/dist/server/index.js
CHANGED
|
@@ -1024,18 +1024,15 @@ var MCPClient = class _MCPClient {
|
|
|
1024
1024
|
__publicField(this, "serverUrl");
|
|
1025
1025
|
__publicField(this, "callbackUrl");
|
|
1026
1026
|
__publicField(this, "onRedirect");
|
|
1027
|
-
__publicField(this, "tokens");
|
|
1028
|
-
__publicField(this, "tokenExpiresAt");
|
|
1029
|
-
__publicField(this, "clientInformation");
|
|
1030
1027
|
__publicField(this, "clientId");
|
|
1031
1028
|
__publicField(this, "clientSecret");
|
|
1032
|
-
__publicField(this, "onSaveTokens");
|
|
1033
1029
|
__publicField(this, "headers");
|
|
1034
1030
|
/** OAuth Client Metadata */
|
|
1035
1031
|
__publicField(this, "clientName");
|
|
1036
1032
|
__publicField(this, "clientUri");
|
|
1037
1033
|
__publicField(this, "logoUri");
|
|
1038
1034
|
__publicField(this, "policyUri");
|
|
1035
|
+
__publicField(this, "createdAt");
|
|
1039
1036
|
/** Event emitters for connection lifecycle */
|
|
1040
1037
|
__publicField(this, "_onConnectionEvent", new Emitter());
|
|
1041
1038
|
__publicField(this, "onConnectionEvent", this._onConnectionEvent.event);
|
|
@@ -1050,12 +1047,8 @@ var MCPClient = class _MCPClient {
|
|
|
1050
1047
|
this.serverId = options.serverId;
|
|
1051
1048
|
this.sessionId = options.sessionId;
|
|
1052
1049
|
this.transportType = options.transportType;
|
|
1053
|
-
this.tokens = options.tokens;
|
|
1054
|
-
this.tokenExpiresAt = options.tokenExpiresAt;
|
|
1055
|
-
this.clientInformation = options.clientInformation;
|
|
1056
1050
|
this.clientId = options.clientId;
|
|
1057
1051
|
this.clientSecret = options.clientSecret;
|
|
1058
|
-
this.onSaveTokens = options.onSaveTokens;
|
|
1059
1052
|
this.headers = options.headers;
|
|
1060
1053
|
this.clientName = options.clientName;
|
|
1061
1054
|
this.clientUri = options.clientUri;
|
|
@@ -1075,6 +1068,8 @@ var MCPClient = class _MCPClient {
|
|
|
1075
1068
|
sessionId: this.sessionId,
|
|
1076
1069
|
serverId: this.serverId,
|
|
1077
1070
|
serverName: this.serverName || this.serverId,
|
|
1071
|
+
serverUrl: this.serverUrl || "",
|
|
1072
|
+
createdAt: this.createdAt,
|
|
1078
1073
|
state: newState,
|
|
1079
1074
|
previousState,
|
|
1080
1075
|
timestamp: Date.now()
|
|
@@ -1195,6 +1190,7 @@ var MCPClient = class _MCPClient {
|
|
|
1195
1190
|
this.serverName = this.serverName || sessionData.serverName;
|
|
1196
1191
|
this.serverId = this.serverId || sessionData.serverId || "unknown";
|
|
1197
1192
|
this.headers = this.headers || sessionData.headers;
|
|
1193
|
+
this.createdAt = sessionData.createdAt;
|
|
1198
1194
|
}
|
|
1199
1195
|
if (!this.serverUrl || !this.callbackUrl || !this.serverId) {
|
|
1200
1196
|
throw new Error("Missing required connection metadata");
|
|
@@ -1248,6 +1244,7 @@ var MCPClient = class _MCPClient {
|
|
|
1248
1244
|
}
|
|
1249
1245
|
const existingSession = await storage.getSession(this.identity, this.sessionId);
|
|
1250
1246
|
if (!existingSession && this.serverId && this.serverUrl && this.callbackUrl) {
|
|
1247
|
+
this.createdAt = Date.now();
|
|
1251
1248
|
console.log(`[MCPClient] Creating initial session ${this.sessionId} for OAuth flow`);
|
|
1252
1249
|
await storage.createSession({
|
|
1253
1250
|
sessionId: this.sessionId,
|
|
@@ -1257,7 +1254,7 @@ var MCPClient = class _MCPClient {
|
|
|
1257
1254
|
serverUrl: this.serverUrl,
|
|
1258
1255
|
callbackUrl: this.callbackUrl,
|
|
1259
1256
|
transportType: this.transportType || "streamable_http",
|
|
1260
|
-
createdAt:
|
|
1257
|
+
createdAt: this.createdAt
|
|
1261
1258
|
}, Math.floor(STATE_EXPIRATION_MS / 1e3));
|
|
1262
1259
|
}
|
|
1263
1260
|
}
|
|
@@ -1279,7 +1276,7 @@ var MCPClient = class _MCPClient {
|
|
|
1279
1276
|
serverUrl: this.serverUrl,
|
|
1280
1277
|
callbackUrl: this.callbackUrl,
|
|
1281
1278
|
transportType: this.transportType || "streamable_http",
|
|
1282
|
-
createdAt: Date.now()
|
|
1279
|
+
createdAt: this.createdAt || Date.now()
|
|
1283
1280
|
};
|
|
1284
1281
|
const existingSession = await storage.getSession(this.identity, this.sessionId);
|
|
1285
1282
|
if (existingSession) {
|
|
@@ -2103,7 +2100,8 @@ var SSEConnectionManager = class {
|
|
|
2103
2100
|
serverId: s.serverId,
|
|
2104
2101
|
serverName: s.serverName,
|
|
2105
2102
|
serverUrl: s.serverUrl,
|
|
2106
|
-
transport: s.transportType
|
|
2103
|
+
transport: s.transportType,
|
|
2104
|
+
createdAt: s.createdAt
|
|
2107
2105
|
}))
|
|
2108
2106
|
};
|
|
2109
2107
|
}
|
|
@@ -2126,6 +2124,7 @@ var SSEConnectionManager = class {
|
|
|
2126
2124
|
sessionId,
|
|
2127
2125
|
serverId,
|
|
2128
2126
|
serverName,
|
|
2127
|
+
serverUrl,
|
|
2129
2128
|
state: "CONNECTING",
|
|
2130
2129
|
previousState: "DISCONNECTED",
|
|
2131
2130
|
timestamp: Date.now()
|
|
@@ -2258,6 +2257,7 @@ var SSEConnectionManager = class {
|
|
|
2258
2257
|
sessionId,
|
|
2259
2258
|
serverId: session.serverId ?? "unknown",
|
|
2260
2259
|
serverName: session.serverName ?? "Unknown",
|
|
2260
|
+
serverUrl: session.serverUrl,
|
|
2261
2261
|
state: "VALIDATING",
|
|
2262
2262
|
previousState: "DISCONNECTED",
|
|
2263
2263
|
timestamp: Date.now()
|
|
@@ -2309,6 +2309,7 @@ var SSEConnectionManager = class {
|
|
|
2309
2309
|
sessionId,
|
|
2310
2310
|
serverId: session.serverId ?? "unknown",
|
|
2311
2311
|
serverName: session.serverName ?? "Unknown",
|
|
2312
|
+
serverUrl: session.serverUrl,
|
|
2312
2313
|
state: "AUTHENTICATING",
|
|
2313
2314
|
previousState: "DISCONNECTED",
|
|
2314
2315
|
timestamp: Date.now()
|