Enables secure interaction with Charles Schwab accounts, accessing real-time market data, account balances, positions, transactions, orders, and options chains through the official Schwab API
Deployed on Cloudflare Workers with Durable Objects for state management and secure token storage
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
- Enterprise-Ready: Deployed on Cloudflare Workers with Durable Objects for state management
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
- Cloudflare Account: For deployment (Workers paid plan required for Durable Objects)
- Node.js: Version 22.x or higher
- Wrangler CLI: Installed via npm (included in dev dependencies)
Getting Started
Quick Setup
Configuration Notes
wrangler.example.jsonc
- Template configuration (committed)wrangler.jsonc
- Your personal config (git-ignored, created from template).dev.vars
- Local development secrets (git-ignored, optional)
Since wrangler.jsonc
is git-ignored, you can safely develop and test with your
personal configuration without exposing secrets.
Detailed Configuration
1. Create a Schwab App
- Log in to the Schwab Developer Portal
- Create a new app with:
- App Name: Your MCP server name
- Callback URL:
https://schwab-mcp.<your-subdomain>.workers.dev/callback
- App Type: Personal or third-party based on your use case
- Note your App Key (Client ID) and generate an App Secret
2. Set Environment Variables
The same secrets from Quick Setup need to be set (see above).
GitHub Actions Deployment
For automated deployments, add these GitHub repository secrets:
CLOUDFLARE_API_TOKEN
: Your Cloudflare API tokenOAUTH_KV_ID
: Your KV namespace ID
The workflow handles validation and deployment when pushing to main
.
Cloudflare secrets must still be set via wrangler secret
.
Testing with Inspector
Test your deployment using the MCP Inspector:
Enter https://schwab-mcp.<your-subdomain>.workers.dev/sse
and connect. You'll
be prompted to authenticate with Schwab.
Usage
Claude Desktop Configuration
1. Use Claude Integrations
- Go to the Claude Desktop settings
- Click on the "Integrations" tab
- Click on the "Add Custom Integration" button
- Enter the integration name "Schwab"
- Enter the MCP Server URL:
https://schwab-mcp.<your-subdomain>.workers.dev/sse
- Click on the "Add" button
- Click "Connect" and the Schwab Authentication flow will start.
2. Add the MCP Server to your Claude Desktop configuration
Add the following to your Claude Desktop configuration file:
Restart Claude Desktop. When you first use a Schwab tool, a browser window will open for authentication.
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"
Local Development
For local development, create a .dev.vars
file (automatically ignored by git):
Run locally:
Connect to http://localhost:8788/sse
using the MCP Inspector for testing.
Architecture
Technology Stack
- Runtime: Cloudflare Workers with Durable Objects
- Authentication: OAuth 2.0 with PKCE via
@cloudflare/workers-oauth-provider
- API Client:
@sudowealth/schwab-api
for type-safe Schwab API access - MCP Framework:
@modelcontextprotocol/sdk
withworkers-mcp
adapter - State Management: KV storage for tokens, Durable Objects for session state
Security Features
- OAuth 2.0 with PKCE: Secure authentication flow preventing authorization code interception
- Enhanced Token Management:
- Centralized KV token store with automatic migration
- Automatic token refresh (5 minutes before expiration)
- 31-day token persistence with TTL
- Account Scrubbing: Sensitive account identifiers are automatically replaced with display names
- State Security: HMAC-SHA256 signatures for state parameter integrity
- Cookie Encryption: Client approval state encrypted with AES-256
- Secret Redaction: Automatic masking of sensitive data in logs
Development
Available Scripts
Debugging
The server includes comprehensive logging with configurable levels:
- Development: Terminal output with colored logs
- Production: Cloudflare dashboard → Workers → Logs
- Log Levels: DEBUG, INFO, WARN, ERROR (set via LOG_LEVEL env var)
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
- Network Errors (503): Automatic retry with backoff
- 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
- "KV namespace not found" error
- Ensure you created the KV namespace and updated
wrangler.jsonc
- Run
npx wrangler kv:namespace list
to verify
- Ensure you created the KV namespace and updated
- Authentication failures
- Verify your redirect URI matches exactly in Schwab app settings
- Check that all secrets are set correctly with
npx wrangler secret list
- Enable debug logging to see detailed OAuth flow
- "Durable Objects not available" error
- Ensure you have a paid Cloudflare Workers plan
- Durable Objects are not available on the free tier
- Token refresh issues
- The server automatically refreshes tokens 5 minutes before expiration
- Tokens are migrated from clientId to schwabUserId keys automatically
- Check KV namespace for stored tokens:
npx wrangler kv:key list --namespace-id=<your-id>
Recent Updates
- Enhanced Token Management: Centralized KV token store prevents token divergence
- Improved Security: HMAC-SHA256 state validation and automatic secret redaction
- Better Error Handling: Structured error types with Schwab API error mapping
- Configurable Logging: Debug mode for troubleshooting OAuth and API issues
Acknowledgments
- Built with Cloudflare Workers
- Uses Model Context Protocol
- Powered by @sudowealth/schwab-api
This server cannot be installed
A Model Context Protocol server that enables AI assistants like Claude to securely interact with Charles Schwab accounts and market data through the official Schwab API.
Related MCP Servers
- -securityFlicense-qualityA comprehensive suite of Model Context Protocol servers designed to extend AI agent Claude's capabilities with integrations for knowledge management, reasoning, advanced search, news access, and workspace tools.Last updated -5TypeScript
- -securityFlicense-qualityA Model Context Protocol server that allows Claude to make API requests on your behalf, providing tools for testing various APIs including HTTP requests and OpenAI integrations without sharing your API keys in the chat.Last updated -Python
- -securityAlicense-qualityA Model Context Protocol server that enables AI assistants like Claude to interact directly with Home Assistant, allowing them to query device states, control smart home entities, and perform automation tasks.Last updated -15PythonMIT License
- -securityAlicense-qualityA server that implements the Model Context Protocol for Schwab API, allowing access to account information, positions, stock quotes, and order/transaction history designed for integration with Large Language Models.Last updated -2PythonMIT License