Skip to main content

Public.com MCP Server

License Python MCP

An MCP (Model Context Protocol) server that connects AI assistants to your Public.com brokerage account. Trade stocks, options, and crypto — get quotes, manage orders, and view your portfolio — all through natural language.

Disclaimer: For illustrative and informational purposes only. Not investment advice or recommendations. Use at your own risk.

Tools

Read-Only

Tool Description
check_setup Verify API credentials and connectivity
get_accounts List all brokerage accounts
get_portfolio View positions, equity, buying power, open orders
get_orders List active/open orders (bracket legs share a bracketId)
get_order Status and details of a specific order, including its fills (trades, filledAt, replacedAt, lastModified); last 30 days
search_orders Search order history — any status, last 30 days, up to 500 orders, filtered by status/side/symbols/type/time
get_history Transaction history (trades, deposits, dividends, etc.)
get_quotes Real-time quotes for stocks, crypto, options, event contracts
get_price_history OHLCV price history for equities, crypto, options, indices, or event contracts
get_instrument Details about a specific tradeable instrument
get_all_instruments List all available instruments with filters
search_bonds Filtered, paged search for fixed income instruments
get_bond_details Pricing, ratings, coupon and maturity info for a bond
get_option_expirations Available expiration dates for options
get_option_chain Full option chain (calls + puts) for a symbol
get_option_greeks Greeks (delta, gamma, theta, vega, rho, IV) for multiple options
get_option_greek Greeks for a single option symbol
get_tax_lots Unrealized tax-lot summary (per-lot gain/loss, term, cost basis)
get_tax_lots_for_symbol Unrealized tax-lot detail for a single symbol
get_tax_lots_csv Export unrealized tax lots as a Base64-encoded CSV file
get_strategy_quote Consolidated quote for a multi-leg option strategy
get_event_categories Event-contract (prediction market) categories, subcategories and frequency filters
get_event_summary Browse event contracts by category / symbol / frequency / resolution time, 100 per page
get_event_details One event's outcomes, YES/NO contract prices, timeline and CFTC terms
get_event_contract_bars Price-history bars for up to 8 contracts of one event
preflight_order Estimate costs/impact before placing a single-leg order
preflight_multileg_order Estimate costs for multi-leg options strategies
preflight_short_order Estimate costs before placing a short-sale order
preflight_call_credit_spread Estimate costs for a Bear Call Spread
preflight_call_debit_spread Estimate costs for a Bull Call Spread
preflight_put_credit_spread Estimate costs for a Bull Put Spread
preflight_put_debit_spread Estimate costs for a Bear Put Spread

Write (Destructive)

Tool Description
place_order Place a single-leg order (stocks, crypto, options); optionally a bracket order via order_class + exit-leg prices, or target specific tax lots via tax_lot_matching_instructions
place_multileg_order Place multi-leg orders (spreads, straddles, etc.)
place_call_credit_spread Place a Bear Call Spread
place_call_debit_spread Place a Bull Call Spread
place_put_credit_spread Place a Bull Put Spread
place_put_debit_spread Place a Bear Put Spread
place_short_order Place an equity short-sale order
flatten_and_go_short Sell an existing long position then go short (experimental)
cancel_order Cancel an existing order
cancel_and_replace_order Atomically cancel and replace an order

Bracket orders

place_order places a bracket by setting order_class to BRACKET, OCO or OTO and supplying at least one exit leg:

Argument Meaning
order_class SIMPLE (default, standalone) or BRACKET / OCO / OTO
take_profit_limit_price Limit price of the take-profit leg
stop_loss_stop_price Stop price of the stop-loss leg
stop_loss_limit_price Optional — makes the stop-loss a STOP_LIMIT rather than a STOP

The exit legs are submitted automatically when the entry order fills, and every leg of the bracket — the entry included — reports the entry's order ID as its bracketId, so get_orders groups them.

The API accepts brackets for EQUITY and OPTION only; they need a whole-share quantity (not amount), must use the CORE market session, and the entry order_type must be LIMIT or MARKET (LIMIT only for OCO). preflight_order validates the entry order only — it has no view of the exit legs.

Order history

get_orders lists only the open/active orders in the portfolio snapshot. For everything else use the order-history tools:

Tool Returns
search_orders Orders in any status (filled, cancelled, rejected, …) matching optional status, side, symbols ("SYMBOL" or "SYMBOL:TYPE"), security_type, open_close_indicator, created_after / created_before filters
get_order One order by ID in the same shape

Both are limited by the API to orders created within the last 30 days, and search_orders returns at most 500 orders. Each order includes trades (the individual fills), filledAt, replacedAt, lastModified and equityMarketSession. Note that equityMarketSession uses REGULAR / REST_OF_DAY / TWENTY_FOUR_HOURS, which is not the CORE / EXTENDED / TWENTY_FOUR_HOURS vocabulary that place_order's equity_market_session argument takes.

Event contracts

Event contracts (prediction markets) are read-only here. Browse with get_event_categories → get_event_summary (page with next_token) → get_event_details, and chart with get_event_contract_bars. Prices are dollars from 0.00 to 1.00 and equal the implied probability.

The two halves take different identifiers, and the API rejects the wrong one:

Tools Event identifier Contract symbol
get_event_summary, get_event_details eventSymbol, e.g. KALSHI.KXBALANCESHEET-EO26 e.g. KALSHI.KXBALANCESHEET-EO26-6.6.Y
get_event_contract_bars -EVENT id, e.g. KALSHI.KXBALANCESHEET-EO26-EVENT -EVENTCONTRACT symbol, e.g. KALSHI.KXBALANCESHEET-EO26-6.6.Y-EVENTCONTRACT

