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

# MCP Server

> The Pacifica MCP server exposes the REST API as Model Context Protocol tools for AI agents.

The Pacifica MCP server is a [Model Context Protocol](https://modelcontextprotocol.io) server that exposes Pacifica's REST API as MCP tools.\
An MCP client such as Claude Desktop, Claude Code, or OpenAI Codex can then read the markets and place trades on your behalf, using natural language.

It wraps the same REST endpoints documented elsewhere in this section, covering:

* **Market data:** exchange info, prices, orderbook, candles, funding rates, and more.
* **Account and positions:** balances, settings, positions, and history queries.
* **Order management:** limit, market, stop, TP/SL, and TWAP orders, plus batch operations.
* **Spot:** spot asset data, balances, and withdrawals.

It also adds **on-chain funding** tools that act on Solana directly: mint test USDP on testnet and deposit USDC/USDP into your exchange balance.

The server is open source and published to npm:

* Source: [github.com/pacifica-fi/pacifica-mcp](https://github.com/pacifica-fi/pacifica-mcp)
* Package: [`@pacifica-fi/mcp-server`](https://www.npmjs.com/package/@pacifica-fi/mcp-server)

## Prerequisites

* **Node.js 18 or newer**
* A **Pacifica account address** (your main account or a subaccount)
* For trading (optional): a signing key, either your main wallet's secret key or, recommended, a revocable **agent key** bound to your account

Read-only access (market data and account queries) needs only the account address.\
Placing or cancelling orders requires a signing key. See [Configuration](/api-documentation/api/mcp/configuration).

## Quickstart

The server runs the same way in every client: the command is `npx -y @pacifica-fi/mcp-server`, which downloads and runs the latest published version automatically (no manual install step), configured through environment variables.

At minimum, set `ADDRESS` to your account. Add a signing key (`AGENT_PRIVATE_KEY`, recommended, or `PRIVATE_KEY`) to place trades, or omit it for read-only access.

Only the config format differs per client. See [Client Setup](/api-documentation/api/mcp/clients) for step-by-step instructions for Claude Desktop, Claude Code, OpenAI Codex, Factory, Hermes, and Crush.

On startup the server logs the active account and auth mode to stderr (visible in the MCP logs), e.g. `[pacifica-mcp] account=<address> mode=agent-key`.

> **Note:** By default the server targets the Pacifica **testnet** (`https://test-api.pacifica.fi`). To trade on production, set `PACIFICA_BASE_URL=https://api.pacifica.fi` in the `env` block. See [Configuration](/api-documentation/api/mcp/configuration) for all environment variables.

## Next Steps

* [Configuration](/api-documentation/api/mcp/configuration): environment variables, auth modes, and security.
* [Client Setup](/api-documentation/api/mcp/clients): configs for Claude Desktop, Claude Code, OpenAI Codex, Factory, Hermes, and Crush.
* [Tools](/api-documentation/api/mcp/tools): the full list of tools the server exposes.
