Schwab MCP Server
A read-only Model Context Protocol (MCP) server for Charles Schwab API. Access your Schwab account data and market information through AI assistants like Claude, ChatGPT, and more.
Features
Portfolio Analysis - View positions with cost basis, quantity, and market value
Real-time Quotes - Get current prices for stocks and ETFs
Options Data - Access options chains with Greeks
Price History - Historical OHLCV data for technical analysis
Account Info - View account balances and details
Security Note: This server is strictly READ-ONLY. No trading or account modification functionality is implemented.
Prerequisites
Python 3.10 or higher
A Charles Schwab Developer account with:
App Key (Client ID)
App Secret (Client Secret)
A valid Refresh Token
Callback URL configured
Installation
Clone the repository:
Create and activate a virtual environment:
Install the package:
Configuration
Environment Variables
Create a .env file in the project root:
Initial Token Setup
Create the token file at the path specified in SCHWAB_TOKEN_PATH (default: ~/.schwab-mcp/token.json):
Setting expires_at to 0 forces an automatic token refresh on first use.
The MCP server will load client_id and client_secret directly from this token file. Environment variables with the same names can override these values if needed.
Client Setup
Claude Desktop
Windows (Automated)
Run the PowerShell script to automatically configure Claude Desktop:
The script will:
Stop Claude Desktop (prompts for confirmation)
Clear MCP-related cache files
Update the config with correct paths to the venv Python and src directory
Restart Claude Desktop
Options:
-RepoPath- Path to this repo (default: auto-detected)-SkipRestart- Update config without restarting Claude-ServerName- MCP server name in config (default:schwab)
Manual Configuration
macOS: Edit ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: Edit %APPDATA%\Claude\claude_desktop_config.json
Add the following configuration:
Restart Claude Desktop after saving the configuration.
ChatGPT Desktop
ChatGPT Desktop supports MCP servers through its settings. To configure:
Open ChatGPT Desktop
Go to Settings > Features > MCP Servers
Click Add Server and enter:
Name:
schwabCommand:
pythonArguments:
-m schwab_mcp.serverWorking Directory:
/path/to/schwab-mcp-server
Add environment variables (client id/secret are read from the token file):
SCHWAB_CALLBACK_URL: https://127.0.0.1:8182/callbackSCHWAB_TOKEN_PATH: /path/to/.schwab-mcp/token.json
Save and restart ChatGPT Desktop
File-based setup (auto-detected by ChatGPT Desktop):
macOS: create
~/Library/Application Support/ChatGPT/.well-known/mcp.jsonWindows: create
%APPDATA%\ChatGPT\.well-known\mcp.json
Copy chatgpt_desktop_config.example.json to that location and update the paths to match your environment (Python executable, repo path, and token path). Restart ChatGPT Desktop after saving.
Claude Code (CLI)
Add the MCP server to your Claude Code configuration. Create or edit ~/.claude/claude_code_config.json:
Alternatively, you can add it to your project's .claude/settings.json for project-specific configuration:
OpenAI Codex
For Codex CLI, configure the MCP server in your environment:
Set up environment variables in your shell profile (
.bashrc,.zshrc, etc.):
Configure Codex to use the MCP server by adding to your Codex configuration:
Available Tools
Tool | Description |
| Get account information including type and balances |
| Get all positions with cost basis and market value |
| Get real-time quote for a single symbol |
| Get real-time quotes for multiple symbols |
| Get options chain with Greeks for a symbol |
| Get historical OHLCV price data |
Usage Examples
Once configured, you can ask your AI assistant questions like:
"What are my current positions and their cost basis?"
"Get me a quote for AAPL"
"Show me the options chain for MSFT expiring in January"
"What's the price history for NVDA over the last 6 months?"
"What are my account balances?"
Testing
Using MCP Inspector
Test the server locally using the MCP Inspector:
Manual Test
Verify authentication is working:
Troubleshooting
Token Refresh Fails
Ensure your refresh token is valid and not expired (7-day expiration)
Verify your client ID and secret are correct
Check that your Schwab Developer app is approved and active
Server Won't Start
Verify Python 3.10+ is installed:
python --versionEnsure all dependencies are installed:
pip install -e .Check that the
.envfile exists and has correct values
No Data Returned
Confirm your Schwab account has the appropriate permissions
Check if markets are open (some data limited outside trading hours)
Review logs for API error messages
Security
Read-only access only - No trading or account modification capabilities
Token storage - Tokens are stored locally with restricted file permissions (600)
No credential logging - Sensitive data is never written to logs
Environment variables - Credentials should be passed via environment, not hardcoded
References
License
MIT - Use at your own risk. Not affiliated with Charles Schwab.