@toolprint/hypertool-mcp
Version:
HyperTool MCP proxy server for routing requests between clients and multiple underlying MCP servers
57 lines • 1.81 kB
JavaScript
/**
* Connection factory for creating transport-specific connections
*/
import { StdioConnection } from "./clients/stdio.js";
import { HttpConnection } from "./clients/http.js";
import { SSEConnection } from "./clients/sse.js";
/**
* Factory for creating connections based on server configuration
*/
export class ConnectionFactory {
/**
* Create a connection based on server configuration
*/
createConnection(serverName, config, options = {}) {
switch (config.type) {
case "stdio":
return new StdioConnection(serverName, config, options);
case "http":
return new HttpConnection(serverName, config, options);
case "sse":
return new SSEConnection(serverName, config, options);
default:
throw new Error(`Unsupported transport type: ${config.type}`);
}
}
/**
* Create a stdio connection
*/
createStdioConnection(serverName, config, options = {}) {
return new StdioConnection(serverName, config, options);
}
/**
* Create an HTTP connection
*/
createHttpConnection(serverName, config, options = {}) {
return new HttpConnection(serverName, config, options);
}
/**
* Create an SSE connection
*/
createSSEConnection(serverName, config, options = {}) {
return new SSEConnection(serverName, config, options);
}
/**
* Validate if a server configuration is supported
*/
isConfigSupported(config) {
return (config.type === "stdio" || config.type === "http" || config.type === "sse");
}
/**
* Get supported transport types
*/
getSupportedTransports() {
return ["stdio", "http", "sse"];
}
}
//# sourceMappingURL=factory.js.map