嘉信理财MCP集成
STDIO施瓦布API账户管理和市场数据访问服务
施瓦布API账户管理和市场数据访问服务
This is a server that implements the Model Context Protocol (MCP) for the Schwab API using schwab-py and the MCP python-sdk.
--jesus-take-the-wheel
flag)# Install with all dependencies uv add -e . # Install development dependencies uv add -e .[dev]
The first step is to authenticate with the Schwab API and generate a token:
# Authenticate and generate a token uv run schwab-mcp auth --client-id YOUR_CLIENT_ID --client-secret YOUR_CLIENT_SECRET --callback-url YOUR_CALLBACK_URL
You can set these credentials through environment variables to avoid typing them each time:
SCHWAB_CLIENT_ID
SCHWAB_CLIENT_SECRET
SCHWAB_CALLBACK_URL
(defaults to https://127.0.0.1:8182)By default, the token is saved to ~/.local/share/schwab-mcp/token.yaml
(platform-specific). You can specify a different path:
uv run schwab-mcp auth --token-path /path/to/token.yaml
Both yaml and json token formats are supported and will be inferred from the file extension.
After authentication, you can run the server:
# Run the server with default token path uv run schwab-mcp server --client-id YOUR_CLIENT_ID --client-secret YOUR_CLIENT_SECRET --callback-url YOUR_CALLBACK_URL # Run with a custom token path uv run schwab-mcp server --token-path /path/to/token.json --client-id YOUR_CLIENT_ID --client-secret YOUR_CLIENT_SECRET --callback-url YOUR_CALLBACK_URL # Run with account modification tools enabled uv run schwab-mcp server --jesus-take-the-wheel --client-id YOUR_CLIENT_ID --client-secret YOUR_CLIENT_SECRET --callback-url YOUR_CALLBACK_URL
Token age is validated - if older than 5 days, you will be prompted to re-authenticate.
WARNING: Using the
--jesus-take-the-wheel
flag enables tools that can modify your account state. Use with caution as this allows LLMs to cancel orders and potentially perform other actions that change account state.
The server exposes the following MCP tools:
get_datetime
- Get the current datetime in ISO formatget_market_hours
- Get market hours for a specific marketget_movers
- Get movers for a specific indexget_instruments
- Search for instruments with a specific symbolget_account_numbers
- Get mapping of account IDs to account hashesget_accounts
- Get information for all linked Schwab accountsget_accounts_with_positions
- Get accounts with position informationget_account
- Get information for a specific accountget_account_with_positions
- Get specific account with position informationget_user_preferences
- Get user preferences for all accounts including nicknamesget_order
- Get details for a specific orderget_orders
- Get orders for a specific accountget_quotes
- Get quotes for specified symbolsget_advanced_price_history
- Get advanced price history for a specific symbolget_price_history_every_minute
- Get price history with minute frequencyget_price_history_every_five_minutes
- Get price history with five minute frequencyget_price_history_every_ten_minutes
- Get price history with ten minute frequencyget_price_history_every_fifteen_minutes
- Get price history with fifteen minute frequencyget_price_history_every_thirty_minutes
- Get price history with thirty minute frequencyget_price_history_every_day
- Get price history with daily frequencyget_price_history_every_week
- Get price history with weekly frequencyget_option_chain
- Get option chain for a specific symbolget_advanced_option_chain
- Get advanced option chain for a specific symbolget_option_expiration_chain
- Get option expiration information for a symbolget_transactions
- Get transactions for a specific accountget_transaction
- Get details for a specific transaction--jesus-take-the-wheel
flag)cancel_order
- Cancel a specific orderThe --jesus-take-the-wheel
flag enables LLMs to perform actions that can modify your account state, including:
Only use this flag in controlled environments and understand the risks involved.
# Type check uv run pyright # Format code uv run ruff format . # Lint uv run ruff check . # Run tests uv run pytest
This project is available under the MIT License.