Labsco
MCP SERVER

Alpaca MCP Gold Standard

by JOravetz

31 Alpaca trading tools — account, market data, orders, portfolio health scoring, and custom strategy code run in an isolated subprocess.

Trading Execution & Brokerage
Summary
This one places real orders — start on paper.

The market, limit and stop-loss order tools act on whichever Alpaca account the keys belong to, so the paper-trading setting is the first thing to get right. What makes it more than an API wrapper is the layer above: a portfolio health score with specific follow-up actions, correlation matrices that name which positions move together, and a subprocess sandbox for running your own analysis code with your real holdings as context.

What it is

A comprehensive MCP server for Alpaca trading operations, built as a reference implementation of a specific MCP architecture. Alongside the trading tools it carries an analytics layer that classifies your holdings, scores the portfolio, and can execute custom analysis code you supply.

What you get
  • 31 MCP tools, plus 11 resource mirrors that expose the same data as tools for clients that do not support resources, and 4 context prompts
  • Account and portfolio: `get_account_info_tool` for real-time status, `get_positions_tool` for holdings with a suggested role attached to each, `get_open_position_tool` for one symbol, `get_portfolio_summary_tool` for the whole picture
  • Market data — `get_stock_quote_tool` with spread analysis, `get_stock_trade_tool`, `get_stock_snapshot_tool` with volatility, and `get_historical_bars_tool` for OHLCV history
  • Order management: `place_market_order_tool`, `place_limit_order_tool`, `place_stop_loss_order_tool`, `get_orders_tool` for history, `cancel_order_tool`
  • Portfolio analytics that produce a judgement rather than a table — `generate_portfolio_health_assessment_tool` scores diversification, risk concentration and performance balance out of 100 with specific recommendations, and `generate_advanced_market_correlation_analysis_tool` builds 30-day correlation matrices to surface over-correlated positions
  • Custom code execution in a subprocess with a 30-second timeout — `execute_custom_trading_strategy_tool` runs your algorithm with portfolio context, `execute_portfolio_optimization_strategy_tool` optimises against a risk tolerance, `execute_risk_analysis_strategy_tool` computes your own risk metrics, and `execute_custom_analytics_code_tool` works on any structured dataset
  • Entity role classification that labels each position — growth candidate, volatile asset, income generator, hedge instrument or speculative play — with the characteristics behind the label
Requirements

An Alpaca trading account; paper trading is supported and recommended. Two required environment variables, `ALPACA_API_KEY` and `ALPACA_SECRET_KEY`, with `ALPACA_PAPER_TRADE` and `LOG_LEVEL` optional. Python 3.12 or newer and the `uv` package manager: clone, `uv sync`, copy `.env.example` to `.env`, and run `uv run python main.py`. A Dockerfile is included for running it as a container with an env file. Credentials are read from the environment only and never appear in error messages; custom code runs in a subprocess sandbox rather than in the server process.