> ## 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. The client negotiates legacy (v1 sessionful) and modern (v2 sessionless) servers automatically and exposes one connection API for both.

## Install

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

Node.js 20+ required. The package is ESM-only.

## Entry points

| Building                       | Import                  | Transports  |
| ------------------------------ | ----------------------- | ----------- |
| Node script, service, or agent | `@mcp-use/client`       | HTTP, stdio |
| Browser (no React)             | `@mcp-use/client`       | HTTP        |
| React app                      | `@mcp-use/client/react` | HTTP        |

MCP App view hooks (`useToolContext`, `useCallTool`, …) live in `mcp-use/react`, not the client package.

## 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((t) => t.name));

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

## Core types

* **`MCPClient`** — holds server config and opens connections.
* **`MCPConnection`** — call tools, read resources, fetch prompts. Check `connection.info` for `protocolEra`, `protocolVersion`, capabilities, and instructions.
* **`MCPSession`** — deprecated alias for `MCPConnection`.

Prefer `client.connect(name)` over `createSession()`. Use `client.connectAll()` for every configured server.

## Configure servers

```typescript theme={null}
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 OAuth (automatic by default), bearer tokens, and custom headers. Stdio is Node-only.

Upgrading from v1? See the [v2 migration guide](/typescript/client/migration).

## Next steps

<CardGroup cols={2}>
  <Card title="Tools" icon="wrench" href="/typescript/client/tools">
    List and call server tools.
  </Card>

  <Card title="v2 Migration" icon="arrow-right-left" href="/typescript/client/migration">
    Breaking changes and upgrade checklist.
  </Card>

  <Card title="Authentication" icon="shield" href="/typescript/client/authentication">
    OAuth and bearer tokens.
  </Card>

  <Card title="React" icon="react" href="/typescript/client/usemcp">
    `McpClientProvider` and hooks.
  </Card>

  <Card title="Environments" icon="container" href="/typescript/client/environments">
    Node, browser, and React differences.
  </Card>
</CardGroup>
