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 "Install 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-mcpwhat 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: bitvavo-mcp
1. OANDA側の準備(デモ口座)
ログイン後、Manage API Access(My Account → Manage API Access)で パーソナルアクセストークンを生成
アカウントID(
101-001-1234567-001のような形式)を控える
2. インストール
Python 3.10 以上が必要です。
cd D:\oanda-mcp
pip install -e .3. 認証情報の設定(.env)
.env ファイルはプロジェクトの外、ホームディレクトリ配下の
%USERPROFILE%\.oanda\.env に置きます(サーバー起動時に自動で読み込まれます。
環境変数の設定は不要です):
New-Item -ItemType Directory -Force $env:USERPROFILE\.oanda | Out-Null
copy .env.example $env:USERPROFILE\.oanda\.env
notepad $env:USERPROFILE\.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 で明示指定したパス → カレントディレクトリと
その親 → プロジェクトルート → %USERPROFILE%\.oanda\.env」です。同名の
環境変数が既に設定されている場合はそちらが優先されます。
4. 動作確認(MCP Inspector)
npx @modelcontextprotocol/inspector oanda-mcp(.env は %USERPROFILE%\.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 を引き継がないため、コマンド名だけでは
起動に失敗することがあります。フルパスは PowerShell で確認できます:
(Get-Command oanda-mcp).Source
# 例: C:\Users\<ユーザー名>\AppData\Local\Programs\Python\Python311\Scripts\oanda-mcp.exe確認したパスを使って設定します(JSON内の \ は \\ にエスケープ):
{
"mcpServers": {
"oanda": {
"command": "C:\\Users\\<ユーザー名>\\AppData\\Local\\Programs\\Python\\Python311\\Scripts\\oanda-mcp.exe"
}
}
}.env は %USERPROFILE%\.oanda\.env から自動で読み込まれるため、env ブロックは
不要です。別の場所に置いた場合のみ、env ブロックで OANDA_DOTENV にそのパスを
指定してください。
保存後、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. 環境変数リファレンス
通常は %USERPROFILE%\.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はプロジェクトの外 (%USERPROFILE%\.oanda\.env)に置き、リポジトリにコミットしたり チャットに貼り付けたりしないでください。OANDA_ENV=liveにすると本番口座のデータを参照します(このサーバーは 参照のみなので発注はできませんが、口座情報は実データになります)。OANDA証券(日本)の口座でAPIを使う場合は、口座コースごとのAPI利用条件を 事前に確認してください。
今後の拡張(取引系を足す場合)
client.py に POST/PUT 系メソッド(/orders, /trades/{id}/close など)を
追加し、server.py にツールを足すだけで拡張できます。その際は
最大ロット数の上限チェックや、OANDA_ENV=live 時は発注を拒否する
ガードを入れることを強く推奨します。
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/aobathree/oanda-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server