oanda-mcp
This is a read-only MCP server for the OANDA v20 REST API, allowing you to retrieve forex market data and account information without placing or managing trades.
Get current prices (
get_price): Fetch real-time bid/ask rates for one or more currency pairs (e.g.,USD_JPY,EUR_USD,GBP_JPY)Get candlestick/OHLC data (
get_candles): Retrieve historical candlestick data with customizable granularity (5-second to monthly), up to 5,000 candles, with optional time range filtering and mid/bid/ask price selectionGet account summary (
get_account_summary): View account balance, unrealized P&L, margin usage, open trade/position counts, currency, and net asset value (NAV)Get open positions (
get_open_positions): List all currently held positions with units, average entry price, and unrealized P&L per instrumentGet pending orders (
get_pending_orders): View all unfilled/pending orders on the accountGet open trades (
get_open_trades): List all open trades with entry price, position size, and unrealized P&LGet recent transactions (
get_recent_transactions): Retrieve recent account transaction history (fills, orders, funding, etc.) with optional type filtering (e.g.,ORDER_FILL,MARKET_ORDER)List tradeable instruments (
list_instruments): Browse all instruments available to your account, with optional filtering by specific symbols
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@oanda-mcp what is the current price of USD_JPY?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
oanda-mcp
OANDA v20 REST API の 参照系(read-only) 機能を Claude から使えるようにする MCP サーバーです。 発注・決済などの取引系ツールは含まれていません(安全のため、まず参照系のみ)。
提供ツール
ツール | 内容 |
| 現在のBid/Askレート取得(複数通貨ペア可) |
| ローソク足(履歴)取得。S5〜月足、最大5000本 |
| 口座サマリー(残高・評価損益・証拠金など) |
| 保有ポジション一覧 |
| 未約定注文一覧 |
| オープントレード一覧 |
| 直近の取引履歴(トランザクション) |
| 取引可能な銘柄一覧 |
通貨ペアは OANDA 形式(USD_JPY, EUR_USD など)で指定します。
Related MCP server: HTS MetaTrader5 Trading MCP
1. OANDA側の準備(デモ口座)
ログイン後、Manage API Access(My Account → Manage API Access)で パーソナルアクセストークンを生成
アカウントID(
101-001-1234567-001のような形式)を控える
2. インストール
Python 3.10 以上が必要です。
Windows
cd D:\oanda-mcp
pip install -e .macOS
macOS標準の python3 は 3.9 のことがあり(その場合インストールが
requires a different Python エラーで失敗します)、システムへの直接
インストールも制限されているため、Homebrewで新しいPythonを入れて
venv(仮想環境)を使います:
brew install python
cd ~/oanda-mcp
python3.13 -m venv .venv # brewで入ったバージョンに合わせる(python3.12等)
source .venv/bin/activate
pip install -e .補足: venvのpipが古いと pyproject.toml のみのプロジェクトを
editableインストールできません(PEP 660はpip 21.3以降)。その場合は
pip install -U pip してから再実行してください。新しいPythonで
venvを作っていれば通常は問題になりません。
3. 認証情報の設定(.env)
.env ファイルはプロジェクトの外、ホームディレクトリ配下
(Windows: %USERPROFILE%\.oanda\.env、macOS/Linux: ~/.oanda/.env)に
置きます(サーバー起動時に自動で読み込まれます。環境変数の設定は不要です):
Windows:
New-Item -ItemType Directory -Force $env:USERPROFILE\.oanda | Out-Null
copy .env.example $env:USERPROFILE\.oanda\.env
notepad $env:USERPROFILE\.oanda\.envmacOS/Linux:
mkdir -p ~/.oanda
cp .env.example ~/.oanda/.env
open -e ~/.oanda/.env # または任意のエディタで開くエディタが開いたら自分の値に書き換えます:
OANDA_API_TOKEN=あなたのトークン
OANDA_ACCOUNT_ID=101-001-1234567-001
OANDA_ENV=practiceプロジェクト直下に .env を置かない理由: このフォルダーで Claude Code などの
コーディングエージェントを使うと、ワークスペース内のファイルとして認証情報が
読める状態になるためです(Webull 公式 MCP サーバーのセキュリティ指針に倣った
配置です)。.gitignore では引き続き .env を除外していますが、これは誤って
プロジェクト内に置いてしまった場合の保険です。
.env の検索順は「OANDA_DOTENV で明示指定したパス → ホームの .oanda/.env
→ カレントディレクトリとその親 → プロジェクトルート」です。読み込まれるのは
OANDA_ で始まるキーだけで(HTTPS_PROXY などの通信系キーは無視されます)、
OANDA_ キーを1つも含まないファイルはスキップして次の候補へ進みます。同名の
環境変数が既に設定されている場合はそちらが優先されます。
4. 動作確認(MCP Inspector)
# Windows
npx @modelcontextprotocol/inspector oanda-mcp# macOS(venvの実行ファイルを指定)
cd ~/oanda-mcp
npx @modelcontextprotocol/inspector .venv/bin/oanda-mcp(.env はホームの .oanda/.env から自動で読み込まれるため、
どのディレクトリから起動しても構いません)
ブラウザで Inspector が開いたら:
Arguments欄は空のまま、Connect をクリック(左下が緑の「Connected」になる)
上部の Tools タブ → List Tools で8ツールが表示される
get_priceを選び、instrumentsにUSD_JPYを入力して Run Tool現在のbid/askがJSONで返れば成功
5. Claude Desktop への登録
設定ファイルの場所:
Windows:
%APPDATA%\Claude\claude_desktop_config.jsonmacOS:
~/Library/Application Support/Claude/claude_desktop_config.json
command には oanda-mcp 実行ファイルのフルパスを指定してください。
Claude Desktop はターミナルと同じ PATH を引き継がないため、コマンド名だけでは
起動に失敗することがあります。フルパスは Windows なら PowerShell で確認できます:
(Get-Command oanda-mcp).Source
# 例: C:\Users\<ユーザー名>\AppData\Local\Programs\Python\Python311\Scripts\oanda-mcp.exeWindows(JSON内の \ は \\ にエスケープ):
{
"mcpServers": {
"oanda": {
"command": "C:\\Users\\<ユーザー名>\\AppData\\Local\\Programs\\Python\\Python311\\Scripts\\oanda-mcp.exe"
}
}
}macOS(venv内の実行ファイルをフルパスで指定。activateは使えないため フルパス指定が必須です):
{
"mcpServers": {
"oanda": {
"command": "/Users/<ユーザー名>/oanda-mcp/.venv/bin/oanda-mcp"
}
}
}.env はホームの .oanda/.env から自動で読み込まれるため、env ブロックは
不要です。別の場所に置いた場合のみ、env ブロックで OANDA_DOTENV にそのパスを
指定してください。
既に他の設定(preferences など)があるファイルの場合、mcpServers は
最上位(一番外側の {} の直下)に、既存ブロックとカンマで区切って追加します。
保存前に python3 -m json.tool <設定ファイル> で構文チェックすると安全です。
保存後、Claude Desktop を完全に再起動(タスクトレイのアイコンからも終了)すると 「oanda」サーバーが認識されます。「ドル円の今のレートは?」のように話しかければ ツールが呼ばれます。
6. Claude Code への登録(任意)
claude mcp add oanda -- oanda-mcpClaude Code はターミナルから起動するため、こちらはコマンド名のままで動きます (動かない場合はフルパスを指定してください)。
どのプロジェクトからでも使う(user スコープ + フルパス)
上のコマンドはデフォルトの local スコープ(実行したプロジェクト限定)で
登録されます。どのプロジェクトからでも使いたい場合は --scope user を
付けます。また、デスクトップアプリ版など PATH を引き継がない環境でも
確実に起動するよう、command には実行ファイルのフルパスを指定するのが
安全です:
# フルパスを確認
(Get-Command oanda-mcp).Source
# 例: C:\Users\<ユーザー名>\...\Python313\Scripts\oanda-mcp.exe
# user スコープでフルパス登録
claude mcp add --scope user oanda -- "<上で確認したフルパス>"登録後は接続状態を確認できます:
claude mcp list
# oanda: ...\oanda-mcp.exe - √ Connected と表示されれば成功設定は %USERPROFILE%\.claude.json に保存されます。なお、Microsoft Store 版
Python を使っている場合、Python のバージョンアップで Scripts フォルダーの
パスが変わるため、その際は claude mcp add を再実行してください。
起動中の Claude Code セッションには途中から追加したサーバーは反映されません。
新しいセッションを開くとツールが使えるようになります。
7. 環境変数リファレンス
通常はホームの .oanda/.env に書くだけで足ります。
変数 | 必須 | 説明 |
| ✔ | パーソナルアクセストークン |
| ✔ | 口座ID |
| - |
|
| - | 読み込む |
テスト
2層構成です(公式 Alpaca MCP サーバーのテスト戦略に倣ったもの):
python tests\test_server.py # ユニット: モックのみ、認証情報・ネットワーク不要
python tests\test_integration.py # 統合: practice口座の実APIに read-only GET で接続統合テストは .env に実際の認証情報がないとき、および OANDA_ENV=live の
ときは自動的にスキップされます(安全のため live 口座では実行されません)。
なお、API リクエストには User-Agent: oanda-mcp/<version> が付与されます。
注意事項
トークンは口座への広い権限を持ちます。
.envはプロジェクトの外 (ホームの.oanda/.env)に置き、リポジトリにコミットしたり チャットに貼り付けたりしないでください。OANDA_ENV=liveにすると本番口座のデータを参照します(このサーバーは 参照のみなので発注はできませんが、口座情報は実データになります)。OANDA証券(日本)の口座でAPIを使う場合は、口座コースごとのAPI利用条件を 事前に確認してください。
今後の拡張(取引系を足す場合)
client.py に POST/PUT 系メソッド(/orders, /trades/{id}/close など)を
追加し、server.py にツールを足すだけで拡張できます。その際は
最大ロット数の上限チェックや、OANDA_ENV=live 時は発注を拒否する
ガードを入れることを強く推奨します。
Available Tools
8 toolsget_account_summaryA
Get the account summary: balance, unrealized P/L, margin usage, open trade/position counts, currency, and NAV.
Inputs: no named parameters. Returns: result
get_candlesA
Get historical candlestick data for an instrument.
Args: instrument: OANDA instrument name, e.g. "USD_JPY". granularity: Candle size: S5,S10,S15,S30,M1,M2,M4,M5,M10,M15,M30, H1,H2,H3,H4,H6,H8,H12,D,W,M. Default "H1". count: Number of candles (max 5000). Ignored when both from_time and to_time are given. Default 100. price: "M" (mid), "B" (bid), "A" (ask), or combinations like "MBA". from_time: RFC3339 start time, e.g. "2026-07-01T00:00:00Z" (optional). to_time: RFC3339 end time (optional).
Inputs: instrument (required), count, price, to_time, +2 more. Returns: result
get_open_positionsA
List all currently open positions with units, average price, and unrealized P/L per instrument.
Inputs: no named parameters. Returns: result
get_open_tradesA
List all open trades with entry price, units, and unrealized P/L.
Inputs: no named parameters. Returns: result
get_pending_ordersA
List all pending (not yet filled) orders on the account.
Inputs: no named parameters. Returns: result
get_priceA
Get current bid/ask prices for one or more instruments.
Args: instruments: Comma-separated OANDA instrument names, e.g. "USD_JPY" or "USD_JPY,EUR_USD,GBP_JPY".
Inputs: instruments (required). Returns: result
get_recent_transactionsA
Get the most recent account transactions (fills, orders, funding...).
Args: count: How many recent transactions to return (default 50). type_filter: Optional comma-separated transaction type filter, e.g. "ORDER_FILL" or "MARKET_ORDER,ORDER_FILL".
Inputs: count, type_filter. Returns: result
list_instrumentsA
List tradeable instruments available to the account.
Args: names: Optional comma-separated filter, e.g. "USD_JPY,EUR_USD". Omit to list everything.
Inputs: names. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 8 tools
Each tool targets a distinct aspect of OANDA account data: account summary, historical candles, open positions, open trades, pending orders, current prices, recent transactions, and instrument list. No two tools have overlapping purposes.
All tool names follow a consistent 'verb_noun' pattern with 'get_' or 'list_' as the verb. The naming is uniform and predictable, making it easy for agents to understand the action and resource.
8 tools is an appropriate count for a trading data server. It covers the essential read operations without being overwhelming or too sparse.
The tool set is entirely read-only, missing all write operations such as creating orders, modifying orders, canceling orders, or closing trades. For a trading server, this is a significant gap that limits agent capabilities to data retrieval only.
Maintenance
Related MCP Connectors
Read-only access to your MetaTrader 4 and 5 accounts for AI agents: balances, open positions, trade history with win rate, live quotes, symbol specs and candles. It cannot place, modify or close orders.
Read-only access to your own bank, card and brokerage accounts for Claude, ChatGPT and other AI agents: balances, transactions, spending, subscriptions, cashflow and investment holdings. It can never move money.
Read-only MetaTrader 5 for AI agents: balances, positions, history and prices. Sign in with OAuth.
Read-only Google Ads, GA4 and Search Console data for Claude, with no Google Cloud setup.
Related MCP Servers
- AlicenseAqualityDmaintenanceEnables Claude to access real-time crypto prices, forex rates, and market sentiment data through free public APIs with no keys required.53MIT
- AlicenseAqualityDmaintenanceEnables Claude AI to perform forex trading operations and market data analysis through MetaTrader 5, including order placement, position management, and multi-timeframe candle data retrieval.16MIT
- FlicenseNot gradedqualityDmaintenanceEnables Claude to access a Zerodha trading account for historical candles, weekly/monthly zone levels and CPR pivots, EMA crossover detection, and option chain data.-
- AlicenseAqualityCmaintenanceEnables Claude to read Moscow Exchange market data and T-Invest brokerage account data, including quotes, candles, order books, dividends, portfolio, and operations. It is read-only and does not place orders.7MIT