Token导航 LogoToken导航TokenDH.com
Metatrade Metaapi MCP Server logo
金融服务未说明官方级别未说明来源级核验

Metatrade Metaapi MCP Server

MCP Server

MetaAPI MCP服务器为AI助手提供直接访问MetaAPI交易平台的接口,支持通过自然语言对话进行外汇、股票和大宗商品交易。

工具数

31

提示词数

0

GitHub Stars

0

资源数

0
JavaScriptClaude金融数据Claude DesktopClaude

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

Neuro-Trade

提供方

Neuro-Trade

最后核验

2026/5/17 20:20

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

详细介绍

MetaAPI MCP服务器#MetaAPI MCP服务器

一个模型上下文协议(MCP)服务器,为克劳德等人工智能助手提供直接访问MetaAPI交易平台的权限。通过自然语言对话交易外汇、股票和商品。一个模型上下文协议(MCP)服务器,为克劳德等人工智能助手提供直接访问MetaAPI交易平台的权限。通过自然语言对话交易外汇、股票和商品。

---## 🚀 快速开始

目录###选项1:在URL中传递令牌(推荐)

  • 快速开始启动服务器并通过URL查询参数传递令牌:

配置Claude桌面:

______________________________________________________________________


## Quick Start{

  "mcpServers": {

### Option 1: Pass Token in URL (Recommended)    "MetaAPI MCP": {

      "command": "npx",

Start the server and pass your token via URL query parameter:      "args": [

        "mcp-remote",

Install dependencies ]

npm install }

}

Start the server}

npm start```


### 选项2:使用.env文件

配置Claude桌面:

{npm install

  "mcpServers": {

    "MetaAPI MCP": {# Create .env file with your MetaAPI token

      "command": "npx",echo "METAAPI_TOKEN=your_token_here" > .env

      "args": [

        "mcp-remote",# Start the server

        "http://localhost:3000/sse?token=your_metaapi_token_here"npm start

      ]```

    }

  }Configure Claude Desktop:

}

{

Option 2: Use .env File "mcpServers": {

"MetaAPI MCP": {


# Install dependencies      "args": [

npm install        "mcp-remote",

        "http://localhost:3000/sse"

# Create .env file with your MetaAPI token      ]

echo "METAAPI_TOKEN=your_token_here" > .env    }

  }

# Start the server}

npm start```

查看完整 入门指南 了解更多详情。

配置Claude桌面:

✨ 特性


{### 32 Trading Tools

  "mcpServers": {- **Account Management** - View balances, equity, margin, and account details

    "MetaAPI MCP": {- **Market Data** - Real-time prices, historical candles, tick data

      "command": "npx",- **Order Management** - Market orders, limit orders, stop orders

      "args": [- **Position Management** - Modify, close, or monitor positions

        "mcp-remote",- **Trading History** - View past orders, deals, and performance

        "http://localhost:3000/sse"- **Risk Management** - Calculate margins, set stop losses

      ]

    }### 4 MCP Resources

  }- `metaapi://accounts` - All trading accounts

}- `metaapi://accounts/{accountId}` - Specific account details
  • metaapi://accounts/{accountId}/orders - Pending orders

3 Smart Prompts

Features- account_overview - Complete account analysis

  • risk_check - Pre-trade risk assessment

32 Trading Tools- trading_summary - Recent activity summary

  • Account Management - View balances, equity, margin, and account details## 📖 Documentation
  • Market Data - Real-time prices, historical candles, tick data
  • Order Management - Market orders, limit orders, stop orders- Getting Started - Installation and setup
  • Position Management - Modify, close, or monitor positions- Tools Reference - All 32 tools documented
  • Trading History - View past orders, deals, and performance- Usage Examples - Practical trading examples
  • Risk Management - Calculate margins, set stop losses- Configuration - Advanced configuration options
  • **** - Production deployment with Docker

4 MCP Resources- Quick Deploy Guide - Fast deployment commands

  • metaapi://accounts - All trading accounts## 🐳 Docker Deployment
  • metaapi://accounts/{accountId} - Specific account details
  • metaapi://accounts/{accountId}/positions - Open positionsQuick start with Docker:
  • metaapi://accounts/{accountId}/orders - Pending orders

### 3 Smart Prompts# Using Docker Compose

docker-compose up -d

- `account_overview` - Complete account analysis

- `risk_check` - Pre-trade risk assessment# Or using npm scripts

