UNPKG

@copilotkit/runtime

Version:

<img src="https://github.com/user-attachments/assets/0a6b64d9-e193-4940-a3f6-60334ac34084" alt="banner" style="border-radius: 12px; border: 2px solid #d6d4fa;" />

23 lines (21 loc) 1.28 kB
require("reflect-metadata"); //#region src/v2/runtime/handlers/shared/mcp-apps-servers.ts const UNSUPPORTED_POLICY_KEYS = ["includeTools", "excludeTools"]; const MCP_APPS_MIDDLEWARE_VERSION = "@ag-ui/mcp-apps-middleware@0.0.3"; const MCP_APPS_POLICY_ISSUE = "https://github.com/CopilotKit/CopilotKit/issues/5930"; /** * Select the servers for an agent and validate the policy boundary owned by * the installed MCP Apps middleware. */ function resolveMcpAppsServers(servers, agentId) { const violations = []; for (const [index, server] of servers.entries()) { const config = server; for (const key of UNSUPPORTED_POLICY_KEYS) if (Object.prototype.hasOwnProperty.call(config, key) && config[key] !== void 0) violations.push(`${key} at server[${index}] (${server.serverId ?? server.url})`); } if (violations.length > 0) throw new Error(`Unsupported MCP Apps tool policy: ${violations.join(", ")}. ${MCP_APPS_MIDDLEWARE_VERSION} owns per-server tool policy and does not support these keys; see ${MCP_APPS_POLICY_ISSUE}.`); return servers.filter((server) => !server.agentId || server.agentId === agentId).map(({ agentId: _agentId, ...server }) => server); } //#endregion exports.resolveMcpAppsServers = resolveMcpAppsServers; //# sourceMappingURL=mcp-apps-servers.cjs.map