(options: MCPClientOptions)
| 229 | } |
| 230 | |
| 231 | export async function createMCPClient< |
| 232 | TServer extends ServerDescriptor = AutomaticDescriptor, |
| 233 | >(options: MCPClientOptions): Promise<MCPClient<TServer>> { |
| 234 | const transport = await resolveTransport(options.transport) |
| 235 | const impl = new MCPClientImpl<TServer>( |
| 236 | options.prefix, |
| 237 | options.name, |
| 238 | options.version, |
| 239 | // Only a serializable config is reconnectable; a ready-made Transport |
| 240 | // instance is single-use, so it is not retained as a descriptor. |
| 241 | isTransportInstance(options.transport) ? undefined : options.transport, |
| 242 | ) |
| 243 | await impl.connect(transport) |
| 244 | return impl |
| 245 | } |
| 246 | |
| 247 | /** Test-only: connect directly from a transport instance (skips resolveTransport). */ |
| 248 | export async function createMCPClientFromTransport< |
no test coverage detected