The MT5 API your AI agent can use.
Connect Claude, Cursor, VS Code or your own agent to MetaTrader 5 through our hosted MCP server. It can read your accounts, positions and history, bring accounts online and — only if its key allows — trade. Every call goes through the same API, scopes and limits as your own code.
- Hosted — nothing to install
- Read-only and reduce-only keys
- 21 tools, MT5 only
You › Close half of my EURUSD position on the demo account
and move the stop on the rest to break-even.
Claude list_accounts → list_positions
#2104837096 buy 0.20 EURUSD @ 1.08410
close_position volume "0.10" idempotency_key …
modify_position stop_loss "1.08410"
Closed 0.10 lots at 1.08655. The remaining 0.10 lots now
have their stop at 1.08410, the entry price.An agent with a trading key trades real money.
fxapis places real orders on real broker accounts — test keys included; there is no simulated market. Connect a broker demo account first, give the agent a read-only or reduce-only key, and never let a client auto-approve trading tools on a live account. AI models make mistakes, and can be misled by text they read.
Three steps, no code.
The server lives at https://api.fxapis.com/mcp. Any MCP client that can send an Authorization header connects to it.
- 01
Connect your MT5 account
In the fxapis console, with the login, trading password and server. The password never goes near the AI model.fxapis console - 02
Create a key for the agent
Only the scopes it needs: read-only to report, trading:reduce to manage risk, trading:execute to open trades.Keys → New key - 03
Add the server to your client
Paste the URL and the key into Claude, Cursor, VS Code or your agent's configuration. The guide has each one.Authorization: Bearer fx_…
One URL, one header.
Claude Code and Cursor below; Claude, Claude Desktop, VS Code and the Anthropic and OpenAI APIs are in the setup guide.
claude mcp add --transport http fxapis https://api.fxapis.com/mcp \
--header "Authorization: Bearer $FXAPIS_KEY"{
"mcpServers": {
"fxapis": {
"url": "https://api.fxapis.com/mcp",
"headers": { "Authorization": "Bearer ${env:FXAPIS_KEY}" }
}
}
}Enforced by the API, not by the prompt.
Each tool calls the ordinary fxapis REST API with the agent's key. Nothing the model says can get past what that key is allowed to do.
Marked as destructive
No double orders
No passwords in the chat
Honest failures
Same limits as your code
What the agent can do.
Full descriptions, arguments and scopes are in the tool reference.
Read
- get_workspace
- get_usage
- list_accounts
- get_account
- get_account_status
- list_positions
- list_orders
- get_order
- list_deals
- list_multi_account_orders
- get_multi_account_order
- calculate
Account lifecycle
- bring_accounts_online
- take_account_offline
Trade — real money
- place_market_order
- place_pending_order
- close_position
- modify_position
- cancel_order
- place_multi_account_order
- cancel_multi_account_order
MetaTrader 5 only. The terminals run in our EU cloud, so neither you nor the agent runs anything. There are no event webhooks yet: an agent following an account coming online or a multi-account order settling polls for it, as the tools tell it to. New to fxapis? Start with the MT5 API.
Questions about the MCP server
What is the fxapis MCP server?
A Model Context Protocol server, hosted by fxapis at https://api.fxapis.com/mcp. MCP is the standard way AI assistants and agents use outside tools. Connect a client to it with an fxapis API key and the assistant can read your MetaTrader 5 accounts, positions, orders and deal history, and — if the key allows — place, modify and close trades.
Can an AI agent really place trades on my account?
Only if you give it a key that allows trading. The trades are real orders on your own broker account, exactly as if your own code had sent them. Start with a broker demo account and a read-only key, and add trading permissions only when you are sure how the agent behaves.
How do I stop an agent from opening positions?
Give it a key without the trading:execute scope. A read-only key can only read. A reduce-only key (trading:reduce) can close positions, move stops and cancel pending orders, but can never open exposure. The API enforces this on every call, whatever the model decides, and you can revoke the key at any time.
Which AI clients work with it?
Any MCP client that can send an Authorization header over Streamable HTTP: Claude Code, Cursor, VS Code, Claude Desktop, agents built on the Anthropic or OpenAI APIs, and claude.ai custom connectors where Anthropic's request-headers option is enabled. ChatGPT's developer mode cannot connect yet, because it offers only OAuth or no sign-in, and fxapis uses API keys.
Do I need to run MetaTrader, a VPS or anything else?
No. The MetaTrader 5 terminals run in the fxapis cloud in the EU. You connect your MT5 account once in the fxapis console, and the AI client connects to our hosted MCP server. There is nothing to install or keep running.
Can the agent connect a new MT5 account for me?
No, deliberately. Connecting an account needs the broker password, and a broker password should never pass through an AI model's conversation. You connect accounts yourself in the fxapis console; the agent sees them once they are there. Creating and revoking API keys is likewise done only in the console.
What if the agent retries an order after a timeout?
Every trading tool takes an idempotency key, and the agent sends the same key when it retries the same action. Market orders, pending orders, closes and multi-account orders take an Idempotency-Key, so fxapis returns the first answer instead of placing a second order; stop changes and cancels are safe to repeat. If the outcome of an order is genuinely unknown, the tool says so with the code ORDER_UNRESOLVED and tells the agent not to resend it.
Is MetaTrader 4 supported?
No. fxapis supports MetaTrader 5 only.
What does it cost?
The MCP server is part of the fxapis API and uses the plan of the workspace the key belongs to. Each tool call counts as one or two API calls, and orders count as orders, the same as when your own code calls the API. See the pricing page for plans.
Give your agent a demo account and a narrow key.
Create a workspace, connect a broker demo account and add the MCP server to your client in a few minutes.