/**
 * 传输层工厂
 */

import type { Transport, MCPServerConfig, LocalMCPServer } from '../types.js';
import { StdioTransport } from './stdio.js';

/**
 * 创建传输层实例
 */
export function createTransport(
  serverName: string,
  config: MCPServerConfig
): Transport {
  if (config.type === 'local') {
    return new StdioTransport(config as LocalMCPServer, serverName);
  }

  if (config.type === 'remote') {
    // TODO: 实现 HTTP 传输
    throw new Error('Remote transport not yet implemented');
  }

  throw new Error(`Unknown transport type: ${(config as MCPServerConfig).type}`);
}

export { StdioTransport } from './stdio.js';
