Skip to main content
Use the TypeScript MCP client when your app needs to connect to one or more MCP servers. MCPClient stores server configuration, and each MCPSession is one live connection where you list tools, call tools, read resources, and fetch prompts. This page helps you choose the right client path and make your first call. For every constructor option and method signature, see the MCPClient API reference and MCPSession API reference.

Choose your client path

Node.js clients support HTTP and Standard I/O servers. Browser and React clients support HTTP servers.

Install

Connect and call a tool

This Node.js example connects to one HTTP server, lists available tools, calls one tool, and closes the connection.
Replace echo and its arguments with a tool returned by listTools(). createSession("demo") throws when demo is not configured.

How the client is organized

MCPClient is the configuration and lifecycle object. Create it once, then use it to add servers, open sessions, close sessions, or enable callbacks such as sampling and elicitation. MCPSession is the protocol object. Use a session to call tools, read resources, fetch prompts, subscribe to notifications, and set roots for one server.
To connect to every configured server, use createAllSessions(). To retrieve a session you already opened, use getSession(name), which returns null when no session exists.

Configure servers

Each entry under mcpServers is named by you. The fields inside the entry determine the transport.
Use url for a remote HTTP server. Use command and args for a local Standard I/O server. See the MCPClient API reference for every server config field, constructor option, callback, and lifecycle method.

Next steps

MCPClient reference

Server config fields, constructor options, callbacks, session lifecycle, and code mode methods.

Call tools

List server tools, call one by name, handle results, and set request timeouts.

Read resources

List, read, and subscribe to server resources.

Fetch prompts

Retrieve prompt templates and pass prompt arguments.

Handle sampling

Let servers request LLM completions through your client callback.

Handle elicitation

Respond when servers ask the user for structured input or a URL action.

Use React

Manage browser MCP connections with McpClientProvider and hooks.