Tradovate MCP Server on Vercel

This service provides MCP and webhook APIs for Tradovate trading.

Available Endpoints:

Available Tools:

Setting up Local MCP Server for Claude Desktop

1. Create or Modify Claude Desktop Configuration

The configuration file location depends on your operating system:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add Your MCP Server Configuration

Create or edit the config file and add your Tradovate MCP server:

{
  "mcpServers": {
    "tradovate": {
      "command": "node",
      "args": ["/path/to/your/project/build/src/index.js"],
      "env": {
        "TRADOVATE_USERNAME": "your_username",
        "TRADOVATE_PASSWORD": "your_password",
        "TRADOVATE_API_ENVIRONMENT": "demo",
        "TRADOVATE_DEVICE_ID": "your_device_id",
        "TRADOVATE_CID": "your_cid",
        "TRADOVATE_API_SECRET": "your_api_secret",
        "TRADOVATE_DEMO_ACCOUNT_ID": "your_demo_account_id",
        "TRADOVATE_LIVE_ACCOUNT_ID": "your_live_account_id",
        "NODE_ENV": "production"
      }
    }
  }
}

Important Notes:

  • Path: Replace /path/to/your/project/build/src/index.js with the actual path to your built server file, for example, C:/john/website/TradovateMCP/build/src/index.js
  • Environment variables: Replace all placeholder values with your actual Tradovate API credentials
  • Multiple servers: If you have other MCP servers, you can add them to the same config file

Alternative: Using npm Command

If you prefer to run it through npm:

{
  "mcpServers": {
    "tradovate": {
      "command": "npm",
      "args": ["run", "start"],
      "cwd": "/path/to/your/project",
      "env": {
        "TRADOVATE_USERNAME": "your_username",
        "TRADOVATE_PASSWORD": "your_password",
        "TRADOVATE_API_ENVIRONMENT": "demo",
        // ... other environment variables
      }
    }
  }
}

3. Restart Claude Desktop

After creating or modifying the configuration file, you must restart Claude Desktop for the changes to take effect.

4. Verify the Connection

Once Claude Desktop is restarted:

  1. Look for your MCP server in the Claude Desktop interface (usually shown in the bottom-left corner when connected)
  2. You should see the Tradovate tools available when you start typing commands
  3. Try using one of the tools like "get available accounts" to verify it's working

5. Example Usage in Claude Desktop

Once connected, you can use your tools like this:

Get my available trading accounts
Place a bracket order for ESM5
Check PnL for my NQM5 position  
List my current positions
Show me common contracts
Close position for symbol GCM5

Claude will automatically use your MCP tools to execute these requests and provide the appropriate responses.

Troubleshooting

If you have issues:

  • Check logs: Claude Desktop creates logs that can help debug connection issues
  • Verify paths: Make sure the path to your built server is correct
  • Environment variables: Ensure all required environment variables are properly set
  • Permissions: Make sure the built JavaScript file has execute permissions
  • Test independently: Try running the server with MCP Inspector first to ensure it's working
  • Check build: Ensure your project has been built with npm run build

Complete Environment Variable List

Make sure all these environment variables are set in your config:

{
  "TRADOVATE_USERNAME": "your_username",
  "TRADOVATE_PASSWORD": "your_password",
  "TRADOVATE_API_ENVIRONMENT": "demo",
  "TRADOVATE_DEVICE_ID": "your_device_id",
  "TRADOVATE_CID": "your_cid",
  "TRADOVATE_API_SECRET": "your_api_secret",
  "TRADOVATE_DEMO_ACCOUNT_ID": "your_demo_account_id",
  "TRADOVATE_LIVE_ACCOUNT_ID": "your_live_account_id",
  "NODE_ENV": "production"
}

Connecting to MCP Server with Claude Desktop

Overview

Claude Desktop doesn't have built-in capabilities to connect to custom servers. Instead, you need to set up a client bridge that Claude Desktop can communicate with.

Setup Instructions

1. Create a Simple Client Bridge

Set up a small service that can forward requests from Claude Desktop to your MCP server:

// tradovate-bridge.js
const express = require('express');
const axios = require('axios');
const app = express();
const port = 3000;

// Your MCP server webhook URL
const MCP_WEBHOOK_URL = 'https://your-mcp-server.com/webhook';

app.use(express.json());

// Handle Claude Desktop requests
app.post('/tradovate', async (req, res) => {
  try {
    // Forward the request to your MCP server
    const response = await axios.post(MCP_WEBHOOK_URL, req.body);
    
    // Return the response to Claude Desktop
    res.json(response.data);
  } catch (error) {
    console.error('Error forwarding request:', error);
    res.status(500).json({
      status: 'error',
      message: error.message
    });
  }
});

app.listen(port, () => {
  console.log(`Tradovate bridge listening at http://localhost:${port}`);
});

Run this bridge on your local machine using Node.js.

2. Using Claude Desktop with the Bridge

Since Claude Desktop can't directly connect to custom servers, you can:

  • Ask Claude to generate Tradovate order request JSON
  • Manually send it to your bridge using tools like cURL or Postman
  • Share the response with Claude for analysis

