MCP ExplorerExplorer

Brokers Mcp

@Frederick-G764on 3 days ago
0 MIT
FreeCommunity
AI Systems
A MCP (Model Context Protocol) server that implements popular brokers' APIs and more

Overview

What is Brokers Mcp

The portfolio_service is a Model Context Protocol (MCP) server that implements various broker APIs to facilitate trading operations. Currently, it partially supports the TradeStation API, allowing users to interact with market data, execute orders, and manage account information.

Use cases

This server is ideal for developers and traders who want to automate their trading strategies using the TradeStation platform. It can be used for fetching historical market data, placing buy and sell orders, and retrieving current positions and balances. The integration streamlines trading operations via API calls.

How to use

To use the portfolio_service, users must first configure their environment with necessary TradeStation API credentials via specified environment variables. They can then install the server, configure it in the Claude Desktop application, and utilize provided commands for executing trading functions and retrieving data.

Key features

Key features include five primary tools for trading: getting bars data, placing buy and sell orders, fetching current positions, and retrieving account balances. The server aims to encapsulate the functionality of the TradeStation API, enhancing user experience with a dataframe output for market data.

Where to use

The server is designed for use in trading environments where the TradeStation brokerage platform is utilized. It can be deployed in local development environments or integrated into larger financial applications seeking to leverage automated trading via the MCP setup.

Content

portfolio_service MCP server

A Model Context Protocol server implementing popular broker api’s

Supported APIs

  • Currently only TradeStation API is supported (partially)

Components

Tools

The server implements five tools that are based on TradeStation API:

  1. tradestation_get_bars - wraps the output of TradeStation GetBars in a dataframe and returns it’s __str__
  2. tradestation_place_buy_order - Same as TradeStation PlaceOrder but only for buy orders
  3. tradestation_place_sell_order - Same as TradeStation PlaceOrder but only for sell orders
  4. tradestation_get_positions - Same as TradeStation GetPositions
  5. tradestation_get_balances - Same as TradeStation GetBalances

see the exact schemas in the definition file here

Configuration

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

Quickstart

Install

Claude Desktop

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"
    ]
  }
}

Development

Building and Publishing

  1. Sync dependencies and update lockfile:
uv sync

Debugging

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.

Tools

No tools

Comments