> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mcp-use.com/llms.txt
> Use this file to discover all available pages before exploring further.

# MCP Client

> Connect a TypeScript app to MCP servers and call tools, resources, and prompts.

`@mcp-use/client` connects your app to one or more MCP servers. By default, HTTP
connections negotiate the server's supported MCP protocol automatically and
stdio connections use the sessionful protocol; set `protocolNegotiation` to
override either default. The same connection API works across sessionful and
sessionless servers.

## Install

```bash theme={null}
npm install @mcp-use/client
```

The package requires Node.js `>=22.22.2` for Node applications and is ESM-only.

## Quick start

```typescript theme={null}
import { MCPClient } from "@mcp-use/client";

const client = new MCPClient({
  mcpServers: {
    demo: { url: "http://localhost:3000/mcp" },
  },
});

try {
  const connection = await client.connect("demo");

  const tools = await connection.listTools();
  console.log(tools.map((tool) => tool.name));

  const result = await connection.callTool("echo", { message: "hello" });
  const text = result.content.find((block) => block.type === "text");
  if (text?.type === "text") {
    console.log(text.text);
  }
} finally {
  await client.close();
}
```

`connect(name)` returns a ready `MCPConnection`. Always close the client when
your application is finished so its active connections and transports are
released.

## Core types

* **`MCPClient`** — holds server configuration and opens connections.
* **`MCPConnection`** — calls tools, reads resources, and fetches prompts.
  `connection.info` exposes the negotiated protocol, server metadata,
  capabilities, and instructions.
* **`MCPSession`** — deprecated compatibility alias for `MCPConnection`.

Use `client.connect(name)` for one configured server or `client.connectAll()` to
connect to every configured server.

## Configure servers

```typescript theme={null}
import { MCPClient } from "@mcp-use/client";

const client = new MCPClient({
  mcpServers: {
    remote: {
      url: "https://api.example.com/mcp",
      authToken: process.env.MCP_TOKEN,
    },
    local: {
      command: "npx",
      args: ["-y", "@modelcontextprotocol/server-filesystem", "./"],
    },
  },
});
```

HTTP servers support automatic OAuth, bearer tokens, and custom headers. Stdio
connections are available only in Node.js.

Migrating existing client code? Follow the
[client migration guide](https://docs.mcp-use.com/typescript/client/migration.md).

## Next steps

> [card] [Tools](https://docs.mcp-use.com/typescript/client/tools.md)
>
> List and call server tools.

> [card] [Migration guide](https://docs.mcp-use.com/typescript/client/migration.md)
>
> Update packages, imports, configuration, and connection code.

> [card] [Authentication](https://docs.mcp-use.com/typescript/client/authentication.md)
>
> Configure OAuth and bearer tokens.

> [card] [React](https://docs.mcp-use.com/typescript/client/usemcp.md)
>
> Manage connections with `McpClientProvider` and hooks.

> [card] [Environments](https://docs.mcp-use.com/typescript/client/environments.md)
>
> Compare Node, browser, and React support.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.