Example Usage

Ask Claude to generate a Tradovate order request like this:

{
  "action": "buy",
  "params": {
    "Ticker": "ESM5",
    "Quantity": 1,
    "LimitPrice": 5680,
    "TakeProfitPoints": 10,
    "StopLossPoints": 5,
    "OrderType": "Limit",
    "UseAutoTrail": true,
    "AutoTrailTrigger": 0.5
  }
}

Advanced Integration

For a more seamless experience, consider:

  • Creating a desktop app that communicates with both Claude and your MCP server
  • Developing a browser extension that enhances Claude with trading buttons
  • Building a trading dashboard that incorporates Claude's AI capabilities

Implementation Guide for Enhanced Tradovate MCP Tools

What's New

  1. Account Selection: Dropdown support for selecting accounts via get_available_accounts
  2. Contract Selection: Dropdown support for common contracts via get_common_contracts
  3. Bracket Order Support: Place orders with take profit and stop loss brackets in a single call
  4. Auto-Trailing Stops: Configure stops that automatically adjust as the market moves in your favor
  5. Dual Account Management: Easily switch between demo and live accounts
  6. Position Management Tools: Check profitable positions and clean up orphaned orders
  7. Additional Risk Management: Estimate margins, check risk parameters, and more

Implementation Steps

1. Update tools.ts

Replace your existing tools.ts file with the enhanced version that includes all the new functionality.

Key changes include:

  • Addition of bracket order handling with handlePlaceBracketOrder and handlePlaceBracketOrderTool
  • New functions for position management: handleCheckPnL and handleCheckOCO
  • Enhanced order functions with support for auto-trailing parameters
  • Support for getting account IDs from environment variables
  • New functions for account and contract selection: getAvailableAccounts and getCommonContracts

2. Update the Tool Definitions in index.ts

Add the new tool definitions to your index.ts file in the server capabilities section.

3. Register the Tool Handlers

Update your CallToolRequestSchema handler in index.ts to include handlers for all the new tools.

4. Configure Environment Variables

Ensure your .env file includes the following variables:

# Tradovate Credentials
TRADOVATE_USERNAME=your_username
TRADOVATE_PASSWORD=your_password
TRADOVATE_APP_ID=your_app_id
TRADOVATE_APP_VERSION=your_app_version
TRADOVATE_DEVICE_ID=your_device_id
TRADOVATE_CID=your_client_id
TRADOVATE_SECRET=your_client_secret

# Tradovate Environment
TRADOVATE_API_ENVIRONMENT=demo  # or 'live'

# Account IDs
TRADOVATE_LIVE_ACCOUNT_ID=12345678
TRADOVATE_DEMO_ACCOUNT_ID=23456789

Using the New Tools

Getting Available Accounts

{
  "action": "get_available_accounts",
  "params": {}
}

Getting Common Contracts

{
  "action": "get_common_contracts",
  "params": {}
}

Placing a Bracket Order

{
  "action": "place_bracket_order",
  "params": {
    "symbol": "ESM5",
    "action": "Buy",
    "orderType": "Limit",
    "quantity": 1,
    "price": 5680,
    "takeProfitPoints": 10,
    "stopLossPoints": 5,
    "useAutoTrail": true,
    "autoTrailTrigger": 0.5,
    "autoTrailStopLoss": 0.25,
    "autoTrailFreq": 0.25,
    "breakeven": 1.5,
    "isLive": false
  }
}

Checking Profitable Positions

{
  "action": "check_pnl",
  "params": {
    "profitThreshold": 5,
    "isLive": false
  }
}

Cleaning Up Orphaned Orders

{
  "action": "check_oco",
  "params": {
    "forceCleanup": true,
    "isLive": false
  }
}

Examples of Common Workflows

1. Trading Lifecycle

  1. Get available accounts: get_available_accounts
  2. Get common contracts: get_common_contracts
  3. Get contract details: get_contract_details
  4. Estimate margin: estimate_margin
  5. Place bracket order: place_bracket_order
  6. Monitor position: list_positions
  7. Check for profit: check_pnl
  8. Liquidate if needed: liquidate_position

2. Account Management

  1. Get accounts: get_available_accounts
  2. Get account summary: get_account_summary
  3. Get risk parameters: get_risk_parameters

3. End of Day Cleanup

  1. Check orphaned orders: check_oco
  2. Check profitable positions: check_pnl
  3. Liquidate all positions: liquidate_all_positions
  4. Cancel all orders: cancel_all_orders

Troubleshooting

If you encounter issues:

  1. Check the logs for specific error messages
  2. Verify that your environment variables are correctly set
  3. Make sure you have valid account IDs configured
  4. Test authentication independently with a simple API call
  5. Verify WebSocket connections are being established properly

Contact Information

Address

Excellgen Inc
15601 Crabbs Branch Way
Rockville, MD 20855

For technical support, feature requests, or general inquiries about the Tradovate MCP Server

Email: phs.phd@gmail.com

WeChat: paulmusic2

Website: https://aiprediction.us