UNPKG

@civic/hub-bridge

Version:

Stdio <-> HTTP/SSE MCP bridge with Civic auth handling

28 lines 1.28 kB
import { CLIClient, RestartableStreamableHTTPClientTransport } from "@civic/auth-mcp/client"; import { CLIAuthProviderSingleton } from "../auth/cli-auth-provider-singleton.js"; import { ConfigManager } from "../lib/ConfigManager.js"; /** * Create a client that connects to the target MCP server */ export async function createTargetClient(targetConfig) { // Use the singleton auth provider const authProvider = CLIAuthProviderSingleton.getInstance(); // Get current profile if set const currentProfile = await ConfigManager.getInstance().getCurrentProfileAlias(); // Create the transport with auth provider const serverUrl = new URL(targetConfig.url); const transport = new RestartableStreamableHTTPClientTransport(serverUrl, { authProvider, requestInit: { headers: { "x-civic-profile": currentProfile || "default", // Use default profile if none set }, } }); // Create and connect client with built-in auth handling const mcpClient = new CLIClient({ name: "hub-bridge", version: "0.0.1" }, { capabilities: {} }); // Connect to the server - this will trigger auth if needed await mcpClient.connect(transport); return mcpClient; } //# sourceMappingURL=index.js.map