@mcp-ts/sdk 2.2.0 → 2.3.1
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 +1 -1
- package/dist/adapters/agui-adapter.d.ts +1 -1
- package/dist/adapters/agui-adapter.js +9 -5
- package/dist/adapters/agui-adapter.js.map +1 -1
- package/dist/adapters/agui-adapter.mjs +9 -5
- package/dist/adapters/agui-adapter.mjs.map +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/ai-adapter.js +9 -5
- package/dist/adapters/ai-adapter.js.map +1 -1
- package/dist/adapters/ai-adapter.mjs +9 -5
- package/dist/adapters/ai-adapter.mjs.map +1 -1
- package/dist/adapters/langchain-adapter.d.mts +1 -1
- package/dist/adapters/langchain-adapter.d.ts +1 -1
- package/dist/adapters/langchain-adapter.js +9 -5
- package/dist/adapters/langchain-adapter.js.map +1 -1
- package/dist/adapters/langchain-adapter.mjs +9 -5
- package/dist/adapters/langchain-adapter.mjs.map +1 -1
- package/dist/client/react.js.map +1 -1
- package/dist/client/react.mjs.map +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +83 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +83 -7
- package/dist/index.mjs.map +1 -1
- package/dist/server/index.d.mts +13 -1
- package/dist/server/index.d.ts +13 -1
- package/dist/server/index.js +66 -1
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +66 -2
- 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 +17 -5
- package/dist/shared/index.js.map +1 -1
- package/dist/shared/index.mjs +17 -5
- package/dist/shared/index.mjs.map +1 -1
- package/dist/{tool-router-C8hIA-tg.d.mts → tool-router-BfE_9tay.d.mts} +5 -0
- package/dist/{tool-router-CdX8e9bk.d.ts → tool-router-CP7qLk1J.d.ts} +5 -0
- package/package.json +1 -1
- package/src/server/index.ts +8 -1
- package/src/server/storage/index.ts +77 -2
- package/src/server/storage/types.ts +14 -0
- package/src/shared/meta-tools.ts +16 -7
- package/src/shared/tool-router.ts +13 -0
package/dist/index.d.mts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
export { M as MCPClient, a as MultiSessionClient, S as StorageOAuthClientProvider } from './multi-session-client-DYNe6az3.mjs';
|
|
2
2
|
export { A as AuthenticationError, C as ConfigurationError, a as ConnectionError, I as InvalidStateError, M as McpError, N as NotConnectedError, R as RpcErrorCode, b as RpcErrorCodes, S as SessionNotFoundError, c as SessionValidationError, T as ToolExecutionError, U as UnauthorizedError, s as sanitizeServerLabel } from './utils-DELRKQPU.mjs';
|
|
3
|
-
export { ClientMetadata, NextMcpHandlerOptions, SSEConnectionManager, SSEHandlerOptions, SessionStore, createNextMcpHandler, createSSEHandler, sessions } from './server/index.mjs';
|
|
3
|
+
export { ClientMetadata, NextMcpHandlerOptions, SSEConnectionManager, SSEHandlerOptions, Session, SessionMutationEvent, SessionMutationListener, SessionMutationType, SessionStore, createNextMcpHandler, createSSEHandler, onSessionMutation, sessions } from './server/index.mjs';
|
|
4
4
|
export { D as Disposable, a as DisposableStore, E as Emitter, b as Event, M as McpConnectionEvent, c as McpConnectionState, d as McpObservabilityEvent } from './events-CK3N--3g.mjs';
|
|
5
5
|
export { C as CallToolParams, a as CallToolRequest, b as CallToolResponse, c as ConnectAuthRequiredResponse, d as ConnectErrorResponse, e as ConnectParams, f as ConnectRequest, g as ConnectResponse, h as ConnectResult, i as ConnectSuccessResponse, D as DisconnectParams, j as DisconnectResult, F as FinishAuthParams, k as FinishAuthResult, G as GetPromptParams, l as GetSessionResult, L as ListPromptsResult, m as ListResourcesResult, n as ListToolsResponse, o as ListToolsRpcResult, M as McpRpcMethod, p as McpRpcParams, q as McpRpcRequest, r as McpRpcResponse, R as ReadResourceParams, S as SessionInfo, s as SessionListResult, t as SessionParams, T as ToolClient, u as ToolClientProvider, v as ToolInfo, w as TransportType, x as isCallToolSuccess, y as isConnectAuthRequired, z as isConnectError, A as isConnectSuccess, B as isListToolsSuccess } from './types-CxFaaZrM.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
|
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, c as SSEClient, d as SSEClientOptions } from './index-Cfjsme-a.mjs';
|
|
9
9
|
export { CallToolFn, DEFAULT_CLIENT_NAME, DEFAULT_CLIENT_URI, DEFAULT_HEARTBEAT_INTERVAL_MS, DEFAULT_LOGO_URI, DEFAULT_POLICY_URI, MCP_CLIENT_NAME, MCP_CLIENT_VERSION, REDIS_KEY_PREFIX, SESSION_TTL_SECONDS, SOFTWARE_ID, SOFTWARE_VERSION, STATE_EXPIRATION_MS, TOKEN_EXPIRY_BUFFER_MS, ToolUiConfig, createExecuteToolDefinition, createGetSchemaToolDefinition, createListServersToolDefinition, createRegexSearchToolDefinition, createSearchToolDefinition, executeMetaTool, findToolByName, getToolUiResourceUri, isMetaTool, resolveMetaToolProxy } from './shared/index.mjs';
|
|
10
|
-
export { C as CompactTool, E as EmbedFn, I as IndexedTool, S as SchemaCompressor, T as ToolGroupInfo, a as ToolIndex, b as ToolIndexOptions, c as ToolListResult, d as ToolRouter, e as ToolRouterClientInput, f as ToolRouterOptions, g as ToolRouterStrategy, h as ToolSearchOptions, i as ToolServerSummary, j as ToolSummary } from './tool-router-
|
|
10
|
+
export { C as CompactTool, E as EmbedFn, I as IndexedTool, S as SchemaCompressor, T as ToolGroupInfo, a as ToolIndex, b as ToolIndexOptions, c as ToolListResult, d as ToolRouter, e as ToolRouterClientInput, f as ToolRouterOptions, g as ToolRouterStrategy, h as ToolSearchOptions, i as ToolServerSummary, j as ToolSummary } from './tool-router-BfE_9tay.mjs';
|
|
11
11
|
import '@modelcontextprotocol/sdk/client/auth.js';
|
|
12
12
|
import '@modelcontextprotocol/ext-apps/app-bridge';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
export { M as MCPClient, a as MultiSessionClient, S as StorageOAuthClientProvider } from './multi-session-client-BYtguGJm.js';
|
|
2
2
|
export { A as AuthenticationError, C as ConfigurationError, a as ConnectionError, I as InvalidStateError, M as McpError, N as NotConnectedError, R as RpcErrorCode, b as RpcErrorCodes, S as SessionNotFoundError, c as SessionValidationError, T as ToolExecutionError, U as UnauthorizedError, s as sanitizeServerLabel } from './utils-DELRKQPU.js';
|
|
3
|
-
export { ClientMetadata, NextMcpHandlerOptions, SSEConnectionManager, SSEHandlerOptions, SessionStore, createNextMcpHandler, createSSEHandler, sessions } from './server/index.js';
|
|
3
|
+
export { ClientMetadata, NextMcpHandlerOptions, SSEConnectionManager, SSEHandlerOptions, Session, SessionMutationEvent, SessionMutationListener, SessionMutationType, SessionStore, createNextMcpHandler, createSSEHandler, onSessionMutation, sessions } from './server/index.js';
|
|
4
4
|
export { D as Disposable, a as DisposableStore, E as Emitter, b as Event, M as McpConnectionEvent, c as McpConnectionState, d as McpObservabilityEvent } from './events-CK3N--3g.js';
|
|
5
5
|
export { C as CallToolParams, a as CallToolRequest, b as CallToolResponse, c as ConnectAuthRequiredResponse, d as ConnectErrorResponse, e as ConnectParams, f as ConnectRequest, g as ConnectResponse, h as ConnectResult, i as ConnectSuccessResponse, D as DisconnectParams, j as DisconnectResult, F as FinishAuthParams, k as FinishAuthResult, G as GetPromptParams, l as GetSessionResult, L as ListPromptsResult, m as ListResourcesResult, n as ListToolsResponse, o as ListToolsRpcResult, M as McpRpcMethod, p as McpRpcParams, q as McpRpcRequest, r as McpRpcResponse, R as ReadResourceParams, S as SessionInfo, s as SessionListResult, t as SessionParams, T as ToolClient, u as ToolClientProvider, v as ToolInfo, w as TransportType, x as isCallToolSuccess, y as isConnectAuthRequired, z as isConnectError, A as isConnectSuccess, B as isListToolsSuccess } from './types-CxFaaZrM.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
|
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, c as SSEClient, d as SSEClientOptions } from './index-CmjMd2ac.js';
|
|
9
9
|
export { CallToolFn, DEFAULT_CLIENT_NAME, DEFAULT_CLIENT_URI, DEFAULT_HEARTBEAT_INTERVAL_MS, DEFAULT_LOGO_URI, DEFAULT_POLICY_URI, MCP_CLIENT_NAME, MCP_CLIENT_VERSION, REDIS_KEY_PREFIX, SESSION_TTL_SECONDS, SOFTWARE_ID, SOFTWARE_VERSION, STATE_EXPIRATION_MS, TOKEN_EXPIRY_BUFFER_MS, ToolUiConfig, createExecuteToolDefinition, createGetSchemaToolDefinition, createListServersToolDefinition, createRegexSearchToolDefinition, createSearchToolDefinition, executeMetaTool, findToolByName, getToolUiResourceUri, isMetaTool, resolveMetaToolProxy } from './shared/index.js';
|
|
10
|
-
export { C as CompactTool, E as EmbedFn, I as IndexedTool, S as SchemaCompressor, T as ToolGroupInfo, a as ToolIndex, b as ToolIndexOptions, c as ToolListResult, d as ToolRouter, e as ToolRouterClientInput, f as ToolRouterOptions, g as ToolRouterStrategy, h as ToolSearchOptions, i as ToolServerSummary, j as ToolSummary } from './tool-router-
|
|
10
|
+
export { C as CompactTool, E as EmbedFn, I as IndexedTool, S as SchemaCompressor, T as ToolGroupInfo, a as ToolIndex, b as ToolIndexOptions, c as ToolListResult, d as ToolRouter, e as ToolRouterClientInput, f as ToolRouterOptions, g as ToolRouterStrategy, h as ToolSearchOptions, i as ToolServerSummary, j as ToolSummary } from './tool-router-CP7qLk1J.js';
|
|
11
11
|
import '@modelcontextprotocol/sdk/client/auth.js';
|
|
12
12
|
import '@modelcontextprotocol/ext-apps/app-bridge';
|
package/dist/index.js
CHANGED
|
@@ -1242,6 +1242,59 @@ function warnIfNeonConnectionStringIsInsecure(connectionString) {
|
|
|
1242
1242
|
}
|
|
1243
1243
|
var storageInstance = null;
|
|
1244
1244
|
var storagePromise = null;
|
|
1245
|
+
var sessionMutationListeners = /* @__PURE__ */ new Set();
|
|
1246
|
+
function emitSessionMutation(event) {
|
|
1247
|
+
for (const listener of sessionMutationListeners) {
|
|
1248
|
+
try {
|
|
1249
|
+
const result = listener(event);
|
|
1250
|
+
if (result && typeof result.catch === "function") {
|
|
1251
|
+
void result.catch((error) => {
|
|
1252
|
+
console.error("[mcp-ts][Storage] Session mutation listener failed:", error);
|
|
1253
|
+
});
|
|
1254
|
+
}
|
|
1255
|
+
} catch (error) {
|
|
1256
|
+
console.error("[mcp-ts][Storage] Session mutation listener failed:", error);
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1259
|
+
}
|
|
1260
|
+
function createSessionMutationEvent(prop, args) {
|
|
1261
|
+
const timestamp = Date.now();
|
|
1262
|
+
if (prop === "create") {
|
|
1263
|
+
const [session, ttl] = args;
|
|
1264
|
+
if (!session?.userId || !session?.sessionId) return null;
|
|
1265
|
+
return {
|
|
1266
|
+
type: "create",
|
|
1267
|
+
userId: session.userId,
|
|
1268
|
+
sessionId: session.sessionId,
|
|
1269
|
+
session,
|
|
1270
|
+
ttl,
|
|
1271
|
+
timestamp
|
|
1272
|
+
};
|
|
1273
|
+
}
|
|
1274
|
+
if (prop === "update") {
|
|
1275
|
+
const [userId, sessionId, patch, ttl] = args;
|
|
1276
|
+
if (!userId || !sessionId) return null;
|
|
1277
|
+
return {
|
|
1278
|
+
type: "update",
|
|
1279
|
+
userId,
|
|
1280
|
+
sessionId,
|
|
1281
|
+
patch,
|
|
1282
|
+
ttl,
|
|
1283
|
+
timestamp
|
|
1284
|
+
};
|
|
1285
|
+
}
|
|
1286
|
+
if (prop === "delete") {
|
|
1287
|
+
const [userId, sessionId] = args;
|
|
1288
|
+
if (!userId || !sessionId) return null;
|
|
1289
|
+
return {
|
|
1290
|
+
type: "delete",
|
|
1291
|
+
userId,
|
|
1292
|
+
sessionId,
|
|
1293
|
+
timestamp
|
|
1294
|
+
};
|
|
1295
|
+
}
|
|
1296
|
+
return null;
|
|
1297
|
+
}
|
|
1245
1298
|
async function initializeStorage(store) {
|
|
1246
1299
|
if (typeof store.init === "function") {
|
|
1247
1300
|
await store.init();
|
|
@@ -1379,13 +1432,24 @@ async function getStorage() {
|
|
|
1379
1432
|
storageInstance = await storagePromise;
|
|
1380
1433
|
return storageInstance;
|
|
1381
1434
|
}
|
|
1435
|
+
function onSessionMutation(listener) {
|
|
1436
|
+
sessionMutationListeners.add(listener);
|
|
1437
|
+
return () => {
|
|
1438
|
+
sessionMutationListeners.delete(listener);
|
|
1439
|
+
};
|
|
1440
|
+
}
|
|
1382
1441
|
var sessions = new Proxy({}, {
|
|
1383
1442
|
get(_target, prop) {
|
|
1384
1443
|
return async (...args) => {
|
|
1385
1444
|
const instance = await getStorage();
|
|
1386
1445
|
const value = instance[prop];
|
|
1387
1446
|
if (typeof value === "function") {
|
|
1388
|
-
|
|
1447
|
+
const result = await value.apply(instance, args);
|
|
1448
|
+
const event = createSessionMutationEvent(prop, args);
|
|
1449
|
+
if (event) {
|
|
1450
|
+
emitSessionMutation(event);
|
|
1451
|
+
}
|
|
1452
|
+
return result;
|
|
1389
1453
|
}
|
|
1390
1454
|
return value;
|
|
1391
1455
|
};
|
|
@@ -4790,8 +4854,13 @@ function createExecuteToolDefinition() {
|
|
|
4790
4854
|
};
|
|
4791
4855
|
}
|
|
4792
4856
|
async function executeMetaTool(toolName, args, router, callToolFn) {
|
|
4793
|
-
const resolveToolSchema = (name, namespace, options) => {
|
|
4857
|
+
const resolveToolSchema = async (name, namespace, options) => {
|
|
4794
4858
|
try {
|
|
4859
|
+
if (typeof router.resolveToolSchema === "function") {
|
|
4860
|
+
return {
|
|
4861
|
+
tool: await router.resolveToolSchema(name, namespace, options)
|
|
4862
|
+
};
|
|
4863
|
+
}
|
|
4795
4864
|
return { tool: router.getToolSchema(name, namespace, options) };
|
|
4796
4865
|
} catch (err) {
|
|
4797
4866
|
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
@@ -4843,13 +4912,12 @@ async function executeMetaTool(toolName, args, router, callToolFn) {
|
|
|
4843
4912
|
const searchOptions = { serverId, serverName };
|
|
4844
4913
|
const selectMatch = query.match(/^select:(.+)$/i);
|
|
4845
4914
|
if (selectMatch) {
|
|
4846
|
-
await router.listTools({ serverId, serverName, limit: 1 });
|
|
4847
4915
|
const requested = selectMatch[1].split(",").map((s) => s.trim()).filter(Boolean);
|
|
4848
4916
|
const found = [];
|
|
4849
4917
|
const errors = [];
|
|
4850
4918
|
const namespace = serverId ?? serverName;
|
|
4851
4919
|
for (const requestedToolName of requested) {
|
|
4852
|
-
const { tool, error } = resolveToolSchema(requestedToolName, namespace, {
|
|
4920
|
+
const { tool, error } = await resolveToolSchema(requestedToolName, namespace, {
|
|
4853
4921
|
allowServerNameFragment: Boolean(serverName && !serverId)
|
|
4854
4922
|
});
|
|
4855
4923
|
if (error) {
|
|
@@ -4913,7 +4981,7 @@ async function executeMetaTool(toolName, args, router, callToolFn) {
|
|
|
4913
4981
|
case "mcp_get_tool_schema": {
|
|
4914
4982
|
const name = String(args.toolName ?? "");
|
|
4915
4983
|
const namespace = String(args.serverId ?? "") || void 0;
|
|
4916
|
-
const { tool, error } = resolveToolSchema(name, namespace);
|
|
4984
|
+
const { tool, error } = await resolveToolSchema(name, namespace);
|
|
4917
4985
|
if (error) {
|
|
4918
4986
|
return error;
|
|
4919
4987
|
}
|
|
@@ -4955,7 +5023,7 @@ async function executeMetaTool(toolName, args, router, callToolFn) {
|
|
|
4955
5023
|
isError: true
|
|
4956
5024
|
};
|
|
4957
5025
|
}
|
|
4958
|
-
const { tool, error } = resolveToolSchema(targetToolName, namespace);
|
|
5026
|
+
const { tool, error } = await resolveToolSchema(targetToolName, namespace);
|
|
4959
5027
|
if (error) {
|
|
4960
5028
|
return error;
|
|
4961
5029
|
}
|
|
@@ -5132,6 +5200,14 @@ var ToolRouter = class {
|
|
|
5132
5200
|
}
|
|
5133
5201
|
return matches[0];
|
|
5134
5202
|
}
|
|
5203
|
+
/**
|
|
5204
|
+
* Resolve the full tool definition by name, ensuring the router index has
|
|
5205
|
+
* been initialized first.
|
|
5206
|
+
*/
|
|
5207
|
+
async resolveToolSchema(toolName, namespace, options = {}) {
|
|
5208
|
+
await this.ensureInitialized();
|
|
5209
|
+
return this.getToolSchema(toolName, namespace, options);
|
|
5210
|
+
}
|
|
5135
5211
|
/**
|
|
5136
5212
|
* Get compact (schema-less) summaries for all tools.
|
|
5137
5213
|
*/
|
|
@@ -5383,6 +5459,7 @@ exports.isConnectError = isConnectError;
|
|
|
5383
5459
|
exports.isConnectSuccess = isConnectSuccess;
|
|
5384
5460
|
exports.isListToolsSuccess = isListToolsSuccess;
|
|
5385
5461
|
exports.isMetaTool = isMetaTool;
|
|
5462
|
+
exports.onSessionMutation = onSessionMutation;
|
|
5386
5463
|
exports.resolveMetaToolProxy = resolveMetaToolProxy;
|
|
5387
5464
|
exports.sanitizeServerLabel = sanitizeServerLabel;
|
|
5388
5465
|
exports.sessions = sessions;
|