Agentic tradingMCPRisk managementAutomation

How to automate exit plans and take profits with MCP

Learn how to build automated exit plans and take-profit rules for AI trading agents using MCP, with scoped keys, budget caps, and non-custodial safety controls.

By the Felix team10 min read
Key takeaways
  • 01Exit plans must be encoded as explicit parameters, not vague suggestions, because an agent interprets literal instructions.
  • 02Take-profit and stop-loss levels should be set in dollar terms and bound by scoped API keys that cannot override the owner's risk limits.
  • 03Paper trading provides a safe environment to test whether an MCP tool correctly parses exit instructions before any live capital is deployed.
  • 04The panic switch flattens positions and revokes agent access, acting as a final layer of defense when automation behaves unexpectedly.
  • 05Non-custodial architecture means the agent can trigger exits but cannot withdraw funds to an unapproved address, even if the exit logic is compromised.

An exit plan tells an AI agent exactly when to close a position, whether that means locking in a gain at a preset target or cutting a loss before it grows. When you automate this through an MCP tool, the agent reads your instructions as parameters and translates them into orders across stocks, crypto, perps, options, or prediction markets. You keep full custody of the funds, because the agent can spend within approved limits but cannot withdraw to itself or to any address you have not explicitly authorized.

What is an exit plan in agentic trading?

A manual trader might decide to sell when a chart looks tired, but an agent has no intuition. It only has rules. An exit plan is therefore a set of concrete conditions that trigger a close order. These conditions typically include a take-profit level, a stop-loss level, and sometimes a time limit or a trailing offset. Without them, the agent will hold until something else tells it to stop, which might be never.

The plan lives in two places. Part of it lives in the prompt or tool context you give the agent, and part of it lives in the hard limits enforced by the API. The prompt might say, "Close the position if the unrealized profit reaches one hundred dollars or the unrealized loss reaches fifty dollars." The API limit might say, "This key may not open new positions once the total position value exceeds five hundred dollars." Both layers are necessary because the prompt can be misinterpreted, while the API limit is absolute. If the two layers contradict each other, the API limit wins. This redundancy is intentional. It prevents a confused agent from holding a loser too long or from taking profits too early because of a vague instruction.

You should also distinguish between an exit plan and an exit strategy. An exit plan is a single set of instructions attached to one position or one session. An exit strategy is the broader logic that generates those instructions across many trades. The agent executes the plan, not the strategy. If you want the agent to calculate the plan dynamically, you must give it a formula it can evaluate with the data available through the MCP tools.

How does take-profit automation work through MCP?

MCP, or Model Context Protocol, lets an AI agent use tools the same way a developer uses functions. When you connect an agent to Felix through MCP, you expose a set of trading tools that the agent can call. One of those tools might create an order, another might read a balance, and another might set an exit plan. The agent does not see your wallet seed or your exchange password. It sees only the tool definitions and the scoped permissions attached to your key.

To automate a take-profit, you describe the rule in the conversation context and let the agent invoke the exit tool. The agent calculates the target from your instruction, then calls the tool with the parameters. Because Felix normalizes order sizing in plain US dollars, you can say "take profit at one hundred twenty dollars" and the API handles the conversion to shares, contracts, or tokens behind the scenes. This removes the need for you to write venue-specific contract math in your prompt. Still, the agent must understand the difference between a limit order that closes at a specific price and a market order that closes immediately when a condition is met. You should be explicit about which behavior you want. How an AI agent executes orders through MCP covers the mechanics of order routing in more detail.

{
  "key": "YOUR_KEY",
  "market_type": "perps",
  "position_id": "abc-123",
  "exit_rules": {
    "take_profit_usd": 120,
    "stop_loss_usd": 80,
    "trailing_offset_usd": 5
  }
}

In practice, the agent would fill these fields based on your prompt. You should review the tool output before authorizing live trading, because a misread decimal or a reversed sign can turn a stop-loss into an unintended entry. The API will reject some impossible values, but it cannot know your intent. Only you can.

You should also consider how the agent monitors the position. Some implementations poll for price changes, while others rely on fill notifications. If your exit plan includes a trailing stop, the agent must update the stop level as the price moves in your favor. This requires repeated tool calls. Define the trailing step in dollars, not in vague percentages, so the agent has a fixed number to work with.

Why does dollar sizing change how you set exits?

Felix sizes orders in plain US dollars, which means you think in terms of exposure rather than contract counts. This changes exit planning because your target is a dollar amount of profit or loss, not a price level on a chart. Suppose you tell the agent to buy two hundred dollars worth of an asset and to take profit when the position is worth two hundred forty dollars. The API translates that into the correct number of shares or contracts at the current price, then monitors the unrealized profit in real time. If the price moves quickly, the contract count does not change, but the dollar value does.

This abstraction is helpful until the underlying asset is highly volatile or uses leverage. In a leveraged perps position, a small price move can create a large dollar gain or loss. Your exit plan must account for that leverage by setting dollar thresholds that reflect your actual risk, not the notional size of the trade. If you set a stop-loss in dollars without considering leverage, the agent might close the position far earlier or later than you expect. Be explicit about which figure the agent should watch.

How to start trading with dollar-based order sizing in 2026 explains how to align your entry size with your exit targets. You should also remember that fees and funding rates change the net dollar value of a position. An exit plan based on gross unrealized profit might trigger before you are actually net positive. It is safer to add a buffer or to phrase the target as "net profit after estimated fees," if the tool supports it. Otherwise, you may find the agent closing trades at what looks like breakeven but is actually a small loss after costs.

What safety controls keep an exit plan from going wrong?

