A Model Context Protocol server implementing popular broker api's
- Currently only TradeStation API is supported (partially)
The server implements five tools that are based on TradeStation API:
- tradestation_get_bars - wraps the output of TradeStation GetBars in a dataframe and returns it's
__str__
- tradestation_place_buy_order - Same as TradeStation PlaceOrder but only for buy orders
- tradestation_place_sell_order - Same as TradeStation PlaceOrder but only for sell orders
- tradestation_get_positions - Same as TradeStation GetPositions
- tradestation_get_balances - Same as TradeStation GetBalances
see the exact schemas in the definition file here
The server is configured via environment variables:
TRADESTATION_API_KEY="your_api_key"
TRADESTATION_API_SECRET="your_api_secret"
TS_REFRESH_TOKEN="your_refresh_token"
TS_ACCOUNT_ID="your_account_id"
If you are unsure about how to get the values of the environment variables, I have a blog post that explains it here
On MacOS: ~/Library/Application\ Support/Claude/claude_desktop_config.json
On Windows: %APPDATA%/Claude/claude_desktop_config.json
"mcpServers": {
"portfolio_service": {
"command": "uv",
"args": [
"--directory",
"<path_to_project>/portfolio_service",
"run",
"portfolio_service"
]
}
}
- Sync dependencies and update lockfile:
uv sync
Since MCP servers run over stdio, debugging can be challenging. For the best debugging experience, we strongly recommend using the MCP Inspector.
You can launch the MCP Inspector via npm
with this command:
npx @modelcontextprotocol/inspector uv --directory <path_to_project>/portfolio_service run portfolio-service
Upon launching, the Inspector will display a URL that you can access in your browser to begin debugging.