Skip to content

An MCP (Model Context Protocol) server that exposes ETRADE API operations as tools for AI agents. This allows AI assistants like Claude and GitHub Copilot to interact with ETRADE's trading platform.

License

Notifications You must be signed in to change notification settings

kerryjiang/OpenEtradeMcp

Repository files navigation

OpenEtradeMcp

build License .NET

An MCP (Model Context Protocol) server that exposes ETRADE API operations as tools for AI agents. This allows AI assistants like Claude and GitHub Copilot to interact with ETRADE's trading platform.

NuGet Packages

Package Version Downloads
OpenEtradeMcp NuGet NuGet Downloads
OpenEtradeMcp.Server NuGet NuGet Downloads

Features

  • OAuth 1.0a Authentication: Interactive OAuth flow designed to work seamlessly with AI agents
  • E*TRADE API Tools: Auto-generated tools from E*TRADE's OpenAPI specification
  • Sandbox Support: Test safely with E*TRADE's sandbox environment
  • Global Tool: Install as a .NET global tool for easy access

Prerequisites

Installation

As a .NET Global Tool

dotnet tool install --global OpenEtradeMcp.Server

From Source

git clone https://github.com/kerryjiang/OpenEtradeMcp.git
cd OpenEtradeMcp
dotnet build

Configuration

Environment Variables

export ETRADE_ConsumerKey="your-consumer-key"
export ETRADE_ConsumerSecret="your-consumer-secret"
export ETRADE_UseSandbox="true"  # Optional: use sandbox environment

Command Line Arguments

etrade-mcp --ConsumerKey=your-key --ConsumerSecret=your-secret --UseSandbox=true

Running the Server

Using the Global Tool

etrade-mcp

From Source

cd src/OpenEtradeMcp.Server
dotnet run

MCP Client Configuration

Claude Desktop

Add to your Claude Desktop config file:

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

{
  "mcpServers": {
    "etrade": {
      "command": "/Users/{YourUserName}/.dotnet/tools/etrade-mcp",
      "env": {
        "ETRADE_ConsumerKey": "your-consumer-key",
        "ETRADE_ConsumerSecret": "your-consumer-secret",
        "ETRADE_UseSandbox": "true"
      }
    }
  }
}

Windows: %APPDATA%\Claude\claude_desktop_config.json

{
  "mcpServers": {
    "etrade": {
      "command": "C:\\\\Users\\{YourUserName}\\.dotnet\\tools\\etrade-mcp",
      "env": {
        "ETRADE_ConsumerKey": "your-consumer-key",
        "ETRADE_ConsumerSecret": "your-consumer-secret",
        "ETRADE_UseSandbox": "true"
      }
    }
  }
}

VS Code with GitHub Copilot

Configure in your VS Code MCP settings to use the etrade-mcp command with appropriate environment variables.

OAuth Authentication Flow

The server provides interactive OAuth tools that allow an AI agent to guide users through authentication:

1. Start OAuth (etrade_oauth_start)

Begins the authentication process and returns an authorization URL.

Agent: "I'll start the E*TRADE authentication process."
[Calls etrade_oauth_start]
Agent: "Please click this link to authorize: https://us.etrade.com/e/t/etws/authorize?..."

2. Complete OAuth (etrade_oauth_complete)

After the user authorizes and receives the verifier code:

User: "I got the code: ABC123"
Agent: "Great, let me complete the authentication."
[Calls etrade_oauth_complete with verifierCode="ABC123"]
Agent: "Authentication successful! You can now use E*TRADE API tools."

3. Additional OAuth Tools

  • etrade_oauth_status - Check authentication status
  • etrade_oauth_renew - Renew access token (tokens expire at midnight Eastern)
  • etrade_oauth_revoke - Log out and revoke access token

Available Tools

OAuth Tools

Tool Description
etrade_oauth_start Start OAuth authentication flow
etrade_oauth_complete Complete OAuth with verifier code
etrade_oauth_status Check authentication status
etrade_oauth_renew Renew access token
etrade_oauth_revoke Revoke access token

E*TRADE API Tools

Tools are auto-generated from the E*TRADE OpenAPI specification and include:

  • Account Management - List accounts, view account details
  • Portfolio - View positions and holdings
  • Orders - Place, preview, and manage orders
  • Market Data - Get quotes, option chains, and market information
  • Alerts - Manage price and trading alerts

Project Structure

OpenEtradeMcp/
├── src/
│   ├── OpenEtradeMcp/              # Core library with E*TRADE API definitions
│   │   └── etrade-api.yaml        # E*TRADE OpenAPI specification
│   └── OpenEtradeMcp.Server/       # MCP server executable
├── Directory.Build.props          # Shared build properties
├── Directory.Packages.props       # Centralized package management
└── OpenEtradeMcp.sln              # Solution file

Security Notes

  • Never commit credentials - Use environment variables for your consumer key/secret
  • Memory-only tokens - Access tokens are stored in memory and not persisted to disk
  • Use sandbox first - Test with sandbox environment before using production credentials

Troubleshooting

"OpenAPI spec file not found"

Ensure the etrade-api.yaml file is in the output directory. Rebuild the project.

"E*TRADE API credentials not provided"

Set the ConsumerKey and ConsumerSecret environment variables.

Authentication fails

  • Verify your credentials are correct
  • Ensure sandbox credentials are used with UseSandbox=true
  • Check that the verifier code is entered correctly (no extra spaces)

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Author

Kerry Jiang - GitHub

About

An MCP (Model Context Protocol) server that exposes ETRADE API operations as tools for AI agents. This allows AI assistants like Claude and GitHub Copilot to interact with ETRADE's trading platform.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages