MCPcopy Create free account
hub / github.com/TanStack/ai / createMCPClient

Function createMCPClient

packages/ai-mcp/src/client.ts:231–245  ·  view source on GitHub ↗
(options: MCPClientOptions)

Source from the content-addressed store, hash-verified

229}
230
231export 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). */
248export async function createMCPClientFromTransport<

Callers 14

createMCPClientsFunction · 0.90
createMcpAppCallHandlerFunction · 0.90
client.test.tsFile · 0.90
api.mcp-manual.tsFile · 0.90
probeFunction · 0.90
tryConnectFunction · 0.90
tryConnectFunction · 0.90
api.mcp-chat.tsFile · 0.90
api.mcp-test.tsFile · 0.90

Calls 3

connectMethod · 0.95
resolveTransportFunction · 0.90
isTransportInstanceFunction · 0.90

Tested by

no test coverage detected