@mcp-ts/sdk 2.4.3 → 2.4.4
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/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 +2 -2
- package/dist/adapters/mastra-adapter.d.ts +2 -2
- package/dist/client/index.d.mts +2 -2
- package/dist/client/index.d.ts +2 -2
- package/dist/client/react.d.mts +4 -5
- package/dist/client/react.d.ts +4 -5
- package/dist/client/react.js.map +1 -1
- package/dist/client/react.mjs.map +1 -1
- package/dist/client/vue.d.mts +4 -5
- package/dist/client/vue.d.ts +4 -5
- package/dist/client/vue.js.map +1 -1
- package/dist/client/vue.mjs.map +1 -1
- package/dist/{index-B8kJSrBJ.d.ts → index-CZk2gu2E.d.ts} +1 -1
- package/dist/{index-DiJsm_lK.d.mts → index-CkM3p0eE.d.mts} +1 -1
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +36 -56
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +36 -56
- package/dist/index.mjs.map +1 -1
- package/dist/{multi-session-client-DOBvtaQV.d.ts → multi-session-client-ChQrBZhF.d.mts} +4 -5
- package/dist/{multi-session-client-B6hsYO8V.d.mts → multi-session-client-QOOPdEVp.d.ts} +4 -5
- package/dist/server/index.d.mts +4 -4
- package/dist/server/index.d.ts +4 -4
- package/dist/server/index.js +36 -56
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +36 -56
- package/dist/server/index.mjs.map +1 -1
- package/dist/shared/index.d.mts +4 -4
- package/dist/shared/index.d.ts +4 -4
- package/dist/shared/index.js.map +1 -1
- package/dist/shared/index.mjs.map +1 -1
- package/dist/{tool-router-CbG4Tum6.d.mts → tool-router-CGs3IDOJ.d.mts} +1 -1
- package/dist/{tool-router-ChIhPwgP.d.ts → tool-router-DQ-HrD7W.d.ts} +1 -1
- package/dist/{types-CjczQwNX.d.mts → types-Bf-7GOLW.d.mts} +0 -2
- package/dist/{types-CjczQwNX.d.ts → types-Bf-7GOLW.d.ts} +0 -2
- package/package.json +1 -1
- package/src/client/react/use-mcp.ts +0 -1
- package/src/client/vue/use-mcp.ts +0 -1
- package/src/server/mcp/oauth-client.ts +41 -76
- package/src/shared/events.ts +0 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { m as Event, M as McpConnectionEvent, t as McpObservabilityEvent, s as McpConnectionState, A as ToolClientProvider } from './types-
|
|
1
|
+
import { m as Event, M as McpConnectionEvent, t as McpObservabilityEvent, s as McpConnectionState, A as ToolClientProvider } from './types-Bf-7GOLW.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
4
|
import { OAuthClientMetadata, OAuthClientInformationMixed, OAuthClientInformationFull, OAuthTokens } from '@modelcontextprotocol/sdk/shared/auth.js';
|
|
@@ -184,12 +184,11 @@ declare class MCPClient {
|
|
|
184
184
|
*/
|
|
185
185
|
private getTransport;
|
|
186
186
|
/**
|
|
187
|
-
*
|
|
188
|
-
*
|
|
189
|
-
* This method is idempotent and safe to call multiple times
|
|
187
|
+
* Ensures session metadata and OAuth provider are loaded.
|
|
188
|
+
* Does NOT create the SDK Client — callers that need one create it themselves.
|
|
190
189
|
* @private
|
|
191
190
|
*/
|
|
192
|
-
private
|
|
191
|
+
private ensureSession;
|
|
193
192
|
/**
|
|
194
193
|
* Saves current session state to the session store
|
|
195
194
|
* Creates new session if it doesn't exist, updates if it does
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { m as Event, M as McpConnectionEvent, t as McpObservabilityEvent, s as McpConnectionState, A as ToolClientProvider } from './types-
|
|
1
|
+
import { m as Event, M as McpConnectionEvent, t as McpObservabilityEvent, s as McpConnectionState, A as ToolClientProvider } from './types-Bf-7GOLW.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
4
|
import { OAuthClientMetadata, OAuthClientInformationMixed, OAuthClientInformationFull, OAuthTokens } from '@modelcontextprotocol/sdk/shared/auth.js';
|
|
@@ -184,12 +184,11 @@ declare class MCPClient {
|
|
|
184
184
|
*/
|
|
185
185
|
private getTransport;
|
|
186
186
|
/**
|
|
187
|
-
*
|
|
188
|
-
*
|
|
189
|
-
* This method is idempotent and safe to call multiple times
|
|
187
|
+
* Ensures session metadata and OAuth provider are loaded.
|
|
188
|
+
* Does NOT create the SDK Client — callers that need one create it themselves.
|
|
190
189
|
* @private
|
|
191
190
|
*/
|
|
192
|
-
private
|
|
191
|
+
private ensureSession;
|
|
193
192
|
/**
|
|
194
193
|
* Saves current session state to the session store
|
|
195
194
|
* Creates new session if it doesn't exist, updates if it does
|
package/dist/server/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { c as SessionMutationListener, e as SessionStore } from '../multi-session-client-
|
|
2
|
-
export { M as MCPClient, a as MultiSessionClient, S as Session, b as SessionMutationEvent, d as SessionMutationType, f as StorageOAuthClientProvider } from '../multi-session-client-
|
|
1
|
+
import { c as SessionMutationListener, e as SessionStore } from '../multi-session-client-ChQrBZhF.mjs';
|
|
2
|
+
export { M as MCPClient, a as MultiSessionClient, S as Session, b as SessionMutationEvent, d as SessionMutationType, f as StorageOAuthClientProvider } from '../multi-session-client-ChQrBZhF.mjs';
|
|
3
3
|
export { U as UnauthorizedError, s as sanitizeServerLabel } from '../utils-DELRKQPU.mjs';
|
|
4
|
-
import { M as McpConnectionEvent, t as McpObservabilityEvent, x as McpRpcResponse, w as McpRpcRequest } from '../types-
|
|
5
|
-
export { a as CallToolRequest, b as CallToolResponse, f as ConnectRequest, g as ConnectResponse, k as Disposable, E as Emitter, m as Event, q as ListToolsResponse, s as McpConnectionState, T as ToolClient, A as ToolClientProvider, B as ToolInfo } from '../types-
|
|
4
|
+
import { M as McpConnectionEvent, t as McpObservabilityEvent, x as McpRpcResponse, w as McpRpcRequest } from '../types-Bf-7GOLW.mjs';
|
|
5
|
+
export { a as CallToolRequest, b as CallToolResponse, f as ConnectRequest, g as ConnectResponse, k as Disposable, E as Emitter, m as Event, q as ListToolsResponse, s as McpConnectionState, T as ToolClient, A as ToolClientProvider, B as ToolInfo } from '../types-Bf-7GOLW.mjs';
|
|
6
6
|
export { OAuthClientInformation, OAuthClientInformationFull, OAuthClientMetadata, OAuthTokens } from '@modelcontextprotocol/sdk/shared/auth.js';
|
|
7
7
|
export { CallToolResult, ListToolsResult, Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
8
8
|
import '@modelcontextprotocol/sdk/client/auth.js';
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { c as SessionMutationListener, e as SessionStore } from '../multi-session-client-
|
|
2
|
-
export { M as MCPClient, a as MultiSessionClient, S as Session, b as SessionMutationEvent, d as SessionMutationType, f as StorageOAuthClientProvider } from '../multi-session-client-
|
|
1
|
+
import { c as SessionMutationListener, e as SessionStore } from '../multi-session-client-QOOPdEVp.js';
|
|
2
|
+
export { M as MCPClient, a as MultiSessionClient, S as Session, b as SessionMutationEvent, d as SessionMutationType, f as StorageOAuthClientProvider } from '../multi-session-client-QOOPdEVp.js';
|
|
3
3
|
export { U as UnauthorizedError, s as sanitizeServerLabel } from '../utils-DELRKQPU.js';
|
|
4
|
-
import { M as McpConnectionEvent, t as McpObservabilityEvent, x as McpRpcResponse, w as McpRpcRequest } from '../types-
|
|
5
|
-
export { a as CallToolRequest, b as CallToolResponse, f as ConnectRequest, g as ConnectResponse, k as Disposable, E as Emitter, m as Event, q as ListToolsResponse, s as McpConnectionState, T as ToolClient, A as ToolClientProvider, B as ToolInfo } from '../types-
|
|
4
|
+
import { M as McpConnectionEvent, t as McpObservabilityEvent, x as McpRpcResponse, w as McpRpcRequest } from '../types-Bf-7GOLW.js';
|
|
5
|
+
export { a as CallToolRequest, b as CallToolResponse, f as ConnectRequest, g as ConnectResponse, k as Disposable, E as Emitter, m as Event, q as ListToolsResponse, s as McpConnectionState, T as ToolClient, A as ToolClientProvider, B as ToolInfo } from '../types-Bf-7GOLW.js';
|
|
6
6
|
export { OAuthClientInformation, OAuthClientInformationFull, OAuthClientMetadata, OAuthTokens } from '@modelcontextprotocol/sdk/shared/auth.js';
|
|
7
7
|
export { CallToolResult, ListToolsResult, Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
8
8
|
import '@modelcontextprotocol/sdk/client/auth.js';
|
package/dist/server/index.js
CHANGED
|
@@ -2149,7 +2149,7 @@ var MCPClient = class {
|
|
|
2149
2149
|
* @param options - Client configuration options
|
|
2150
2150
|
*/
|
|
2151
2151
|
constructor(options) {
|
|
2152
|
-
__publicField(this, "client"
|
|
2152
|
+
__publicField(this, "client");
|
|
2153
2153
|
__publicField(this, "oauthProvider", null);
|
|
2154
2154
|
__publicField(this, "transport", null);
|
|
2155
2155
|
__publicField(this, "userId");
|
|
@@ -2190,6 +2190,21 @@ var MCPClient = class {
|
|
|
2190
2190
|
this.clientUri = options.clientUri;
|
|
2191
2191
|
this.logoUri = options.logoUri;
|
|
2192
2192
|
this.policyUri = options.policyUri;
|
|
2193
|
+
this.client = new index_js.Client(
|
|
2194
|
+
{
|
|
2195
|
+
name: MCP_CLIENT_NAME,
|
|
2196
|
+
version: MCP_CLIENT_VERSION
|
|
2197
|
+
},
|
|
2198
|
+
{
|
|
2199
|
+
capabilities: {
|
|
2200
|
+
extensions: {
|
|
2201
|
+
"io.modelcontextprotocol/ui": {
|
|
2202
|
+
mimeTypes: ["text/html+mcp"]
|
|
2203
|
+
}
|
|
2204
|
+
}
|
|
2205
|
+
}
|
|
2206
|
+
}
|
|
2207
|
+
);
|
|
2193
2208
|
}
|
|
2194
2209
|
/**
|
|
2195
2210
|
* Emit a connection state change event
|
|
@@ -2315,13 +2330,12 @@ var MCPClient = class {
|
|
|
2315
2330
|
}
|
|
2316
2331
|
}
|
|
2317
2332
|
/**
|
|
2318
|
-
*
|
|
2319
|
-
*
|
|
2320
|
-
* This method is idempotent and safe to call multiple times
|
|
2333
|
+
* Ensures session metadata and OAuth provider are loaded.
|
|
2334
|
+
* Does NOT create the SDK Client — callers that need one create it themselves.
|
|
2321
2335
|
* @private
|
|
2322
2336
|
*/
|
|
2323
|
-
async
|
|
2324
|
-
if (this.
|
|
2337
|
+
async ensureSession() {
|
|
2338
|
+
if (this.oauthProvider) {
|
|
2325
2339
|
return;
|
|
2326
2340
|
}
|
|
2327
2341
|
this.emitStateChange("INITIALIZING");
|
|
@@ -2364,23 +2378,6 @@ var MCPClient = class {
|
|
|
2364
2378
|
}
|
|
2365
2379
|
});
|
|
2366
2380
|
}
|
|
2367
|
-
if (!this.client) {
|
|
2368
|
-
this.client = new index_js.Client(
|
|
2369
|
-
{
|
|
2370
|
-
name: MCP_CLIENT_NAME,
|
|
2371
|
-
version: MCP_CLIENT_VERSION
|
|
2372
|
-
},
|
|
2373
|
-
{
|
|
2374
|
-
capabilities: {
|
|
2375
|
-
extensions: {
|
|
2376
|
-
"io.modelcontextprotocol/ui": {
|
|
2377
|
-
mimeTypes: ["text/html+mcp"]
|
|
2378
|
-
}
|
|
2379
|
-
}
|
|
2380
|
-
}
|
|
2381
|
-
}
|
|
2382
|
-
);
|
|
2383
|
-
}
|
|
2384
2381
|
if (existingSession === null) {
|
|
2385
2382
|
existingSession = await sessions.get(this.userId, this.sessionId);
|
|
2386
2383
|
}
|
|
@@ -2497,17 +2494,16 @@ var MCPClient = class {
|
|
|
2497
2494
|
* @throws {Error} When connection fails for other reasons
|
|
2498
2495
|
*/
|
|
2499
2496
|
async connect() {
|
|
2500
|
-
if (this.client
|
|
2497
|
+
if (this.client.transport) {
|
|
2501
2498
|
this.transport = null;
|
|
2502
2499
|
try {
|
|
2503
2500
|
await this.client.close();
|
|
2504
2501
|
} catch {
|
|
2505
2502
|
}
|
|
2506
|
-
this.client = null;
|
|
2507
2503
|
}
|
|
2508
|
-
await this.
|
|
2509
|
-
if (!this.
|
|
2510
|
-
const error = "
|
|
2504
|
+
await this.ensureSession();
|
|
2505
|
+
if (!this.oauthProvider) {
|
|
2506
|
+
const error = "OAuth provider not initialized";
|
|
2511
2507
|
this.emitError(error, "connection");
|
|
2512
2508
|
this.emitStateChange("FAILED");
|
|
2513
2509
|
throw new Error(error);
|
|
@@ -2574,7 +2570,7 @@ var MCPClient = class {
|
|
|
2574
2570
|
async finishAuth(authCode, state) {
|
|
2575
2571
|
this.emitStateChange("AUTHENTICATING");
|
|
2576
2572
|
this.emitProgress("Exchanging authorization code for tokens...");
|
|
2577
|
-
await this.
|
|
2573
|
+
await this.ensureSession();
|
|
2578
2574
|
if (!this.oauthProvider) {
|
|
2579
2575
|
const error = "OAuth provider not initialized";
|
|
2580
2576
|
this.emitError(error, "auth");
|
|
@@ -2874,13 +2870,12 @@ var MCPClient = class {
|
|
|
2874
2870
|
return await fn();
|
|
2875
2871
|
} catch (error) {
|
|
2876
2872
|
if (!(error instanceof Error && error.message.includes("MCP_SESSION_EXPIRED"))) throw error;
|
|
2877
|
-
if (this.client) {
|
|
2873
|
+
if (this.client.transport) {
|
|
2878
2874
|
try {
|
|
2879
2875
|
await this.client.close();
|
|
2880
2876
|
} catch {
|
|
2881
2877
|
}
|
|
2882
2878
|
this.transport = null;
|
|
2883
|
-
this.client = null;
|
|
2884
2879
|
}
|
|
2885
2880
|
await this.reconnect();
|
|
2886
2881
|
return await fn();
|
|
@@ -2893,26 +2888,9 @@ var MCPClient = class {
|
|
|
2893
2888
|
* @throws {Error} When OAuth provider is not initialized
|
|
2894
2889
|
*/
|
|
2895
2890
|
async reconnect() {
|
|
2896
|
-
await this.
|
|
2897
|
-
if (!this.oauthProvider)
|
|
2898
|
-
|
|
2899
|
-
}
|
|
2900
|
-
if (this.client) {
|
|
2901
|
-
try {
|
|
2902
|
-
await this.client.close();
|
|
2903
|
-
} catch {
|
|
2904
|
-
}
|
|
2905
|
-
}
|
|
2906
|
-
this.client = new index_js.Client(
|
|
2907
|
-
{
|
|
2908
|
-
name: MCP_CLIENT_NAME,
|
|
2909
|
-
version: MCP_CLIENT_VERSION
|
|
2910
|
-
},
|
|
2911
|
-
{ capabilities: {} }
|
|
2912
|
-
);
|
|
2913
|
-
const tt = this.transportType || "streamable-http";
|
|
2914
|
-
this.transport = this.getTransport(tt);
|
|
2915
|
-
await this.client.connect(this.transport);
|
|
2891
|
+
await this.ensureSession();
|
|
2892
|
+
if (!this.oauthProvider) throw new Error("OAuth provider not initialized");
|
|
2893
|
+
await this.connect();
|
|
2916
2894
|
}
|
|
2917
2895
|
/**
|
|
2918
2896
|
* Completely removes the session from Redis including all OAuth data
|
|
@@ -2920,7 +2898,7 @@ var MCPClient = class {
|
|
|
2920
2898
|
*/
|
|
2921
2899
|
async clearSession() {
|
|
2922
2900
|
try {
|
|
2923
|
-
await this.
|
|
2901
|
+
await this.ensureSession();
|
|
2924
2902
|
} catch (error) {
|
|
2925
2903
|
console.warn("[MCPClient] Initialization failed during clearSession:", error);
|
|
2926
2904
|
}
|
|
@@ -2935,7 +2913,7 @@ var MCPClient = class {
|
|
|
2935
2913
|
* @returns True if connected, false otherwise
|
|
2936
2914
|
*/
|
|
2937
2915
|
isConnected() {
|
|
2938
|
-
return this.client !==
|
|
2916
|
+
return this.client.transport !== void 0;
|
|
2939
2917
|
}
|
|
2940
2918
|
/**
|
|
2941
2919
|
* Disconnects from the MCP server and cleans up resources.
|
|
@@ -2953,10 +2931,12 @@ var MCPClient = class {
|
|
|
2953
2931
|
} catch {
|
|
2954
2932
|
}
|
|
2955
2933
|
}
|
|
2956
|
-
if (this.client) {
|
|
2957
|
-
|
|
2934
|
+
if (this.client.transport) {
|
|
2935
|
+
try {
|
|
2936
|
+
await this.client.close();
|
|
2937
|
+
} catch {
|
|
2938
|
+
}
|
|
2958
2939
|
}
|
|
2959
|
-
this.client = null;
|
|
2960
2940
|
this.oauthProvider = null;
|
|
2961
2941
|
this.transport = null;
|
|
2962
2942
|
if (this.serverId) {
|