@mcp-ts/sdk 1.6.2 → 2.0.0
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 +12 -6
- package/dist/adapters/agui-adapter.d.mts +3 -3
- package/dist/adapters/agui-adapter.d.ts +3 -3
- package/dist/adapters/agui-adapter.js +4 -5
- package/dist/adapters/agui-adapter.js.map +1 -1
- package/dist/adapters/agui-adapter.mjs +4 -5
- package/dist/adapters/agui-adapter.mjs.map +1 -1
- 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 +9 -3
- package/dist/adapters/ai-adapter.d.ts +9 -3
- package/dist/adapters/ai-adapter.js +20 -6
- package/dist/adapters/ai-adapter.js.map +1 -1
- package/dist/adapters/ai-adapter.mjs +20 -6
- package/dist/adapters/ai-adapter.mjs.map +1 -1
- package/dist/adapters/langchain-adapter.d.mts +3 -3
- package/dist/adapters/langchain-adapter.d.ts +3 -3
- package/dist/adapters/langchain-adapter.js +9 -6
- package/dist/adapters/langchain-adapter.js.map +1 -1
- package/dist/adapters/langchain-adapter.mjs +9 -6
- package/dist/adapters/langchain-adapter.mjs.map +1 -1
- package/dist/adapters/mastra-adapter.d.mts +1 -1
- package/dist/adapters/mastra-adapter.d.ts +1 -1
- package/dist/adapters/mastra-adapter.js +5 -1
- package/dist/adapters/mastra-adapter.js.map +1 -1
- package/dist/adapters/mastra-adapter.mjs +5 -1
- package/dist/adapters/mastra-adapter.mjs.map +1 -1
- package/dist/bin/mcp-ts.js +7 -1
- package/dist/bin/mcp-ts.js.map +1 -1
- package/dist/bin/mcp-ts.mjs +7 -1
- package/dist/bin/mcp-ts.mjs.map +1 -1
- package/dist/client/index.d.mts +2 -2
- package/dist/client/index.d.ts +2 -2
- package/dist/client/index.js +9 -13
- package/dist/client/index.js.map +1 -1
- package/dist/client/index.mjs +9 -13
- package/dist/client/index.mjs.map +1 -1
- package/dist/client/react.d.mts +7 -7
- package/dist/client/react.d.ts +7 -7
- package/dist/client/react.js +15 -19
- package/dist/client/react.js.map +1 -1
- package/dist/client/react.mjs +15 -19
- package/dist/client/react.mjs.map +1 -1
- package/dist/client/vue.d.mts +7 -7
- package/dist/client/vue.d.ts +7 -7
- package/dist/client/vue.js +14 -18
- package/dist/client/vue.js.map +1 -1
- package/dist/client/vue.mjs +14 -18
- package/dist/client/vue.mjs.map +1 -1
- package/dist/{index-DhA-OEAe.d.ts → index-C9gvpxy5.d.ts} +5 -5
- package/dist/{index-bFL4ZF2N.d.mts → index-eaH14_5u.d.mts} +5 -5
- package/dist/index.d.mts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +616 -370
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +615 -370
- package/dist/index.mjs.map +1 -1
- package/dist/{multi-session-client-CHE8QpVE.d.ts → multi-session-client-BYtguGJm.d.ts} +22 -22
- package/dist/{multi-session-client-CQsRbxYI.d.mts → multi-session-client-DYNe6az3.d.mts} +22 -22
- package/dist/server/index.d.mts +31 -34
- package/dist/server/index.d.ts +31 -34
- package/dist/server/index.js +531 -256
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +530 -256
- package/dist/server/index.mjs.map +1 -1
- package/dist/shared/index.d.mts +5 -5
- package/dist/shared/index.d.ts +5 -5
- package/dist/shared/index.js +76 -101
- package/dist/shared/index.js.map +1 -1
- package/dist/shared/index.mjs +76 -101
- package/dist/shared/index.mjs.map +1 -1
- package/dist/{tool-router-Dh2804tM.d.ts → tool-router-Ddtybmr0.d.ts} +71 -73
- package/dist/{tool-router-BVaV1udm.d.mts → tool-router-Dnd6IOKC.d.mts} +71 -73
- package/dist/{types-rIuN1CQi.d.mts → types-BCAG20P6.d.mts} +4 -4
- package/dist/{types-rIuN1CQi.d.ts → types-BCAG20P6.d.ts} +4 -4
- package/dist/{utils-0qmYrqoa.d.mts → utils-DELRKQPU.d.mts} +1 -1
- package/dist/{utils-0qmYrqoa.d.ts → utils-DELRKQPU.d.ts} +1 -1
- package/migrations/neon/20260513010000_install_mcp_sessions.sql +69 -0
- package/migrations/neon/20260513020000_add_session_cleanup_cron.sql +35 -0
- package/{supabase/migrations → migrations/supabase}/20260330195700_install_mcp_sessions.sql +7 -9
- package/package.json +14 -5
- package/src/adapters/ai-adapter.ts +30 -1
- package/src/adapters/langchain-adapter.ts +6 -2
- package/src/adapters/mastra-adapter.ts +6 -2
- package/src/bin/mcp-ts.ts +8 -1
- package/src/client/core/app-host.ts +1 -1
- package/src/client/core/sse-client.ts +12 -14
- package/src/client/core/types.ts +1 -1
- package/src/client/react/use-mcp-apps.tsx +1 -1
- package/src/client/react/use-mcp.ts +11 -11
- package/src/client/vue/use-mcp.ts +10 -10
- package/src/server/handlers/nextjs-handler.ts +18 -15
- package/src/server/handlers/sse-handler.ts +29 -29
- package/src/server/index.ts +1 -1
- package/src/server/mcp/multi-session-client.ts +17 -17
- package/src/server/mcp/oauth-client.ts +37 -37
- package/src/server/mcp/storage-oauth-provider.ts +17 -17
- package/src/server/storage/file-backend.ts +25 -25
- package/src/server/storage/index.ts +67 -10
- package/src/server/storage/memory-backend.ts +34 -34
- package/src/server/storage/neon-backend.ts +281 -0
- package/src/server/storage/redis-backend.ts +64 -64
- package/src/server/storage/sqlite-backend.ts +33 -33
- package/src/server/storage/supabase-backend.ts +23 -24
- package/src/server/storage/types.ts +18 -21
- package/src/shared/errors.ts +1 -1
- package/src/shared/index.ts +1 -2
- package/src/shared/meta-tools.ts +4 -6
- package/src/shared/schema-compressor.ts +2 -42
- package/src/shared/tool-index.ts +89 -84
- package/src/shared/tool-router.ts +0 -24
- package/src/shared/types.ts +4 -4
- /package/{supabase/migrations → migrations/supabase}/20260421010000_add_session_cleanup_cron.sql +0 -0
package/dist/client/vue.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { c as SSEClient } from '../index-
|
|
2
|
-
export { A as APP_HOST_DEFAULTS, a as AppHost, D as DEFAULT_MCP_APP_CSP, S as SANDBOX_PROXY_READY_METHOD, b as SANDBOX_RESOURCE_READY_METHOD, d as SSEClientOptions } from '../index-
|
|
1
|
+
import { c as SSEClient } from '../index-eaH14_5u.mjs';
|
|
2
|
+
export { A as APP_HOST_DEFAULTS, a as AppHost, D as DEFAULT_MCP_APP_CSP, S as SANDBOX_PROXY_READY_METHOD, b as SANDBOX_RESOURCE_READY_METHOD, d as SSEClientOptions } from '../index-eaH14_5u.mjs';
|
|
3
3
|
import { c as McpConnectionState, M as McpConnectionEvent } from '../events-CK3N--3g.mjs';
|
|
4
4
|
export { D as Disposable, a as DisposableStore, E as Emitter, b as Event, d as McpObservabilityEvent } from '../events-CK3N--3g.mjs';
|
|
5
|
-
import { v as ToolInfo, k as FinishAuthResult,
|
|
6
|
-
export {
|
|
5
|
+
import { v as ToolInfo, k as FinishAuthResult, o as ListToolsRpcResult, L as ListPromptsResult, m as ListResourcesResult } from '../types-BCAG20P6.mjs';
|
|
6
|
+
export { q as McpRpcRequest, r as McpRpcResponse } from '../types-BCAG20P6.mjs';
|
|
7
7
|
import '@modelcontextprotocol/ext-apps/app-bridge';
|
|
8
8
|
import '@modelcontextprotocol/sdk/types.js';
|
|
9
9
|
|
|
@@ -21,7 +21,7 @@ interface UseMcpOptions {
|
|
|
21
21
|
/**
|
|
22
22
|
* User/Client identifier
|
|
23
23
|
*/
|
|
24
|
-
|
|
24
|
+
userId: string;
|
|
25
25
|
/**
|
|
26
26
|
* Optional auth token
|
|
27
27
|
*/
|
|
@@ -99,7 +99,7 @@ interface McpClient {
|
|
|
99
99
|
serverName: string;
|
|
100
100
|
serverUrl: string;
|
|
101
101
|
callbackUrl: string;
|
|
102
|
-
transportType?: 'sse' | '
|
|
102
|
+
transportType?: 'sse' | 'streamable-http';
|
|
103
103
|
}) => Promise<string>;
|
|
104
104
|
/**
|
|
105
105
|
* Disconnect from an MCP server
|
|
@@ -113,7 +113,7 @@ interface McpClient {
|
|
|
113
113
|
serverName: string;
|
|
114
114
|
serverUrl: string;
|
|
115
115
|
callbackUrl: string;
|
|
116
|
-
transportType?: 'sse' | '
|
|
116
|
+
transportType?: 'sse' | 'streamable-http';
|
|
117
117
|
}) => Promise<string>;
|
|
118
118
|
/**
|
|
119
119
|
* Get connection by session ID
|
package/dist/client/vue.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { c as SSEClient } from '../index-
|
|
2
|
-
export { A as APP_HOST_DEFAULTS, a as AppHost, D as DEFAULT_MCP_APP_CSP, S as SANDBOX_PROXY_READY_METHOD, b as SANDBOX_RESOURCE_READY_METHOD, d as SSEClientOptions } from '../index-
|
|
1
|
+
import { c as SSEClient } from '../index-C9gvpxy5.js';
|
|
2
|
+
export { A as APP_HOST_DEFAULTS, a as AppHost, D as DEFAULT_MCP_APP_CSP, S as SANDBOX_PROXY_READY_METHOD, b as SANDBOX_RESOURCE_READY_METHOD, d as SSEClientOptions } from '../index-C9gvpxy5.js';
|
|
3
3
|
import { c as McpConnectionState, M as McpConnectionEvent } from '../events-CK3N--3g.js';
|
|
4
4
|
export { D as Disposable, a as DisposableStore, E as Emitter, b as Event, d as McpObservabilityEvent } from '../events-CK3N--3g.js';
|
|
5
|
-
import { v as ToolInfo, k as FinishAuthResult,
|
|
6
|
-
export {
|
|
5
|
+
import { v as ToolInfo, k as FinishAuthResult, o as ListToolsRpcResult, L as ListPromptsResult, m as ListResourcesResult } from '../types-BCAG20P6.js';
|
|
6
|
+
export { q as McpRpcRequest, r as McpRpcResponse } from '../types-BCAG20P6.js';
|
|
7
7
|
import '@modelcontextprotocol/ext-apps/app-bridge';
|
|
8
8
|
import '@modelcontextprotocol/sdk/types.js';
|
|
9
9
|
|
|
@@ -21,7 +21,7 @@ interface UseMcpOptions {
|
|
|
21
21
|
/**
|
|
22
22
|
* User/Client identifier
|
|
23
23
|
*/
|
|
24
|
-
|
|
24
|
+
userId: string;
|
|
25
25
|
/**
|
|
26
26
|
* Optional auth token
|
|
27
27
|
*/
|
|
@@ -99,7 +99,7 @@ interface McpClient {
|
|
|
99
99
|
serverName: string;
|
|
100
100
|
serverUrl: string;
|
|
101
101
|
callbackUrl: string;
|
|
102
|
-
transportType?: 'sse' | '
|
|
102
|
+
transportType?: 'sse' | 'streamable-http';
|
|
103
103
|
}) => Promise<string>;
|
|
104
104
|
/**
|
|
105
105
|
* Disconnect from an MCP server
|
|
@@ -113,7 +113,7 @@ interface McpClient {
|
|
|
113
113
|
serverName: string;
|
|
114
114
|
serverUrl: string;
|
|
115
115
|
callbackUrl: string;
|
|
116
|
-
transportType?: 'sse' | '
|
|
116
|
+
transportType?: 'sse' | 'streamable-http';
|
|
117
117
|
}) => Promise<string>;
|
|
118
118
|
/**
|
|
119
119
|
* Get connection by session ID
|
package/dist/client/vue.js
CHANGED
|
@@ -29,8 +29,8 @@ var SSEClient = class {
|
|
|
29
29
|
isConnected() {
|
|
30
30
|
return this.connected;
|
|
31
31
|
}
|
|
32
|
-
async
|
|
33
|
-
return this.sendRequest("
|
|
32
|
+
async listSessions() {
|
|
33
|
+
return this.sendRequest("listSessions");
|
|
34
34
|
}
|
|
35
35
|
async connectToServer(params) {
|
|
36
36
|
return this.sendRequest("connect", params);
|
|
@@ -46,8 +46,8 @@ var SSEClient = class {
|
|
|
46
46
|
this.emitUiEventIfPresent(result, sessionId, toolName);
|
|
47
47
|
return result;
|
|
48
48
|
}
|
|
49
|
-
async
|
|
50
|
-
return this.sendRequest("
|
|
49
|
+
async getSession(sessionId) {
|
|
50
|
+
return this.sendRequest("getSession", { sessionId });
|
|
51
51
|
}
|
|
52
52
|
async finishAuth(sessionId, code) {
|
|
53
53
|
return this.sendRequest("finishAuth", { sessionId, code });
|
|
@@ -113,7 +113,7 @@ var SSEClient = class {
|
|
|
113
113
|
return this.parseRpcResponse(data2);
|
|
114
114
|
}
|
|
115
115
|
const data = await this.readRpcResponseFromStream(response, {
|
|
116
|
-
delayConnectionEvents: method === "connect" || method === "
|
|
116
|
+
delayConnectionEvents: method === "connect" || method === "getSession" || method === "finishAuth"
|
|
117
117
|
});
|
|
118
118
|
return this.parseRpcResponse(data);
|
|
119
119
|
}
|
|
@@ -203,17 +203,13 @@ var SSEClient = class {
|
|
|
203
203
|
throw new Error("Invalid RPC response format");
|
|
204
204
|
}
|
|
205
205
|
buildUrl() {
|
|
206
|
-
|
|
207
|
-
url.searchParams.set("identity", this.options.identity);
|
|
208
|
-
if (this.options.authToken) {
|
|
209
|
-
url.searchParams.set("token", this.options.authToken);
|
|
210
|
-
}
|
|
211
|
-
return url.toString();
|
|
206
|
+
return new URL(this.options.url, globalThis.location?.origin).toString();
|
|
212
207
|
}
|
|
213
208
|
buildHeaders() {
|
|
214
209
|
const headers = {
|
|
215
210
|
"Content-Type": "application/json",
|
|
216
|
-
"Accept": "text/event-stream"
|
|
211
|
+
"Accept": "text/event-stream",
|
|
212
|
+
"x-mcp-user-id": this.options.userId
|
|
217
213
|
};
|
|
218
214
|
if (this.options.authToken) {
|
|
219
215
|
headers["Authorization"] = `Bearer ${this.options.authToken}`;
|
|
@@ -260,7 +256,7 @@ var SSEClient = class {
|
|
|
260
256
|
function useMcp(options) {
|
|
261
257
|
const {
|
|
262
258
|
url,
|
|
263
|
-
|
|
259
|
+
userId,
|
|
264
260
|
authToken,
|
|
265
261
|
autoConnect = true,
|
|
266
262
|
autoInitialize = true,
|
|
@@ -366,7 +362,7 @@ function useMcp(options) {
|
|
|
366
362
|
if (!clientRef.value) return;
|
|
367
363
|
try {
|
|
368
364
|
isInitializing.value = true;
|
|
369
|
-
const result = await clientRef.value.
|
|
365
|
+
const result = await clientRef.value.listSessions();
|
|
370
366
|
const sessions = result.sessions || [];
|
|
371
367
|
if (isMountedRef.value) {
|
|
372
368
|
connections.value = sessions.map((s) => ({
|
|
@@ -388,7 +384,7 @@ function useMcp(options) {
|
|
|
388
384
|
return;
|
|
389
385
|
}
|
|
390
386
|
suppressAuthRedirectSessions.value.add(session.sessionId);
|
|
391
|
-
await clientRef.value.
|
|
387
|
+
await clientRef.value.getSession(session.sessionId);
|
|
392
388
|
} catch (error) {
|
|
393
389
|
console.error(`[useMcp] Failed to validate session ${session.sessionId}:`, error);
|
|
394
390
|
} finally {
|
|
@@ -412,7 +408,7 @@ function useMcp(options) {
|
|
|
412
408
|
}
|
|
413
409
|
const clientOptions = {
|
|
414
410
|
url,
|
|
415
|
-
|
|
411
|
+
userId,
|
|
416
412
|
authToken,
|
|
417
413
|
onConnectionEvent: (event) => {
|
|
418
414
|
updateConnectionsFromEvent(event);
|
|
@@ -497,7 +493,7 @@ function useMcp(options) {
|
|
|
497
493
|
throw new Error("SSE client not initialized");
|
|
498
494
|
}
|
|
499
495
|
suppressAuthRedirectSessions.value.delete(sessionId);
|
|
500
|
-
await clientRef.value.
|
|
496
|
+
await clientRef.value.getSession(sessionId);
|
|
501
497
|
};
|
|
502
498
|
const callTool = async (sessionId, toolName, toolArgs) => {
|
|
503
499
|
if (!clientRef.value) {
|
|
@@ -991,7 +987,7 @@ var AppHost = class {
|
|
|
991
987
|
async getSessionId() {
|
|
992
988
|
if (this.sessionId) return this.sessionId;
|
|
993
989
|
if (!this.client) return void 0;
|
|
994
|
-
const result = await this.client.
|
|
990
|
+
const result = await this.client.listSessions();
|
|
995
991
|
return result.sessions?.[0]?.sessionId;
|
|
996
992
|
}
|
|
997
993
|
isMcpUri(url) {
|