- `trading_summary` - Recent activity summarynpm run compose:up

______________________________________________________________________

医生.md 获取完整的部署指南。

入门指南

🎯 Claude使用示例

先决条件

配置后,您可以询问Claude:

  • Node.js 18或更高版本
  • MetaAPI帐户和API令牌\\\`
  • Claude Desktop应用程序“列出我的交易账户”

“欧元兑美元的当前价格是多少?”

安装“显示我的空缺职位”

“买入0.1手欧元兑美元,止损1.0850”

  1. 克隆或下载此项目“以英镑兑美元的价格获取最后50小时的蜡烛”

2. **Install dependencies**

npm install


3. **Configure your MetaAPI token**```

   MetaAPI MCP Server (HTTP/SSE)

   Create a `.env` file in the project root:├── Express Server (Port 3000)

METAAPI_TOKEN=your_metaapi_token_here│ ├── 32 Trading Tools


│   └── 3 Prompts

4. **Start the server**└── MetaAPI SDK Client

npm start```


## 📋 先决条件

服务器将于启动 `http://localhost:3000`

- Node.js>=18.0.0

### 配置克劳德桌面-MetaAPI帐户([注册](https://metaapi.cloud/))

- MetaAPI仪表板中的API令牌

1. **打开Claude Desktop配置文件**-在MetaAPI中至少配置一个MT4/MT5账户

   - macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`

   - 窗户: `%APPDATA%\Claude\claude_desktop_config.json`## 🔧 安装和设置

1. **添加MetaAPI MCP服务器配置**查看完整 [入门指南](docs/GETTING_STARTED.md) 详细说明。

   **选项A:在URL查询参数中传递令牌(建议用于远程服务器)**###快速设置

{1. Clone/download this repository

"mcpServers": {2. Install dependencies: npm install

"MetaAPI MCP": {3. Create .env file with your METAAPI_TOKEN

"command": "/Users/yourusername/.nvm/versions/node/v20.18.1/bin/npx",4. Start server: npm start

"args": [5. Configure Claude Desktop (see guide)

"mcp-remote",

"http://localhost:3000/sse?token=your_metaapi_token_here"## 💡 Available Commands

],

"env": {```bash

"NODE_PATH": "/Users/yourusername/.nvm/versions/node/v20.18.1/lib/node_modules",npm start # Start the server

