@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
package/dist/index.mjs
CHANGED
|
@@ -1081,18 +1081,15 @@ var MCPClient = class _MCPClient {
|
|
|
1081
1081
|
__publicField(this, "serverUrl");
|
|
1082
1082
|
__publicField(this, "callbackUrl");
|
|
1083
1083
|
__publicField(this, "onRedirect");
|
|
1084
|
-
__publicField(this, "tokens");
|
|
1085
|
-
__publicField(this, "tokenExpiresAt");
|
|
1086
|
-
__publicField(this, "clientInformation");
|
|
1087
1084
|
__publicField(this, "clientId");
|
|
1088
1085
|
__publicField(this, "clientSecret");
|
|
1089
|
-
__publicField(this, "onSaveTokens");
|
|
1090
1086
|
__publicField(this, "headers");
|
|
1091
1087
|
/** OAuth Client Metadata */
|
|
1092
1088
|
__publicField(this, "clientName");
|
|
1093
1089
|
__publicField(this, "clientUri");
|
|
1094
1090
|
__publicField(this, "logoUri");
|
|
1095
1091
|
__publicField(this, "policyUri");
|
|
1092
|
+
__publicField(this, "createdAt");
|
|
1096
1093
|
/** Event emitters for connection lifecycle */
|
|
1097
1094
|
__publicField(this, "_onConnectionEvent", new Emitter());
|
|
1098
1095
|
__publicField(this, "onConnectionEvent", this._onConnectionEvent.event);
|
|
@@ -1107,12 +1104,8 @@ var MCPClient = class _MCPClient {
|
|
|
1107
1104
|
this.serverId = options.serverId;
|
|
1108
1105
|
this.sessionId = options.sessionId;
|
|
1109
1106
|
this.transportType = options.transportType;
|
|
1110
|
-
this.tokens = options.tokens;
|
|
1111
|
-
this.tokenExpiresAt = options.tokenExpiresAt;
|
|
1112
|
-
this.clientInformation = options.clientInformation;
|
|
1113
1107
|
this.clientId = options.clientId;
|
|
1114
1108
|
this.clientSecret = options.clientSecret;
|
|
1115
|
-
this.onSaveTokens = options.onSaveTokens;
|
|
1116
1109
|
this.headers = options.headers;
|
|
1117
1110
|
this.clientName = options.clientName;
|
|
1118
1111
|
this.clientUri = options.clientUri;
|
|
@@ -1132,6 +1125,8 @@ var MCPClient = class _MCPClient {
|
|
|
1132
1125
|
sessionId: this.sessionId,
|
|
1133
1126
|
serverId: this.serverId,
|
|
1134
1127
|
serverName: this.serverName || this.serverId,
|
|
1128
|
+
serverUrl: this.serverUrl || "",
|
|
1129
|
+
createdAt: this.createdAt,
|
|
1135
1130
|
state: newState,
|
|
1136
1131
|
previousState,
|
|
1137
1132
|
timestamp: Date.now()
|
|
@@ -1252,6 +1247,7 @@ var MCPClient = class _MCPClient {
|
|
|
1252
1247
|
this.serverName = this.serverName || sessionData.serverName;
|
|
1253
1248
|
this.serverId = this.serverId || sessionData.serverId || "unknown";
|
|
1254
1249
|
this.headers = this.headers || sessionData.headers;
|
|
1250
|
+
this.createdAt = sessionData.createdAt;
|
|
1255
1251
|
}
|
|
1256
1252
|
if (!this.serverUrl || !this.callbackUrl || !this.serverId) {
|
|
1257
1253
|
throw new Error("Missing required connection metadata");
|
|
@@ -1305,6 +1301,7 @@ var MCPClient = class _MCPClient {
|
|
|
1305
1301
|
}
|
|
1306
1302
|
const existingSession = await storage.getSession(this.identity, this.sessionId);
|
|
1307
1303
|
if (!existingSession && this.serverId && this.serverUrl && this.callbackUrl) {
|
|
1304
|
+
this.createdAt = Date.now();
|
|
1308
1305
|
console.log(`[MCPClient] Creating initial session ${this.sessionId} for OAuth flow`);
|
|
1309
1306
|
await storage.createSession({
|
|
1310
1307
|
sessionId: this.sessionId,
|
|
@@ -1314,7 +1311,7 @@ var MCPClient = class _MCPClient {
|
|
|
1314
1311
|
serverUrl: this.serverUrl,
|
|
1315
1312
|
callbackUrl: this.callbackUrl,
|
|
1316
1313
|
transportType: this.transportType || "streamable_http",
|
|
1317
|
-
createdAt:
|
|
1314
|
+
createdAt: this.createdAt
|
|
1318
1315
|
}, Math.floor(STATE_EXPIRATION_MS / 1e3));
|
|
1319
1316
|
}
|
|
1320
1317
|
}
|
|
@@ -1336,7 +1333,7 @@ var MCPClient = class _MCPClient {
|
|
|
1336
1333
|
serverUrl: this.serverUrl,
|
|
1337
1334
|
callbackUrl: this.callbackUrl,
|
|
1338
1335
|
transportType: this.transportType || "streamable_http",
|
|
1339
|
-
createdAt: Date.now()
|
|
1336
|
+
createdAt: this.createdAt || Date.now()
|
|
1340
1337
|
};
|
|
1341
1338
|
const existingSession = await storage.getSession(this.identity, this.sessionId);
|
|
1342
1339
|
if (existingSession) {
|
|
@@ -2160,7 +2157,8 @@ var SSEConnectionManager = class {
|
|
|
2160
2157
|
serverId: s.serverId,
|
|
2161
2158
|
serverName: s.serverName,
|
|
2162
2159
|
serverUrl: s.serverUrl,
|
|
2163
|
-
transport: s.transportType
|
|
2160
|
+
transport: s.transportType,
|
|
2161
|
+
createdAt: s.createdAt
|
|
2164
2162
|
}))
|
|
2165
2163
|
};
|
|
2166
2164
|
}
|
|
@@ -2183,6 +2181,7 @@ var SSEConnectionManager = class {
|
|
|
2183
2181
|
sessionId,
|
|
2184
2182
|
serverId,
|
|
2185
2183
|
serverName,
|
|
2184
|
+
serverUrl,
|
|
2186
2185
|
state: "CONNECTING",
|
|
2187
2186
|
previousState: "DISCONNECTED",
|
|
2188
2187
|
timestamp: Date.now()
|
|
@@ -2315,6 +2314,7 @@ var SSEConnectionManager = class {
|
|
|
2315
2314
|
sessionId,
|
|
2316
2315
|
serverId: session.serverId ?? "unknown",
|
|
2317
2316
|
serverName: session.serverName ?? "Unknown",
|
|
2317
|
+
serverUrl: session.serverUrl,
|
|
2318
2318
|
state: "VALIDATING",
|
|
2319
2319
|
previousState: "DISCONNECTED",
|
|
2320
2320
|
timestamp: Date.now()
|
|
@@ -2366,6 +2366,7 @@ var SSEConnectionManager = class {
|
|
|
2366
2366
|
sessionId,
|
|
2367
2367
|
serverId: session.serverId ?? "unknown",
|
|
2368
2368
|
serverName: session.serverName ?? "Unknown",
|
|
2369
|
+
serverUrl: session.serverUrl,
|
|
2369
2370
|
state: "AUTHENTICATING",
|
|
2370
2371
|
previousState: "DISCONNECTED",
|
|
2371
2372
|
timestamp: Date.now()
|