Deployed on Cloudflare Workers with Durable Objects for state management, providing serverless hosting for the MCP server with OAuth token storage via KV namespaces
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., "@Schwab MCP Servershow me my account balances and positions"
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.
Schwab MCP Server
A Model Context Protocol (MCP) server that enables AI assistants like Claude to securely interact with Charles Schwab accounts and market data through the official Schwab API.
What You Can Do
Ask Claude to:
"Show me my Schwab account balances and positions"
"Get real-time quotes for AAPL, GOOGL, and MSFT"
"What are today's market movers in the $SPX?"
"Show me the options chain for TSLA with Greeks"
"Get my transactions from the last 30 days"
"Search for ETFs related to technology"
"Check if the markets are open"
Unofficial MCP Server
This is an unofficial, community-developed TypeScript MCP server for Charles Schwab. It has not been approved, endorsed, or certified by Charles Schwab. It is provided as-is, and its functionality may be incomplete or unstable. Use at your own risk, especially when dealing with financial data or transactions.
Overview
This MCP server acts as a bridge between AI assistants and the Schwab API, providing:
Secure OAuth Authentication: Implements Schwab's OAuth 2.0 flow with PKCE for secure authentication
Comprehensive Trading Tools: Access to accounts, orders, quotes, and transactions
Market Data Tools: Real-time quotes, price history, market hours, movers, and options chains
Account Privacy: Built-in account identifier scrubbing to protect sensitive information
Local-Only: Runs entirely on your machine with local HTTPS server and file-based token storage
Features
Trading Tools
Account Management
getAccounts: Retrieve all account information with positions and balancesgetAccountNumbers: Get list of account identifiers
Order Management
getOrder: Get order by IDgetOrders: Fetch orders with filtering by status, time range, and symbolgetOrdersByAccountNumber: Get orders by account numbercancelOrder: Cancel an order (Experimental)placeOrder: Place an order (Experimental)replaceOrder: Replace an order (Experimental)
Market Quotes
getQuotes: Get real-time quotes for multiple symbolsgetQuoteBySymbolId: Get detailed quote for a single symbol
Transaction History
getTransactions: Retrieve transaction history across all accounts with date filtering
User Preferences
getUserPreference: Retrieve user trading preferences and settings
Market Data Tools
Instrument Search
searchInstruments: Search for securities by symbol with fundamental/reference data
Price History
getPriceHistory: Get historical price data with customizable periods and frequencies
Market Hours
getMarketHours: Check market operating hours by dategetMarketHoursByMarketId: Get specific market information
Market Movers
getMovers: Find top market movers by index ($SPX, $COMPX, $DJI)
Options Chains
getOptionChain: Retrieve full options chain data with GreeksgetOptionExpirationChain: Get option expiration dates
Prerequisites
Schwab Developer Account: Register at Schwab Developer Portal
Node.js: Version 20.x or higher (22.x recommended)
Getting Started
Quick Setup
Configuration
1. Create a Schwab App
Log in to the Schwab Developer Portal
Create a new app with:
App Name: Your MCP server name (e.g., "My Schwab MCP")
Callback URL:
https://localhost:3000/callbackApp Type: Personal
Note your App Key (Client ID) and generate an App Secret
2. Configure Environment Variables
Copy the .env.example file to .env and fill in your credentials:
Edit .env:
3. First Run - OAuth Authentication
On the first run, the server will:
Generate self-signed certificates in
.certs/directory (no OpenSSL required)Start an HTTPS server on
https://localhost:3000Open your browser to the Schwab authorization page
After you authorize, tokens will be saved to
.auth/directoryThe MCP server will start and be ready to use
Note: You may need to trust the self-signed certificate in your browser or system. The certificate is only used for localhost OAuth callback and is generated automatically using Node.js crypto libraries.
Usage
Claude Desktop Configuration
Add the server to your Claude Desktop configuration file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
Or if you prefer to build first and run the compiled JavaScript:
Note: The first option using tsx is recommended as it doesn't require a build step.
Restart Claude Desktop. The server will connect via stdio transport.
Example Commands
Once connected, you can ask Claude to:
"Show me my Schwab account balances"
"Get a quote for AAPL"
"What are today's market movers in the $SPX?"
"Show me the options chain for TSLA"
"Get my recent transactions from the last week"
Architecture
Technology Stack
Runtime: Node.js with TypeScript
Authentication: OAuth 2.0 with PKCE via
@sudowealth/schwab-apiAPI Client:
@sudowealth/schwab-apifor type-safe Schwab API accessMCP Framework:
@modelcontextprotocol/sdkwith stdio transportState Management: File-based token storage in
.auth/directoryOAuth Server: Express with HTTPS for OAuth callback handling
Security Features
OAuth 2.0 with PKCE: Secure authentication flow preventing authorization code interception
Local Token Storage: Tokens stored locally in
.auth/directory (never sent to external servers)HTTPS Localhost: Self-signed certificates for secure OAuth callback
Automatic Token Refresh: Tokens refreshed 5 minutes before expiration
Account Scrubbing: Sensitive account identifiers automatically replaced with display names
Secret Redaction: Automatic masking of sensitive data in logs
Development
Available Scripts
Project Structure
Debugging
The server includes comprehensive logging with configurable levels:
Log Levels: trace, debug, info, warn, error, fatal
Set via
LOG_LEVELenvironment variable in.env
Enable debug logging to see detailed OAuth flow and API interactions:
Error Handling
The server implements robust error handling with specific error types:
Authentication Errors (401): Prompt for re-authentication
Client Errors (400): Invalid parameters, missing data
Server Errors (500): API failures, configuration issues
All errors include request IDs for Schwab API troubleshooting
Contributing
Fork the repository
Create a feature branch (
git checkout -b feature/amazing-feature)Commit your changes (
git commit -m 'Add amazing feature')Push to the branch (
git push origin feature/amazing-feature)Open a Pull Request
License
MIT
Troubleshooting
Common Issues
"Certificate error" in browser
This is expected with self-signed certificates
Accept the certificate warning during OAuth flow
The certificate is only used for
https://localhost:3000/callback
"Cannot find module" errors
Run
npm installto ensure all dependencies are installedMake sure you're using Node.js 20.x or higher
Authentication failures
Verify your redirect URI matches exactly:
https://localhost:3000/callbackCheck that your Schwab app credentials are correct in
.envEnable debug logging:
LOG_LEVEL=debugin.env
"Port already in use" error
Change the PORT in
.envto a different valueMake sure no other process is using port 3000
Recent Updates
Local-Only Architecture: Migrated from Cloudflare Workers to local Node.js server
File-Based Token Storage: Tokens stored securely in local
.auth/directoryHTTPS OAuth Flow: Self-signed certificates for secure localhost OAuth callback
Stdio Transport: Uses standard MCP SDK with stdio for Claude Desktop integration
Acknowledgments
Powered by @sudowealth/schwab-api
Built with @modelcontextprotocol/sdk