"PATH": "/Users/yourusername/.nvm/versions/node/v20.18.1/bin:/usr/local/bin:/usr/bin:/bin"npm run dev # Development mode with auto-reload

}npm test # Run test suite

}```

}

}## 🔗 API Endpoints


   - `http://localhost:3000/health` -健康检查

   **选项B:使用.env文件(更简单的配置)**- `http://localhost:3000/sse` -MCP客户端的SSE连接

   \`\`\`json- `http://localhost:3000/message/:sessionId` -JSON-RPC消息

   {

   “mcpServers”:{##🛠️ 发展

"MetaAPI MCP": {

"command": "npx",### Project Structure

"args": [

"mcp-remote",```

"http://localhost:3000/sse"metaapi-mcp-server/

]├── src/

}│ ├── index.js # Main server & MCP setup


   }│   ├── config.js#配置和MetaAPI客户端

   }│   └── utils/

│       ├── connection.js#连接管理

3. **重新启动克劳德桌面**│       └── helpers.js#辅助函数

   ├── tests/#测试文件

   完全退出并重新启动应用程序。├── scripts/#实用程序脚本

├── docs/#文档

### 验证连接└── .env#环境变量(创建此变量)

Once Claude Desktop restarts, try asking:

Testing

  • "What MCP servers are connected?"
  • "List my MetaAPI trading accounts"```bash

Test basic functionality

You should see the MetaAPI MCP server in the list of available servers.node tests/test_client.js

---# Test all MCP features

node tests/test_mcp_client.js

Tools Reference

Test market data visualization

The MetaAPI MCP Server provides 32 tools for trading, market data, and account management.node tests/test_candle_viz.js


### 账户管理

## 📚 了解更多

#### list_计数

列出可使用API令牌访问的所有MetaAPI帐户。- [MetaAPI文档](https://metaapi.cloud/docs/)

- [模型上下文协议](https://modelcontextprotocol.io/)

**退货:** 包含id、名称、类型、平台和状态的帐户对象数组- [MCP SDK文档](https://github.com/modelcontextprotocol/sdk)

**例子:**## ⚠️ 重要说明

"List my trading accounts"- Demo Accounts: Test with demo accounts before using real money


- **Security**: Keep your API token secure, never commit `.env` files

#### get_account_information- **Risk**: Trading involves risk - use proper risk management

Get detailed information about a specific trading account including balance, equity, and margin.

## 📄 License

**Arguments:**

- `accountId` (required): The MetaAPI account IDMIT

**Example:**## 🤝 Contributing

“显示账户abc123的账户信息”欢迎捐款!请先阅读捐款指南。


## 📞 Support

---

- [MetaAPI Support](https://metaapi.cloud/docs/)

### Market Data- [MCP Documentation](https://modelcontextprotocol.io/)

- Issues: Use GitHub Issues for bug reports

#### get_symbols

List all available trading symbols (currency pairs, commodities, etc.) for an account.---

**Arguments:**Made with ❤️ for AI-powered trading

- `accountId` (required): The MetaAPI account ID- The server will attempt to deploy accounts automatically

- This may take a few minutes on first connection

**Example:**- Check account status in MetaAPI dashboard

“我可以在账户abc123上交易哪些交易品种?”“交易环境繁忙”


- Retry the operation after a short delay

#### get_symbol_specification- The server will include this in the error message

Get detailed specification for a symbol including tick size, contract size, trading hours, etc.

**"Market is closed"**

**Arguments:**- Trading session is closed for the symbol

- `accountId` (required): The MetaAPI account ID- Check broker trading hours

- `symbol` (required): Symbol name (e.g., "EURUSD")- Use `get_server_time` to verify current time

**Example:****Connection timeouts**

"Get the specification for EURUSD"- The server logs progress during connection/synchronization


#### get_symbol_price## Performance Tips

Get current real-time price for a symbol.

1. **Reuse connections**: The server caches connections automatically

**Arguments:**2. **Batch queries**: Use resources to get multiple data points efficiently

- `accountId` (required): The MetaAPI account ID3. **Streaming for prices**: Use `subscribe_price` instead of polling `get_symbol_price`

- `symbol` (required): Symbol name4. **Check margin first**: Use `calculate_margin` before placing orders to avoid rejections

**Example:**## Resources

“英镑兑美元的当前价格是多少?”- MetaAPI文档


- [Model Context Protocol](https://modelcontextprotocol.io/)

#### get_candles- [MCP SDK Documentation](https://github.com/modelcontextprotocol/typescript-sdk)

Retrieve historical candle/bar data for technical analysis.

## License

**Arguments:**

- `accountId` (required): The MetaAPI account IDMIT

- `symbol` (required): Symbol name

- `timeframe` (required): Candle timeframe (1m, 5m, 15m, 30m, 1h, 4h, 1d, 1w, 1mn)## Support

- `limit` (optional): Number of candles (default: 100, max: 1000)

For issues related to:

**Example:**- **MetaAPI functionality**: Check [MetaAPI docs](https://metaapi.cloud/docs/) or contact MetaAPI support

"Get the last 50 hourly candles for EURUSD"- MCP protocol: See MCP documentation


#### get_tick_data

检索最近的逐笔价格数据。

**论据:**

- `accountId` (必填):MetaAPI帐户ID
- `symbol` (必填):符号名称
- `limit` (可选):滴答数(默认值:100,最大值:1000)

**例子:**

"Show me the last 200 ticks for USDJPY"


#### get_current_tick

获取某个符号的最新刻度。

**论据:**

- `accountId` (必填):MetaAPI帐户ID
- `symbol` (必填):符号名称

**例子:**

"What's the current tick for GOLD?"


______________________________________________________________________

### 职位管理

#### get_positions

列出一个账户的所有未平仓头寸。

**论据:**

- `accountId` (必填):MetaAPI帐户ID

**例子:**

"Show my open positions"


#### get_position

通过ID获取特定职位的详细信息。

**论据:**

- `accountId` (必填):MetaAPI帐户ID
- `positionId` (必填):职位ID

**例子:**

"Get details for position 12345"


#### 修改位置

修改现有头寸的止损或止盈。

**论据:**

- `accountId` (必填):MetaAPI帐户ID
- `positionId` (必填):职位ID
- `stopLoss` (可选):新的止损价格
- `takeProfit` (可选):新的止盈价格

**例子:**

"Set stop loss to 1.0850 and take profit to 1.0950 for position 12345"


#### 闭合位置

部分或完全关闭未平仓头寸。

**论据:**

- `accountId` (必填):MetaAPI帐户ID
- `positionId` (必填):职位ID
- `volume` (可选):关闭音量(如果部分关闭)

**例子:**

"Close position 12345"


#### close_position_by_symbol

关闭特定符号的所有位置。

**论据:**

- `accountId` (必填):MetaAPI帐户ID
- `symbol` (必填):符号名称

**例子:**

"Close all EURUSD positions"


______________________________________________________________________

### 订单管理

#### 获取订单

列出所有待处理的订单。

**论据:**

- `accountId` (必填):MetaAPI帐户ID

**例子:**

"Show my pending orders"


#### 获取订单

按ID获取特定订单的详细信息。

**论据:**

- `accountId` (必填):MetaAPI帐户ID
- `orderId` (必填):订单ID

**例子:**

"Get details for order 67890"


#### create_market_order

执行市价单,以当前价格立即买入或卖出。

**论据:**

- `accountId` (必填):MetaAPI帐户ID
- `symbol` (必填):符号名称
- `actionType` (必填):“ORDER_TYPE_BUY”或“ORDER_TYPE_SELL”
- `volume` (必填):批量交易量
- `stopLoss` (可选):止损价
- `takeProfit` (可选):获利价格
- `comment` (可选):订单备注

**例子:**

"Buy 0.1 lots of EURUSD with stop loss at 1.0850"


#### create_limit_order

创建一个挂起的限价单,以特定价格买入/卖出。

**论据:**

- `accountId` (必填):MetaAPI帐户ID
- `symbol` (必填):符号名称
- `actionType` (必填):“ORDER_TYPE_BUY_LIMIT”或“ORDER_TYPE_SELL_LIMIT”
- `volume` (必填):批量交易量
- `openPrice` (必填):执行订单的价格
- `stopLoss` (可选):止损价
- `takeProfit` (可选):获利价格
- `comment` (可选):订单备注

**例子:**

"Create a buy limit order for GBPUSD at 1.2500, volume 0.2 lots"


#### 创建停止订单

创建待处理的止损单。

**论据:**

- `accountId` (必填):MetaAPI帐户ID
- `symbol` (必填):符号名称
- `actionType` (必填):“ORDER_TYPE_BUY_STOP”或“ORDER_TYPE_SELL_STOP”
- `volume` (必填):批量交易量
- `openPrice` (必填):触发订单的价格
- `stopLoss` (可选):止损价
- `takeProfit` (可选):获利价格
- `comment` (可选):订单备注

**例子:**

"Create a buy stop order for USDJPY at 150.00"


#### 修改订单

修改挂单价格或止损/止盈。

**论据:**

- `accountId` (必填):MetaAPI帐户ID
- `orderId` (必填):订单ID
- `openPrice` (可选):新开盘价
- `stopLoss` (可选):新止损
- `takeProfit` (可选):新止盈

**例子:**

"Change order 67890 open price to 1.2550"


#### 取消订单

取消待处理订单。

**论据:**

- `accountId` (必填):MetaAPI帐户ID
- `orderId` (必填):订单ID

**例子:**

"Cancel order 67890"


______________________________________________________________________

### 交易历史

#### 获取历史_订单_按票

获取按票号筛选的历史订单。

**论据:**

- `accountId` (必填):MetaAPI帐户ID
- `ticket` (必填):机票/订单号

**例子:**

"Get history for ticket 12345"


#### get_history_orders_by_position

获取与头寸关联的历史订单。

**论据:**

- `accountId` (必填):MetaAPI帐户ID
- `positionId` (必填):职位ID

**例子:**

"Get order history for position 12345"


#### get_history_orders_by_time_range

获取一个时间范围内的历史订单。

**论据:**

- `accountId` (必填):MetaAPI帐户ID
- `startTime` (必填):开始时间(ISO 8601格式)
- `endTime` (必填):结束时间(ISO 8601格式)
- `offset` (可选):分页偏移量(默认值:0)
- `limit` (可选):结果限制(默认值:1000)

**例子:**

"Get all orders from January 1 to January 31, 2024"


#### 获取_折扣_门票

获取按票号过滤的交易历史记录。

**论据:**

- `accountId` (必填):MetaAPI帐户ID
- `ticket` (必填):票号

**例子:**

"Get deals for ticket 12345"


#### get_deals_by_position

获取与职位相关的交易。

**论据:**

- `accountId` (必填):MetaAPI帐户ID
- `positionId` (必填):职位ID

**例子:**

"Get deals for position 12345"


#### get_deals_by_time_range

在一定时间内达成交易。

**论据:**

- `accountId` (必填):MetaAPI帐户ID
- `startTime` (必填):开始时间(ISO 8601格式)
- `endTime` (必填):结束时间(ISO 8601格式)
- `offset` (可选):分页偏移量(默认值:0)
- `limit` (可选):结果限制(默认值:1000)

**例子:**

"Show all deals from last week"


______________________________________________________________________

### 市场订阅

#### subscribe_to_market_data

订阅交易品种的实时价格更新。

**论据:**

- `accountId` (必填):MetaAPI帐户ID
- `symbol` (必填):符号名称
- `subscriptions` (可选):订阅类型数组

**例子:**

"Subscribe to real-time prices for EURUSD"


#### unsubscribe_from_market_data

取消订阅价格更新。

**论据:**

- `accountId` (必填):MetaAPI帐户ID
- `symbol` (必填):符号名称

**例子:**

"Unsubscribe from EURUSD updates"


#### get_active_订阅

列出所有活跃的市场数据订阅。

**论据:**

- `accountId` (必填):MetaAPI帐户ID

**例子:**

"What symbols am I subscribed to?"


______________________________________________________________________

### 服务器信息

#### get_server_time

从MetaAPI获取当前服务器时间。

**论据:**

- `accountId` (必填):MetaAPI帐户ID

**例子:**

"What's the server time?"


#### calculate_margin

计算交易所需的保证金。

**论据:**

- `accountId` (必填):MetaAPI帐户ID
- `symbol` (必填):符号名称
- `type` (必填):订单类型
- `volume` (必填):批量交易量
- `openPrice` (必填):预期开盘价

**例子:**

"Calculate margin for buying 1 lot of EURUSD at 1.0900"


______________________________________________________________________

## 用法示例

### 市场数据分析

#### 查看当前价格

"What's the current price of EURUSD?"

"Show me real-time prices for GBPUSD, USDJPY, and GOLD"


#### 获取历史数据

"Get the last 100 hourly candles for EURUSD"

"Show me daily candles for GBPUSD from the last month"


#### 分析Tick数据

"Get the last 500 ticks for USDJPY"


#### 符号信息

"Get the symbol specification for GOLD"


______________________________________________________________________

### 职位管理工作流程

#### 查看空缺职位

"Show all my open positions"

"What positions do I have on EURUSD?"


#### 修改职位

"Set stop loss to 1.0850 for position 12345"

"Update position 12345 with stop loss 1.0850 and take profit 1.0950"


#### 关闭头寸

"Close position 12345"

"Close all EURUSD positions"

"Close half of position 12345"


______________________________________________________________________

### 订单管理模式

#### 查看待处理订单

"Show my pending orders"

"What orders do I have for GBPUSD?"


#### 创建市场订单

"Buy 0.1 lots of EURUSD at market price"

"Sell 0.5 lots of GBPUSD with stop loss at 1.2500 and take profit at 1.2700"


#### 创建限价订单

"Create a buy limit order for EURUSD at 1.0850, volume 0.2 lots"

"Set a sell limit order at 1.1000 for EURUSD with 0.1 lot volume"


#### 创建止损单

"Create a buy stop order for GBPUSD at 1.2600"

"Set a sell stop for USDJPY at 149.50 with volume 0.3 lots"


#### 修改订单

"Change the open price of order 67890 to 1.0900"

"Update order 67890 stop loss to 1.0850"


#### 取消订单

"Cancel order 67890"


______________________________________________________________________

### 复杂的多步骤工作流

#### 完整的交易分析

"For account abc123:

  1. Show current balance and equity
  2. Get the last 50 hourly candles for EURUSD
  3. Show current EURUSD price
  4. List any open EURUSD positions"

#### 风险管理

"For my position 12345:

  1. Get the current position details
  2. Show me the current price
  3. Calculate what my loss would be if I set stop loss at 1.0850"

#### 投资组合概览

"Give me a complete overview:

  1. List all my trading accounts
  2. For each account, show balance and open positions
  3. Show pending orders
  4. List active market subscriptions"

______________________________________________________________________

### 交易技巧

1. **具体说明帐户ID** -使用多个帐户时,始终包含帐户ID
1. **使用自然语言** -克劳德理解对话请求
1. **合并多个请求** -在一个查询中询问相关信息
1. **检查规格** -交易前查看交易品种规格,以了解报价单大小和合约价值
1. **监视器位置** -定期检查头寸状态,根据需要调整止损

______________________________________________________________________

## 配置

### 环境变量

创建一个 `.env` 项目根目录中的文件:

Required: Your MetaAPI API token

METAAPI_TOKEN=your_token_here

Optional: Server port (default: 3000)

PORT=3000

Optional: Log level (default: info)

LOG_LEVEL=info


### 获取MetaAPI令牌

1. 注册地址: [MetaAPI](https://metaapi.cloud/)
1. 导航到您的仪表板
1. 生成API令牌
1. 将令牌复制到您的 `.env` 文件

______________________________________________________________________

### 服务器配置

#### 端口配置

默认端口为3000。要更改,请设置 `.env`:

PORT=8080


#### Claude桌面中的自定义端口

如果更改了服务器端口:

{ "mcpServers": { "MetaAPI MCP": { "command": "npx", "args": [ "mcp-remote", "http://localhost:8080/sse" ] } } }


#### 帐户筛选

默认情况下,与您的令牌关联的所有MetaAPI帐户都是可访问的。要限制对特定帐户的访问,请传递 `accounts` SSE URL中的参数:

{ "mcpServers": { "MetaAPI MCP": { "command": "npx", "args": [ "mcp-remote", "http://localhost:3000/sse?token=your_token&accounts=account_id_1,account_id_2" ] } } }


**优点:**

- **安全**:仅限制访问生产帐户
- **多环境**:为模拟账户和真实账户创建单独的Claude配置
- **团队访问权限**:与不同的团队成员共享不同的帐户集
- **灵活性**:在不重新启动服务器的情况下更改允许的帐户

**示例配置:**

仅生产:

"http://localhost:3000/sse?token=xxx&accounts=prod_account_123"


演示和登台:

"http://localhost:3000/sse?token=xxx&accounts=demo_456,staging_789"


无筛选器(所有帐户均可访问):

"http://localhost:3000/sse?token=xxx"


当 `accounts` 参数已设置 `list_accounts` 该工具将只返回指定的帐户。尝试访问其他帐户仍然有效,但不会出现在列表中。

#### 多个服务器

您可以运行多个实例,也可以使用具有不同帐户筛选器的同一服务器:

{ "mcpServers": { "MetaAPI Production": { "command": "npx", "args": [ "mcp-remote", "http://localhost:3000/sse?token=your_token&accounts=prod_account_123" ] }, "MetaAPI Demo": { "command": "npx", "args": [ "mcp-remote", "http://localhost:3000/sse?token=your_token&accounts=demo_account_456,demo_account_789" ] }, "MetaAPI All Accounts": { "command": "npx", "args": [ "mcp-remote", "http://localhost:3000/sse?token=your_token" ] } } }


这允许您在Claude中切换不同的帐户集,而无需更改服务器配置。

______________________________________________________________________

### 安全考虑

#### API代币安全

- 永不承诺 `.env` 文件到版本控制
- 保持您的MetaAPI令牌私有
- 定期旋转令牌
- 使用单独的令牌进行生产和测试

#### 网络安全

- 默认情况下,服务器在本地主机上运行
- 仅在绝对必要时才暴露于网络
- 在生产环境中使用HTTPS(需要反向代理)
- 考虑暴露实例的防火墙规则

#### Claude桌面访问

- Claude Desktop通过本地主机连接
- 无需外部网络访问
- 代币留在您的机器上

______________________________________________________________________

### 性能调整

#### 市场数据限制

- 蜡烛:每次请求最多1000支
- 勾选:每个请求最多1000个
- 历史:有偏移/限制

#### 速率限制

MetaAPI有速率限制。服务器不会强制执行其他限制,但请注意:

- 每分钟API调用次数
- 并发连接
- 数据检索限制

检查 [MetaAPI文档](https://metaapi.cloud/docs/) 对于当前的限制。

______________________________________________________________________

## 建筑

MetaAPI MCP Server (HTTP/SSE) ├── Express Server (Port 3000) ├── MCP Server Instance │ ├── 32 Trading Tools │ ├── 4 Resources │ └── 3 Prompts └── MetaAPI SDK Client └── Your MT4/MT5 Accounts


### 项目结构

metaapi-mcp-server/ ├── src/ │ ├── index.js # Main server & MCP setup │ ├── config.js # Configuration & MetaAPI client │ └── utils/ │ ├── logger.js # Logging utility │ ├── connection.js # Connection management │ └── helpers.js # Helper functions ├── tests/ # Test files ├── config/ # Config examples ├── docs/ # Documentation └── .env # Environment variables (create this)


______________________________________________________________________

## 发展

### 可用命令

npm start # Start the server npm run dev # Development mode with auto-reload npm test # Run test suite


### API终点

- `http://localhost:3000/health` -健康检查
- `http://localhost:3000/sse` -MCP客户端的SSE连接
- `http://localhost:3000/message/:sessionId` -JSON-RPC消息

### 测试

Test basic functionality

node tests/test_client.js

Test all MCP features

node tests/test_mcp_client.js

Test market data visualization

node tests/test_candle_viz.js


______________________________________________________________________

## 故障排除

### 服务器无法启动

检查:

- 端口3000可用: `lsof -i :3000`
- `.env` 文件存在并且具有METAAPI_TOKEN
- 已安装的依赖项: `npm install`

### 克劳德无法连接

检查:

- 服务器正在运行: `curl http://localhost:3000/health`
- 配置文件语法是有效的JSON
- `mcp-remote` 套餐可用: `npx mcp-remote --version`
- 完全重新启动克劳德桌面

### 无效令牌错误

- 在MetaAPI仪表板中验证令牌
- 检查中是否有空格 `.env` 文件
- 确保令牌未过期
- 尝试重新生成令牌

### 健康检查

测试服务器是否正在运行:

curl http://localhost:3000/health


应返回:

{"status":"ok","server":"MetaAPI MCP Server"}


### 常见问题

**“帐户未部署”**

- 服务器将尝试自动部署帐户
- 首次连接时可能需要几分钟
- 在MetaAPI仪表板中检查帐户状态

**“交易环境繁忙”**

- MT终端正在处理另一个请求
- 在短暂延迟后重试该操作

**“市场关闭”**

- 该交易品种的交易时段已结束
- 查看经纪商交易时间
- 使用 `get_server_time` 验证当前时间

**连接超时**

- 首次连接到帐户可能需要2-5分钟
- 服务器记录连接/同步过程中的进度

______________________________________________________________________

## 性能提示

1. **重复使用连接**:服务器自动缓存连接
1. **批量查询**:利用资源高效获取多个数据点
1. **价格流媒体**:使用 `subscribe_to_market_data` 而不是投票 `get_symbol_price`
1. **先检查保证金**:使用 `calculate_margin` 下单前避免退货

______________________________________________________________________

## 支持

### 外部资源

- [MetaAPI文档](https://metaapi.cloud/docs/)
- [MetaAPI JavaScript SDK](https://github.com/agiliumtrade-ai/metaapi-node.js-sdk)
- [模型上下文协议](https://modelcontextprotocol.io/)
- [MCP SDK文档](https://github.com/modelcontextprotocol/typescript-sdk)

### 获取帮助

关于以下问题:

- **MetaAPI功能**:检查 [MetaAPI文档](https://metaapi.cloud/docs/) 或联系MetaAPI支持
- **MCP服务器实现**:在此存储库中打开一个问题
- **MCP协议**:参见 [MCP文件](https://modelcontextprotocol.io/)

______________________________________________________________________

## 重要说明

- **模拟账户**:在使用真钱之前,先用模拟账户进行测试
- **API限值**:MetaAPI有速率限制-请参阅其文档
- **安全**:确保API令牌的安全,从不提交 `.env` 文件
- **风险**:交易涉及风险-使用适当的风险管理

______________________________________________________________________

## 许可证

麻省理工学院

______________________________________________________________________

由以下材料制成❤️ 用于人工智能交易

目录标签

目录标签

JavaScriptClaude金融数据AI交易本地部署外汇交易股票交易大宗商品交易自然语言处理

支持客户端

Claude DesktopClaude

接入字段

传输方式(transport,传输协议)

未说明

鉴权方式(authType,认证方式)

token

工具数量(toolCount,工具数)

31

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

未说明token部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

仍需确认:installCommand

来源信息

继续浏览同类 MCP