施瓦布模型上下文协议服务器
这是一个使用schwab-py和 MCP python-sdk为 Schwab API 实现模型上下文协议 (MCP) 的服务器。
特征
- 通过模型上下文协议公开 Schwab API 功能
- 获取账户信息和仓位
- 检索股票报价和价格历史记录
- 获取市场信息和推动者
- 获取期权链和到期数据
- 访问订单和交易历史记录
- 使用特殊工具修改帐户状态(需要
--jesus-take-the-wheel
标志) - 设计用于与大型语言模型 (LLM) 集成
安装
用法
验证
第一步是使用 Schwab API 进行身份验证并生成令牌:
您可以通过环境变量设置这些凭据,以避免每次都输入它们:
SCHWAB_CLIENT_ID
SCHWAB_CLIENT_SECRET
SCHWAB_CALLBACK_URL
(默认为https://127.0.0.1:8182 )
默认情况下,令牌保存在~/.local/share/schwab-mcp/token.yaml
(平台相关)。您可以指定其他路径:
支持 yaml 和 json 令牌格式,并将从文件扩展名推断出来。
运行服务器
验证后即可运行服务器:
令牌年龄已验证 - 如果超过 5 天,系统将提示您重新进行身份验证。
警告:使用
--jesus-take-the-wheel
标志会启用可修改您账户状态的工具。请谨慎使用,因为这允许 LLM 取消订单并可能执行其他更改账户状态的操作。
可用工具
该服务器公开以下 MCP 工具:
日期和市场信息
get_datetime
- 获取 ISO 格式的当前日期时间get_market_hours
- 获取特定市场的市场时间get_movers
- 获取特定索引的推动者get_instruments
- 搜索具有特定符号的工具
帐户信息
get_account_numbers
- 获取帐户 ID 到帐户哈希值的映射get_accounts
- 获取所有关联的 Schwab 账户的信息get_accounts_with_positions
- 获取账户的持仓信息get_account
获取特定帐户的信息get_account_with_positions
- 获取特定账户的持仓信息get_user_preferences
- 获取所有帐户的用户偏好设置,包括昵称
订单
get_order
获取特定订单的详细信息get_orders
- 获取特定账户的订单
引号
get_quotes
- 获取指定符号的报价
价格历史
get_advanced_price_history
- 获取特定符号的高级价格历史记录get_price_history_every_minute
- 以分钟频率获取价格历史记录get_price_history_every_five_minutes
- 以五分钟的频率获取价格历史记录get_price_history_every_ten_minutes
- 获取十分钟频率的价格历史记录get_price_history_every_fifteen_minutes
- 获取每十五分钟一次的价格历史记录get_price_history_every_thirty_minutes
- 获取频率为三十分钟的价格历史记录get_price_history_every_day
- 获取每日频率的价格历史记录get_price_history_every_week
- 获取每周价格历史记录
选项
get_option_chain
- 获取特定符号的期权链get_advanced_option_chain
- 获取特定符号的高级期权链get_option_expiration_chain
- 获取符号的期权到期信息
交易
get_transactions
- 获取特定账户的交易get_transaction
获取特定交易的详细信息
帐户修改工具(需要--jesus-take-the-wheel
标志)
cancel_order
- 取消特定订单
安全警告
--jesus-take-the-wheel
标志使 LLM 能够执行可修改您的帐户状态的操作,包括:
- 取消订单
- 其他可能产生财务影响的行动(未来版本中将添加更多工具)
仅在受控环境中使用此标志并了解所涉及的风险。
发展
执照
该项目可在 MIT 许可下使用。
This server cannot be installed
hybrid server
The server is able to function both locally and remotely, depending on the configuration or use case.
为 Schwab API 实现模型上下文协议的服务器,允许访问专为与大型语言模型集成而设计的帐户信息、头寸、股票报价和订单/交易历史记录。
Related MCP Servers
- -securityAlicense-qualityA Model Context Protocol server that enables interaction with the Tradovate API for managing trading contracts, positions, orders, and accounts.Last updated -JavaScriptMIT License
- -securityAlicense-qualityA Model Context Protocol server that enables LLMs like Claude to interact with the Alpaca trading API, allowing for trading stocks, checking positions, fetching market data, and managing accounts through natural language.Last updated -PythonMIT License
MCP TapData Serverofficial
-securityFlicense-qualityA Model Context Protocol server that enables Large Language Models to access and interact with database connections, including viewing schemas and performing CRUD operations on connected databases.Last updated -Paddle MCP Serverofficial
AsecurityAlicenseAqualityA Model Context Protocol server that provides tools for interacting with the Paddle Billing API, enabling users to manage products, prices, customers, transactions, subscriptions, and create custom financial reports.Last updated -84319TypeScriptApache 2.0