Questrade MCP Server

Questrade MCP Server

An unofficial MCP server that integrates with the Questrade API to provide access to trading accounts, market data, and portfolio information. It enables users to view balances, track positions, search symbols, and analyze market trends through natural language.

Category
访问服务器

README

Questrade MCP Server

npm version Release

An unofficial Model Context Protocol (MCP) server for integrating with the Questrade API, providing access to trading accounts, market data, and portfolio information.

⚠️ Disclaimer: This is an unofficial, community-built integration and is not affiliated with, endorsed by, or supported by Questrade Inc. Use at your own risk.

Features

  • 🔐 Authentication: OAuth 2.0 token management with automatic refresh
  • 📊 Account Data: Access accounts, positions, balances, and order history
  • 📈 Market Data: Real-time quotes, symbol search, and historical candles
  • 🛡️ Error Handling: Comprehensive error handling and logging
  • 🔧 TypeScript: Full TypeScript support with proper type definitions

Installation

Option 1: Install from npm (Recommended)

npm install -g questrade-mcp-server

Option 2: Clone and Build

  1. Clone this repository

  2. Install dependencies:

    npm install
    
  3. Copy the environment template:

    cp .env.example .env
    
  4. Configure your Questrade API credentials in .env:

    QUESTRADE_API_URL=https://api01.iq.questrade.com
    QUESTRADE_REFRESH_TOKEN=your_refresh_token_here
    # QUESTRADE_TOKEN_DIR=/path/to/custom/directory
    

Getting Questrade API Credentials

For detailed information about Questrade's API authorization, see the official API documentation.

Step 1: Generate API Token

  1. Log in to your Questrade account or navigate directly to https://apphub.questrade.com/UI/UserApps.aspx

  2. In the top right corner, select "API centre" from the drop-down menu under your login name

    Add Server

  3. Click "Activate API" and agree to the API access agreement

  4. Click "Generate new token" for manual authorization

    New Device

  5. Copy the refresh token provided

    Generate Token

Step 2: Configure Environment

  1. Copy your refresh token to .env:

    QUESTRADE_REFRESH_TOKEN=your_refresh_token_here
    
  2. The MCP server will automatically:

    • Use your refresh token to get an access token
    • Discover the correct API server URL
    • Handle token refresh when needed
    • Persist new tokens to ~/.questrade-mcp/tokens.json (or system temp directory as fallback)

Important: Refresh tokens are single-use only. The server will attempt to persist new refresh tokens to ~/.questrade-mcp/tokens.json (configurable via QUESTRADE_TOKEN_DIR environment variable), but if a token expires or gets used by another process, you'll need to manually generate a new one following the steps above.

Step 3: Test Your Setup

Verify your token works correctly:

npm run test-connection

Note: If you get a "'tsx' is not recognized" error, the test script will automatically build the project first and use Node.js instead.

Usage

Development

npm run dev

Production

npm run build
npm start

Adding to Claude Desktop

  1. Find your Claude Desktop config file:

    • Windows: %APPDATA%\Claude\claude_desktop_config.json
    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
    • Linux: ~/.config/Claude/claude_desktop_config.json
  2. Add the MCP server configuration:

    Quick setup (Recommended)

    {
      "mcpServers": {
        "questrade": {
          "command": "npx",
          "args": ["questrade-mcp-server"],
          "env": {
            "QUESTRADE_REFRESH_TOKEN": "your_refresh_token_here"
          }
        }
      }
    }
    

    Local development build

    {
      "mcpServers": {
        "questrade": {
          "command": "node",
          "args": ["/path/to/your/project/dist/index.js"],
          "env": {
            "QUESTRADE_REFRESH_TOKEN": "your_refresh_token_here"
          }
        }
      }
    }
    
  3. If using local build, update the path to match your actual project location

  4. Restart Claude Desktop

  5. Test the connection by asking Claude to show your Questrade accounts

For detailed setup instructions, see claude-desktop-config.md.

Available Tools

Account Management

  • get_accounts - Get all Questrade accounts
  • get_positions - Get positions for a specific account
  • get_balances - Get balances for a specific account
  • get_orders - Get order history for an account

Market Data

  • search_symbols - Search for symbols by prefix
  • get_symbol - Get detailed symbol information
  • get_quotes - Get real-time quotes for symbols
  • get_candles - Get historical price data

Authentication

  • refresh_token - Refresh the API access token

Built-in Prompts

The MCP server includes helpful prompts for common trading analysis tasks:

Portfolio Summary

Prompt: portfolio_summary

  • Get a comprehensive portfolio analysis with account balances, positions, and performance
  • Optional: Specify accountNumber (uses first account if not provided)

Stock Analysis

Prompt: stock_analysis

  • Analyze a specific stock with current quotes, symbol information, and recent performance
  • Required: symbol (e.g., "AAPL", "TSLA", "MSFT")

Trading Opportunities

Prompt: trading_opportunities

  • Identify potential trading opportunities based on current positions and market data
  • Optional: accountNumber (uses first account if not provided)
  • Optional: riskLevel ("conservative", "moderate", or "aggressive")

Example Usage

Simply ask Claude:

  • "Use the portfolio_summary prompt to analyze my trading account"
  • "Analyze AAPL stock using the stock_analysis prompt"
  • "Show me trading opportunities with conservative risk level"

Tool Examples

Get Accounts

{
  "name": "get_accounts"
}

Get Positions

{
  "name": "get_positions",
  "arguments": {
    "accountNumber": "12345678"
  }
}

Search Symbols

{
  "name": "search_symbols",
  "arguments": {
    "prefix": "AAPL",
    "offset": 0
  }
}

Get Quotes

{
  "name": "get_quotes",
  "arguments": {
    "symbolIds": [8049, 9291]
  }
}

Configuration

The server uses environment variables for configuration:

  • QUESTRADE_API_URL: Base URL for Questrade API (default: https://api01.iq.questrade.com)
  • QUESTRADE_REFRESH_TOKEN: Your API refresh token
  • QUESTRADE_TOKEN_DIR: Custom directory for token storage (default: ~/.questrade-mcp)

Error Handling

The server includes comprehensive error handling for:

  • Invalid or expired tokens (automatic refresh)
  • Missing required parameters
  • API rate limits and network errors
  • Invalid account numbers or symbol IDs

Security Notes

  • Never commit your .env file to version control
  • Access tokens expire after 7 days
  • Refresh tokens are automatically used to get new access tokens
  • This is an unofficial tool - ensure you comply with Questrade's API terms of service
  • Always verify trading decisions independently before executing trades

Development

Project Structure

src/
├── index.ts          # Main MCP server implementation
├── questrade-client.ts # Questrade API client
└── types.ts          # TypeScript type definitions

Building

npm run build

Cleaning

npm run clean

License

MIT

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选