UNPKG

@pluggedin/pluggedin-mcp-proxy

Version:

Unified MCP proxy that aggregates all your MCP servers (STDIO, SSE, Streamable HTTP) into one powerful interface. Access any tool through a single connection, search across unified documents with built-in RAG, and receive notifications from any model. Tes

79 lines (78 loc) 3.15 kB
import { debugLog, debugError } from "./debug-log.js"; /** * Enriches a connected client with server capabilities */ export async function enrichSession(connectedClient, serverUuid, params) { try { debugLog(`[SessionEnrichment] Enriching session for ${params.name || serverUuid}`); // Get server capabilities by listing tools, prompts, resources let serverCapabilities = {}; try { // List tools const toolsResponse = await connectedClient.client.request({ method: "tools/list", params: {} }, {}); serverCapabilities.tools = toolsResponse?.tools || []; debugLog(`[SessionEnrichment] Found ${serverCapabilities.tools?.length || 0} tools`); } catch (error) { debugError(`[SessionEnrichment] Failed to list tools:`, error); } try { // List prompts const promptsResponse = await connectedClient.client.request({ method: "prompts/list", params: {} }, {}); serverCapabilities.prompts = promptsResponse?.prompts || []; debugLog(`[SessionEnrichment] Found ${serverCapabilities.prompts?.length || 0} prompts`); } catch (error) { debugError(`[SessionEnrichment] Failed to list prompts:`, error); } try { // List resources const resourcesResponse = await connectedClient.client.request({ method: "resources/list", params: {} }, {}); serverCapabilities.resources = resourcesResponse?.resources || []; debugLog(`[SessionEnrichment] Found ${serverCapabilities.resources?.length || 0} resources`); } catch (error) { debugError(`[SessionEnrichment] Failed to list resources:`, error); } try { // List resource templates const templatesResponse = await connectedClient.client.request({ method: "resourceTemplates/list", params: {} }, {}); serverCapabilities.resourceTemplates = templatesResponse?.resourceTemplates || []; debugLog(`[SessionEnrichment] Found ${serverCapabilities.resourceTemplates?.length || 0} resource templates`); } catch (error) { debugError(`[SessionEnrichment] Failed to list resource templates:`, error); } // Create enriched session const enrichedSession = { client: connectedClient.client, serverUuid, serverName: params.name || serverUuid, serverCapabilities, cleanup: connectedClient.cleanup }; return enrichedSession; } catch (error) { debugError(`[SessionEnrichment] Failed to enrich session:`, error); // Return basic session even if enrichment fails return { client: connectedClient.client, serverUuid, serverName: params.name || serverUuid, cleanup: connectedClient.cleanup }; } }