Skip to main content

Schwab Model Context Protocol (MCP) for the Schwab API

Project description

Schwab Model Context Protocol Server

This is a server that implements the Model Context Protocol (MCP) for the Schwab API using schwab-py and the MCP python-sdk.

Features

  • Expose Schwab API functionality through Model Context Protocol
  • Get account information and positions
  • Retrieve stock quotes and price history
  • Get market information and movers
  • Fetch option chains and expiration data
  • Access order and transaction history
  • Modify account state with special tools (requires --jesus-take-the-wheel flag)
  • Designed to integrate with Large Language Models (LLMs)

Installation

# Install with all dependencies
uv add -e .

# Install development dependencies
uv add -e .[dev]

Usage

Authentication

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:

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.

Running the Server

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.

Available Tools

The server exposes the following MCP tools:

Date and Market Information

  1. get_datetime - Get the current datetime in ISO format
  2. get_market_hours - Get market hours for a specific market
  3. get_movers - Get movers for a specific index
  4. get_instruments - Search for instruments with a specific symbol

Account Information

  1. get_account_numbers - Get mapping of account IDs to account hashes
  2. get_accounts - Get information for all linked Schwab accounts
  3. get_accounts_with_positions - Get accounts with position information
  4. get_account - Get information for a specific account
  5. get_account_with_positions - Get specific account with position information
  6. get_user_preferences - Get user preferences for all accounts including nicknames

Orders

  1. get_order - Get details for a specific order
  2. get_orders - Get orders for a specific account

Quotes

  1. get_quotes - Get quotes for specified symbols

Price History

  1. get_advanced_price_history - Get advanced price history for a specific symbol
  2. get_price_history_every_minute - Get price history with minute frequency
  3. get_price_history_every_five_minutes - Get price history with five minute frequency
  4. get_price_history_every_ten_minutes - Get price history with ten minute frequency
  5. get_price_history_every_fifteen_minutes - Get price history with fifteen minute frequency
  6. get_price_history_every_thirty_minutes - Get price history with thirty minute frequency
  7. get_price_history_every_day - Get price history with daily frequency
  8. get_price_history_every_week - Get price history with weekly frequency

Options

  1. get_option_chain - Get option chain for a specific symbol
  2. get_advanced_option_chain - Get advanced option chain for a specific symbol
  3. get_option_expiration_chain - Get option expiration information for a symbol

Transactions

  1. get_transactions - Get transactions for a specific account
  2. get_transaction - Get details for a specific transaction

Account Modification Tools (Requires --jesus-take-the-wheel flag)

  1. cancel_order - Cancel a specific order

Security Warning

The --jesus-take-the-wheel flag enables LLMs to perform actions that can modify your account state, including:

  • Canceling orders
  • Other actions that may have financial implications (more tools to be added in future releases)

Only use this flag in controlled environments and understand the risks involved.

Development

# Type check
uv run pyright

# Format code
uv run ruff format .

# Lint
uv run ruff check .

# Run tests
uv run pytest

License

This project is available under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mseep_schwab_mcp-0.1.1.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mseep_schwab_mcp-0.1.1-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file mseep_schwab_mcp-0.1.1.tar.gz.

File metadata

  • Download URL: mseep_schwab_mcp-0.1.1.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.12

File hashes

Hashes for mseep_schwab_mcp-0.1.1.tar.gz
Algorithm Hash digest
SHA256 d607a892e3bcb8a1ad405f130c133851d389df481273111f199f8f36be3304fd
MD5 afaa71128ff1902190bc8bd86f956ee8
BLAKE2b-256 fd3c29ca7c96885997a73e5302a2541f1e4438faba793e201f9eb51ddcbef005

See more details on using hashes here.

File details

Details for the file mseep_schwab_mcp-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for mseep_schwab_mcp-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4ed6455af4734ed985836c6b7e4d3857e7af4ee53c40bedc20d597013637b019
MD5 7e748f34cb8101680b8062435d55da70
BLAKE2b-256 12b8b4b67de49d8ca527ad7c21c4436bf13e4cab71cad31b0db9e39ed575581e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page