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

# Build a Safe AI Trading Agent With Claude Code

> Connect Claude Code to your Aries brokerage account over MCP, let the agent research on its own, and make every order wait for your approval.

An AI trading agent is an AI model that can read market data and your brokerage account, then place orders through tools. To build one safely with Claude Code, connect it to the Aries MCP server, add a permission rule so every Aries action waits for your yes, and test on your simulation account before you trade live.

## What You Need

* An **Aries account**, with access to [Client Center](https://app.aries.com/client-center).
* An **MCP key** from Client Center: open the **API** section and click **Generate MCP Key**. The [MCP setup guide](https://finance.dev/mcp-auth.md) walks through it.
* **Claude Code** installed. The `claude mcp add` command below was run with Claude Code 2.1.332.

## Why an AI Trading Agent Needs Your Approval Before It Trades

An agent that can place orders will sometimes try to place one you didn't intend. It can misread a request, size a position from a stale quote, or follow instructions hidden in a web page or a file. That last one is indirect prompt injection, and OWASP's answer is to "[implement human-in-the-loop controls for privileged operations](https://genai.owasp.org/llmrisk/llm01-prompt-injection/)."

The MCP specification goes further: "[there SHOULD always be a human in the loop with the ability to deny tool invocations](https://modelcontextprotocol.io/specification/2025-06-18/server/tools)." And FINRA's 2026 oversight report lists "[AI agents acting autonomously without human validation and approval](https://www.finra.org/rules-guidance/guidance/reports/2026-finra-annual-regulatory-oversight-report/gen-ai)" as a risk of AI agents.

So here's the setup: the agent researches, every order waits for you, and a Claude Code setting makes sure of it. The agent doesn't decide what you trade, and nothing here promises a return. It helps you look. You decide.

## How an AI Agent Places Trades Through a Brokerage API

In this setup, every order takes six steps.

![1 Research: the agent reads quotes, positions and news. 2 Propose: the agent picks symbol, side, size and limit price. 3 Preview: the agent prices the order without placing it. 4 Approve: you say yes or no. 5 Place: Aries receives the order at POST /v1/orders. 6 Watch: fills arrive on the account WebSocket.](https://mintcdn.com/ariesfinancialinc/t9rNcUU2gb0nVofi/images/guides/ai-agent-order-steps-light.svg?fit=max\&auto=format\&n=t9rNcUU2gb0nVofi\&q=85\&s=15384b0ab0b790f816da20410408b2c4)

Step 4 is the only one that needs you, and the one the agent must never skip.

Placing an order is one call, `POST /v1/orders`, whatever the order type. The response confirms Aries accepted the order. Fills arrive later on the account WebSocket, so a good agent reports what actually happened, not what it sent. The [order flow guide](https://finance.dev/api-reference/orders/order-flow.md) covers the full lifecycle.

## Connect Claude Code to Your Brokerage Account With the Aries MCP Server

Aries hosts the server itself. Your agent connects to the same infrastructure Aries' own brokerage runs on. Add it once, for all your projects:

```bash theme={null}
claude mcp add --transport http --scope user aries https://mcp.aries.com/mcp
```

`--scope user` is the part that makes it work in every project, as [Claude Code's MCP docs](https://code.claude.com/docs/en/mcp) explain.

![Terminal running claude mcp add for the Aries MCP server, then claude mcp list showing aries at https://mcp.aries.com/mcp as needing authentication](https://mintcdn.com/ariesfinancialinc/t9rNcUU2gb0nVofi/images/guides/claude-code-add-aries-mcp.png?fit=max\&auto=format\&n=t9rNcUU2gb0nVofi\&q=85\&s=c25d16155041d874e1e90d2678224d35)

Our test run with Claude Code 2.1.332. Until you sign in, `claude mcp list` shows the server as needing authentication. Home folder shortened to \~.

That "Needs authentication" line is expected. It means Claude Code found the server and is waiting for you to sign in.

Then sign in. In Claude Code, run `/mcp`, select **aries** and choose **Authenticate**. Aries asks for your MCP key in the browser, then you sign in and click **Allow**. The [Claude Code setup guide](https://finance.dev/mcp-auth/claude-code.md) has every step and the fixes for common sign-in errors.

Your account can have one active MCP connection at a time.

## Give the Agent Read-Only Access Until You Approve Each Order

Claude Code uses permission rules in a settings file to decide which tools run without asking. An `ask` rule makes Claude Code stop and ask you before a tool runs. Put this in `~/.claude/settings.json` to cover every Aries tool in every project, or in `.claude/settings.json` to cover one project:

```json theme={null}
{
  "permissions": {
    "ask": ["mcp__aries"]
  }
}
```

`mcp__aries` matches every tool the `aries` server provides, and `mcp__aries__<tool>` matches just one.

This is the lock that matters. Claude Code enforces it, not the model: "[Instructions in your prompt or CLAUDE.md shape what Claude tries to do, but they don't change these rules](https://code.claude.com/docs/en/permissions)." A line in your prompt that says "always ask me first" is a request. This rule is a setting.

Two things to know before you change it:

* **`ask` beats `allow`.** Claude Code checks deny rules first, then ask, then allow, and the first match wins. If `mcp__aries` is in `ask`, adding a read tool to `allow` changes nothing: it still asks.
* **Narrow it with tool names, not guesses.** Once you want reads to run on their own, run `/mcp` and select a tool to see its full name, as [Claude Code's MCP docs](https://code.claude.com/docs/en/mcp) describe. Then replace `mcp__aries` with one `ask` rule per tool that places, changes or cancels an order, and put the read tools in `allow`. Now the agent researches without asking, and every order still waits for you.

Run `/permissions` at any time to see which rules are active and which file each one comes from.

Start with questions that only read, like "What's in my Aries portfolio?" or "What's the current price of AAPL?" With the `ask` rule on every Aries tool, each one still stops for your yes. That's the point of the first session: you see which tools the agent reaches for and what comes back, before anything can trade. Once the reads look right, move those tools to `allow` and keep the order tools in `ask`.

## Paper Trading First: Use Your Simulation Account

Aries accounts can include a simulation account next to your live one, and the [accounts endpoint](https://finance.dev/api-reference/accounts/user-accounts.md) marks each one with a simulation flag. Run your first sessions there.

Start each session by asking the agent which account it will use, and to stop if it isn't the simulation account. Then ask it to preview every order before it asks you to approve it. The [preview endpoint](https://finance.dev/api-reference/orders/preview-order.md), `POST /v1/orders/preview`, works out what an order would cost and how it would change your buying power, without placing it.

A prompt that sets both up:

```text theme={null}
Use my Aries simulation account. Before you place any order, preview it and show me the account, symbol, side, quantity, order type, price and estimated cost. Then wait for me to reply yes.
```

Both are prompts, not locks. What they give you is a clear picture at the moment you approve.

![A Claude Code session. The agent writes: Preview, nothing placed yet. Account: simulation. Buy 10 MSFT, limit order at 400.00 dollars. Estimated cost 4,000.00 dollars. Reply yes to place it. The user replies: yes.](https://mintcdn.com/ariesfinancialinc/t9rNcUU2gb0nVofi/images/guides/ai-agent-order-preview-light.svg?fit=max\&auto=format\&n=t9rNcUU2gb0nVofi\&q=85\&s=77a00947a378638c3c5f52cce11bfc41)

What an approval looks like with the prompt above. Example only, not a recommendation.

## Give Your Own Agent Delegated Access With OAuth Scopes

If you build your own agent on the Aries API instead of Claude Code, your users never hand it a password. They sign in with their own Aries account over [OAuth2](https://finance.dev/api-reference/oauth2/guide.md), and the access token only works for the scopes they approved on the consent screen.

Scopes are the strongest limit you control here. `order:execution` is the only scope that places, modifies or cancels orders. An agent that only researches never needs it, so a leaked token can't trade. A research-only agent can ask for:

```text theme={null}
account:information position:information order:information market:information market:supplemental
```

Send them as one space-separated string, spelled as in the [scope list](https://finance.dev/api-reference/oauth2/guide.md#available-scopes). Add `options:information`, `analytics:information` or `calendar:information` when the agent needs options chains, analytics or calendars. The [preview endpoint](https://finance.dev/api-reference/orders/preview-order.md) also needs `order:execution`, so add it only to the part of your app that previews and places orders after a person approves them.

The [quickstart](https://finance.dev/api-reference/quickstart.md) walks through the sign-in request step by step.

Pick the sign-in flow by who the agent acts for. An agent other people use runs the [Authorization Code flow](https://finance.dev/api-reference/oauth2/auth-code-flow.md) when it has a backend that can keep a client secret, or the [PKCE flow](https://finance.dev/api-reference/oauth2/pkce-flow.md) in a browser or mobile app with no server secret. Each user signs in and approves the scopes themselves. An agent that only ever trades your own account can use a personal-token client with the [Client Credentials flow](https://finance.dev/api-reference/oauth2/client-credentials.md): it swaps a client ID and secret for a short-lived token that acts as you, with no sign-in screen.

## Can the Agent Place Multi-Leg Options Orders?

Yes. The Aries API takes single-leg options orders and [multi-leg options orders](https://finance.dev/api-reference/orders/multi-leg-option.md) with 2 to 4 legs, sent as one order. The same approval applies: a spread waits for your yes like any other order. Ask the agent to show every leg in its preview, so you approve the whole order and not just its first line.

## What It Costs

The Aries API, its market data and the MCP server are free with an Aries account, and the market data includes the full SIP feed with level 2. Claude costs whatever your Claude plan costs.

To start, [generate your MCP key](https://app.aries.com/client-center) in Client Center, then follow the [Claude Code setup guide](https://finance.dev/mcp-auth/claude-code.md).


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