Automation is only as safe as the boundaries around it. Felix provides several controls that apply specifically to exit behavior.

  • ·Scoped keys restrict the agent to closing only certain positions or markets, or to position sizes below a set dollar threshold.
  • ·Budget caps stop the agent from opening new trades once a daily or weekly limit is reached, preventing it from averaging into a loser instead of exiting.
  • ·Position limits cap total exposure so that even if an exit fails, the damage stays bounded.
  • ·The panic switch flattens every open position and revokes the agent's key in seconds, without giving the agent a veto.

The panic switch is the most important control for exits. If the agent starts firing close orders at bad prices, or if the market gaps and the agent cannot keep up, you can hit the kill switch. This flattens every open position and revokes the agent's key immediately. The agent does not get a veto. The switch is owner-controlled and works in seconds. You should test the panic switch in paper trading so you know exactly what it does. Some traders worry that flattening will crystallize a loss, but a runaway agent can turn a small loss into a total wipeout faster than a human can react. The switch exists to stop that spiral.

How to control risk when an AI agent trades through MCP discusses how to set these limits before you enable live trading. You should also design your prompt with hard constraints. Do not say, "Try to take profits early if the market looks weak." Instead say, "Place a limit order to close fifty percent of the position at a one hundred dollar profit and the remainder at a two hundred dollar profit." Specificity removes ambiguity. How to write prompts that keep trading agents inside hard limits offers patterns for writing instructions that the agent cannot misread.

Another layer is the exit plan itself, which can be configured as a bracket order at entry time. A bracket order attaches the take-profit and stop-loss to the opening order, so the agent does not need to monitor the position continuously. The venue manages the exits, and the agent only needs to check that the orders are still live. This reduces the chance that the agent misses a move because it was polling too slowly. Not all markets support bracket orders, so check the docs for availability.

How do you test an exit plan without risking money?

Every exit plan should go through paper trading before it touches live capital. Felix provides a paper environment where the agent can call the same tools, read the same market data, and simulate the same fills, but no real money moves. This lets you observe whether the agent correctly interprets your take-profit and stop-loss instructions. You can watch the unrealized profit approach the target and confirm that the agent sends the close order at the right moment.

During testing, deliberately introduce edge cases. Imagine the price gaps past your stop-loss. Does the agent send a market order to exit immediately, or does it place a limit order that might never fill? Imagine the price hovers exactly at your take-profit level. Does the agent spam close orders, or does it send one and wait? Paper trading reveals these behaviors without cost. You should also test what happens when the agent loses its MCP connection mid-trade. If the plan lives only in the agent's context, the position may go unmonitored until it reconnects.

Live trading requires explicit owner authorization of a key, so you cannot accidentally promote a paper test to live execution. You must consciously approve the key and set the live permissions separately. This means you can iterate on the prompt and the parameters in paper mode, then copy the working configuration to a live key with tighter limits. Never skip this step. A prompt that looks correct in static review can behave differently when real latency and price feeds are involved.

How do you move from tested rules to live execution?

Once paper trading shows that the agent follows your exit plan correctly, you can authorize a live key. Start with a small budget cap and a tight position limit. Choose one market type, such as stocks or crypto, before you let the agent trade across all five. Watch the first few exits manually. Verify that the agent closes at the dollar targets you specified and that the fills look reasonable. If the agent behaves correctly, you can gradually raise the caps.

Remember that live markets have slippage, partial fills, and downtime. An exit plan that worked perfectly in paper trading may still lose money in live trading because the price moved too fast or the venue rejected the order. Trading can lose money, including everything, and automation does not change that. The non-custodial design means your funds stay in a wallet you control, and the agent can never withdraw to itself or to an unapproved address. Even if the exit logic is compromised, the worst case is a bad trade, not a stolen balance.

You should also keep a log of every live exit. Compare the intended dollar target with the actual fill price and the net profit or loss. Over time, this log reveals whether your take-profit levels are too optimistic or whether your stop-losses are too tight. Adjust the plan in paper trading again before you change the live parameters. This loop of plan, test, deploy, measure, and replan is the only reliable way to automate exits with an agent.

Frequently asked questions

Can I use the same exit plan for every market type?

You can reuse the same dollar targets, but the plan must account for differences in volatility, fees, and leverage. A stop-loss that works for a stock position may be too tight for a leveraged perps trade. Test the plan in each market separately through paper trading before applying it live.

What happens if the agent loses its MCP connection during a trade?

If the exit plan is stored as a bracket order in the API, the venue continues to manage the exits. If the plan lives only in the agent's context, the position may go unmonitored until the agent reconnects. Confirm how state is handled before relying on continuous monitoring.

Does the agent need my private keys to automate exits?

No. The agent uses a scoped API key that can place orders and read positions but cannot withdraw funds. Your private keys remain in your wallet, and the agent can only trade within the limits you set.

Can I change an exit plan after the trade is already live?

Yes, you can send a new instruction through the MCP tool to update the levels. The agent will call the appropriate tool to amend the orders. Verify that the old orders are cancelled and replaced, not duplicated.

What is the difference between a stop-loss and the panic switch?

A stop-loss is a planned exit at a specific dollar loss level that the agent manages normally. The panic switch is an owner-controlled override that flattens all positions and revokes the agent's key immediately. Use the stop-loss for routine risk and the panic switch for emergencies.

How do I know if my take-profit level is realistic?

Review historical volatility and set the target in paper trading first. If the price rarely reaches your target within the expected timeframe, the agent will hold longer than intended and may accumulate fees. Adjust the target based on actual fill data before moving live.

Give your agent a key.

One key to trade stocks, crypto, perps, options, and prediction markets. Live after owner authorization.

Keep reading

Not a brokerage, exchange, or investment adviser. Not investment advice. Trading involves risk, including total loss.