EVENTCONTRACT is also accepted as an instrument type by get_quotes, get_price_history, get_instrument, get_all_instruments and search_orders.

Prerequisites

Installation

pip install publicdotcom-mcp-server

Or install from source:

git clone https://github.com/publicdotcom/publicdotcom-mcp-server.git
cd publicdotcom-mcp-server
pip install .

Configuration

Set your API credentials as environment variables:

# Required
export PUBLIC_COM_SECRET=your_api_secret_key

# Optional — sets a default account so you don't need to specify it each time
export PUBLIC_COM_ACCOUNT_ID=your_account_id

Usage

Claude Desktop

Add this to your Claude Desktop config (~/Library/Application Support/Claude/claude_desktop_config.json on macOS):

{
  "mcpServers": {
    "public-com": {
      "command": "publicdotcom-mcp-server",
      "env": {
        "PUBLIC_COM_SECRET": "your_api_secret_key",
        "PUBLIC_COM_ACCOUNT_ID": "your_account_id"
      }
    }
  }
}

Claude Desktop (using uvx)

If you prefer using uvx (no pre-install needed):

{
  "mcpServers": {
    "public-com": {
      "command": "uvx",
      "args": ["publicdotcom-mcp-server"],
      "env": {
        "PUBLIC_COM_SECRET": "your_api_secret_key",
        "PUBLIC_COM_ACCOUNT_ID": "your_account_id"
      }
    }
  }
}

Running Directly

# stdio transport (default — for Claude Desktop, Claude Code, etc.)
publicdotcom-mcp-server

# Or run as a Python module
python -m publicdotcom_mcp_server

Hosted / Remote Deployment

For remote deployments (behind a reverse proxy or load balancer), switch to the streamable-HTTP transport:

export MCP_TRANSPORT=streamable-http
export PUBLIC_COM_SECRET=your_api_secret_key
export PORT=8000  # optional, defaults to 8000
export HOST=0.0.0.0  # optional, defaults to 0.0.0.0
publicdotcom-mcp-server

In this mode the server listens for MCP requests at POST /mcp. Clients authenticate per-request via an Authorization: Bearer <key> header, which takes priority over the PUBLIC_COM_SECRET environment variable — useful for multi-tenant deployments.

Testing with MCP Inspector

npx @modelcontextprotocol/inspector publicdotcom-mcp-server

Development

# Clone and install in development mode
git clone https://github.com/publicdotcom/publicdotcom-mcp-server.git
cd publicdotcom-mcp-server
pip install -e ".[dev]"

# Run tests
pytest

# Run the server locally
python -m publicdotcom_mcp_server

CI & Releases

  • CI (.github/workflows/ci.yml) runs the test suite (Python 3.10–3.13) and ruff on every push to main and every pull request.
  • Releases (.github/workflows/release.yml) run on every push to main. When the version in pyproject.toml is one that hasn't been released yet (no matching v<version> tag), the workflow builds the package, publishes to PyPI via Trusted Publishing (OIDC) — no API token is stored — and creates the corresponding GitHub Release. Merges that don't change the version are no-ops.

To cut a release: bump version in pyproject.toml in your PR and merge it to main. The release + PyPI publish + v<version> tag/GitHub Release happen automatically. One-time setup on PyPI (project → Publishing) must register a Trusted Publisher for this repo with workflow release.yml and environment pypi.

How It Works

This server wraps the publicdotcom-py Python SDK, exposing each API operation as an MCP tool. The MCP protocol allows AI clients to discover and call these tools through a standardized interface.

AI Client (Claude, etc.)
    ↕ MCP Protocol (stdio)
Public.com MCP Server
    ↕ HTTPS
Public.com Trading API

All tools include proper MCP tool annotations:

  • Read-only tools are marked with readOnlyHint: true
  • Order-placement tools are marked with readOnlyHint: false (they modify account state)
  • Order cancellation tools (cancel_order, cancel_and_replace_order) are additionally marked with destructiveHint: true

License

Apache 2.0

Metadata

Release files for publicdotcom-mcp-server 0.8.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for publicdotcom-mcp-server 0.8.0
File Size Uploaded
publicdotcom_mcp_server-0.8.0.tar.gz 53.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for publicdotcom-mcp-server 0.8.0
File Interpreter ABI Platform
publicdotcom_mcp_server-0.8.0-py3-none-any.whl Python 3 none any Details

Total release size: 85.6 kB

Release files / publicdotcom_mcp_server-0.8.0.tar.gz

Download URL publicdotcom_mcp_server-0.8.0.tar.gz
Size 53.6 kB
Tags Source
SHA-256 checksum
How to use checksums
3dc1f18d9093b8ea8bfd37493ebf33c69f3f3a4137e1e42de548d3905f322d6a
BLAKE2b-256 checksum
How to use checksums
8126cb0cf2ee0e24dfd8b2c64be57ebb58f620af068b57fe7d22920e373f7cba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 9, 2026.

Transparency log

Release files / publicdotcom_mcp_server-0.8.0-py3-none-any.whl

Download URL publicdotcom_mcp_server-0.8.0-py3-none-any.whl
Size 32.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a93a3b9be0b5c83c385019406db4385405ee4239e70feeb7bd3e0bb370b52bd9
BLAKE2b-256 checksum
How to use checksums
ec959820916f859fa56b4b987576662289b445ea8d1509fed4d1e98aec2198dd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 9, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.8.0 This release

2 release files

0.7.0

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page