alpaca-mcp-server
AGENTS.md1k starsChanged 3 months agoMITView on GitHub
This MCP server auto-generates tools from bundled OpenAPI specs (src/alpaca_mcp_server/specs/) using FastMCP's from_openapi(). Tool names, descriptions, and output risk classifications are defined in tool_registry.py. Complex endpoints (orders, historical data) use hand-written overrides in overrides.py and market_data_overrides.py. Toolset filtering is defined in toolsets.py. A trust-boundary middleware (security.py) wraps every tool result in a security envelope to mitigate prompt injection via tool outputs. The test suite has three layers: - tests/test_integrity.py — Spec ↔ toolset ↔ names consistency, plus release version alignment…
- Reads credentials
- Commits and pushes
Trending
More talk lately.thin dataabout the whole repository
Who's talking about alpacahq/alpaca-mcp-server
- A Hacker News story“Alpaca's MCP Server for Trading/Quotes”Hacker News · Jun 6, 2025 · 2 points
- IgorGanapolsky/trading“fix: Use official alpaca-mcp-server instead of community package”GitHub · Dec 2, 2025 · 1 reactions
- seathatflowsinourveins/native-agent-stack“Trading catalog corrections: alpaca-py source pin and mirrors, alpacahq dispositions, IBKR forward note”GitHub · Oct 5, 2026
- odelixhq/odelix-harness“[ODX-HAR-004] Подключить официальный MCP SDK и адаптировать Alpaca allowlist/envelope”GitHub · Sep 28, 2026
- seathatflowsinourveins/native-agent-stack“Alpaca platform landscape 2026-09-26: beyond NautilusTrader and LEAN (two-family research + Tavily Research …”GitHub · Sep 26, 2026
The biggest 5 of 11 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 11
Talked about on GitHub and Hacker News (11 times).
On GitHub · 10
- Dec 2, 2025fix: Use official alpaca-mcp-server instead of community package — IgorGanapolsky/trading1 reaction
- Oct 5, 2026Trading catalog corrections: alpaca-py source pin and mirrors, alpacahq dispositions, IBKR forward note — seathatflowsinourveins/native-agent-stack0 reactions · 3 comments
- Sep 28, 2026[ODX-HAR-004] Подключить официальный MCP SDK и адаптировать Alpaca allowlist/envelope — odelixhq/odelix-harness0 reactions
- Sep 26, 2026Alpaca platform landscape 2026-09-26: beyond NautilusTrader and LEAN (two-family research + Tavily Research pro) — seathatflowsinourveins/native-agent-stack0 reactions · 1 comment
- Sep 25, 2026build(deps): bump alpaca-mcp-server from 2.3.1 to 2.3.2 — maixuancanh/convictionos0 reactions
5 more on GitHub
- Sep 16, 2026Research: discover agentic/programmatic trading platforms that integrate well with the unisona trader — alex-place/lantern-os0 reactions · 1 comment
- Aug 29, 2026feat: connect host-managed Alpaca MCP paper session — Tempest-Research/esscher-market0 reactions
- Jun 6, 2026content(mcp): add Alpaca MCP Server — JSONbored/awesome-claude0 reactions · 3 comments
- Nov 6, 2025Add Alpaca MCP Server — docker/mcp-registry0 reactions
- Sep 18, 2025Alpaca Official MCP Server — chatmcp/mcpso0 reactions
On Hacker News · 1
- Jun 6, 2025Alpaca's MCP Server for Trading/Quotes2 points · 1 comment
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
The file
Show its rules and text
We split this AGENTS.md into the rules it gives an agent
19 rules. About 0 are common, 9 are distinctive, and 10 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈9
Distinctive · estimate
This author's own choices. Worth a look.
10
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 18
When asked to "sync the MCP server" or "update specs", follow this process:
- Distinctive: line 22
Run the sync script:
- Distinctive: line 28
After downloading, the script rewrites the declared OpenAPI version from 3.1.2 to 3.1.1.
- Distinctive: line 47
Action for auto-generated tools: No code changes needed — the spec update is sufficient.
- Very specific: line 54
Changed description/type/enum on an existing parameter: Update the override's docstring to match the new spec description.
- Very specific: line 74
Run the integrity test suite.
- Very specific: line 80
All 8 tests must pass before proceeding.
- Very specific: line 84
If tools were added, removed, or renamed, update the Available Tools section in README.md to match.
- Very specific: line 90
Use the tool name and description from the ToolDefinition entry you added in tool_registry.py.
- Very specific: line 94
If new tools were added (either auto-generated or overrides), add integration test coverage in tests/test_paper_integration.py:
- Very specific: line 96
Follow the existing patterns in the file — each test is an async def test_...
- Distinctive: line 99
If a test requires placing orders or creating resources, clean up after itself (cancel orders, delete watchlists, etc.).
- Distinctive: line 100
Run the full suite locally to verify:
- Very specific: line 110
All tests must pass before proceeding.
- Distinctive: line 114
Write a descriptive commit message listing:
- Distinctive: line 129
Never publish from a feature branch or an ordinary main push.
- Distinctive: line 133
If the release change did not already bump versions, open a dedicated version-bump PR and keep these fields aligned:
- Very specific: line 143
Create a GitHub Release from that main commit using tag vX.Y.Z:
- Very specific: line 164
Do not use local uv publish or twine upload after the automated workflow is live.
≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Agent Instructions
Architecture Overview
This MCP server auto-generates tools from bundled OpenAPI specs (src/alpaca_mcp_server/specs/) using FastMCP's from_openapi(). Tool names, descriptions, and output risk classifications are defined in tool_registry.py. Complex endpoints (orders, historical data) use hand-written overrides in overrides.py and market_data_overrides.py. Toolset filtering is defined in toolsets.py. A trust-boundary middleware (security.py) wraps every tool result in a security envelope to mitigate prompt injection via tool outputs.
The test suite has three layers:
tests/test_integrity.py— Spec ↔ toolset ↔ names consistency, plus release version alignment (no network)tests/test_server_construction.py— Server builds correctly and exposes the expected tool set (no network)tests/test_paper_integration.py— Real API calls against Alpaca paper (needs credentials)
CI is defined in .github/workflows/ci.yml with two jobs: test-core (runs on every PR) and test-integration (runs when ALPACA_API_KEY / ALPACA_SECRET_KEY secrets are available). PyPI publishing is defined in .github/workflows/publish-pypi.yml and runs only when a GitHub Release is published.
Syncing OpenAPI Specs
When asked to "sync the MCP server" or "update specs", follow this process:
Step 1: Download latest specs
Run the sync script:
./scripts/sync-specs.shAfter downloading, the script rewrites the declared OpenAPI version from 3.1.2 to 3.1.1. FastMCP parses specs with openapi-pydantic, which only accepts 3.1.0 and 3.1.1 and rejects anything newer, so without this the server builds zero tools. Expect a one-character difference from the published spec. Remove that line once openapi-pydantic supports 3.1.2.
Step 2: Diff the specs
Check what changed:
git diff src/alpaca_mcp_server/specs/Classify every change into one of three categories:
A. Modified existing endpoints
Parameter or schema changes to endpoints already in the allowlist (toolsets.py).
Action for auto-generated tools: No code changes needed — the spec update is sufficient.
Action for overrides: If the modified endpoint has its operationId in OVERRIDE_OPERATION_IDS (e.g., postOrder), the auto-generator is bypassed and the hand-written override in overrides.py or market_data_overrides.py is used instead. Spec changes do NOT flow through to overrides automatically. For every override whose underlying spec changed, you must:
- Extract the full parameter/property list from the spec's request schema (query params, path params, and request body properties).
- Diff that list against the override function's Python parameter list. For each difference:
- New spec parameter not in the override: Evaluate whether to add it. If it's useful for LLM interactions, add it as an optional parameter, wire it into the request body/query, and document it in the docstring.
- Removed spec parameter still in the override: Flag it — the override is passing a field the API no longer accepts.
- Changed description/type/enum on an existing parameter: Update the override's docstring to match the new spec description.
- Apply the same diff to any other overrides that hit the same underlying API resource (e.g., if
postOrderandpatchOrderByOrderIdboth touch/v2/orders, a field added to one likely applies to the other).
B. New endpoints
Endpoints with operationIds not present in any toolset. Action: Evaluate each:
- Is this endpoint useful for LLM interactions? (e.g., CRUD for a core trading resource = yes; internal/admin endpoints = no)
- If yes: Add the operationId to the appropriate toolset in
toolsets.py. Add aToolDefinitionentry to theTOOLSdict intool_registry.pywith asnake_casename and a curated description (see existing entries for the pattern). Setoutput_risk="external_text"if the endpoint returns arbitrary third-party prose (e.g. news, comments); otherwise leave the default"api_structured". - If the endpoint is complex (many conditional params, multiple use cases in one schema like
POST /v2/orders): Write an override function inoverrides.py, add the operationId toOVERRIDE_OPERATION_IDSintoolsets.py, and do NOT add it to any toolset's operations. - If not useful: Note in the commit message that the endpoint was evaluated and excluded.
C. Removed or renamed endpoints
OperationIds in toolsets.py that no longer exist in the specs.
Action: Flag as a breaking change. Remove the stale operationId from toolsets.py and the corresponding ToolDefinition entry from TOOLS in tool_registry.py.
Step 3: Validate
Run the integrity test suite. It checks that every operationId in toolsets.py exists in the specs, has a ToolDefinition in tool_registry.py, and that all tool names are unique:
python -m pytest tests/test_integrity.py -vAll 8 tests must pass before proceeding. The tests are self-updating — they read toolsets.py, tool_registry.py, the spec JSONs, and the existing release version fields at runtime, so they never need manual changes.
Step 4: Update README.md
If tools were added, removed, or renamed, update the Available Tools section in README.md to match. The section uses <details> blocks grouped by category. Each tool is listed as:
* `tool_name` — Short descriptionUse the tool name and description from the ToolDefinition entry you added in tool_registry.py. Place the tool in the correct category block (Account & Portfolio, Trading, Positions, etc.). If a new toolset was created, add a new <details> block for it.
Step 5: Extend Tests
If new tools were added (either auto-generated or overrides), add integration test coverage in tests/test_paper_integration.py:
- Follow the existing patterns in the file — each test is an
async def test_...function marked with@pytest.mark.integration. - Tests call tools via
server.call_tool(tool_name, arguments)and parse results with the_to_dict/_parsehelpers at the top of the file. - Assert the response contains expected keys or structure. Keep assertions loose enough to tolerate live data variability (e.g., check a key exists rather than asserting an exact value).
- If a test requires placing orders or creating resources, clean up after itself (cancel orders, delete watchlists, etc.).
- Run the full suite locally to verify:
# Core tests (fast, no credentials)
pytest tests/test_integrity.py tests/test_server_construction.py -v
# Integration tests (requires paper API keys)
ALPACA_API_KEY=... ALPACA_SECRET_KEY=... pytest tests/ -m integration -vAll tests must pass before proceeding. The CI pipeline (.github/workflows/ci.yml) runs core tests on every PR and integration tests when secrets are available.
Step 6: Commit
Write a descriptive commit message listing:
- What changed in the API specs
- Which new endpoints were added to toolsets (and which toolset)
- Which new endpoints were excluded (and why)
- Any breaking changes (removed/renamed endpoints)
- Whether README was updated
- Whether new tests were added
Releasing to PyPI
Publishing is a human release decision. Agents may prepare a version-bump PR and the release command, but must not silently create a production GitHub Release.
Never publish from a feature branch or an ordinary main push. Never upload a
version that already exists on PyPI. Never try to delete and reuse a bad
version.
- If the release change did not already bump versions, open a dedicated
version-bump PR and keep these fields aligned:
pyproject.tomlproject.versionsrc/alpaca_mcp_server/__init__.py__version__server.jsonversionandpackages[0].versionserver.yamlmetadata.version.well-known/mcp/manifest.jsonversioncharts/alpaca-mcp-server/Chart.yamlappVersion(leave chartversion: 0.1.0unless the chart itself changed)uv.lockeditablealpaca-mcp-serverpackage
- Confirm CI on
mainis green after the version PR merges. - Create a GitHub Release from that
maincommit using tagvX.Y.Z:
VERSION=$(python -c 'import re, pathlib; print(re.search(r"^version = \"([^\"]+)\"", pathlib.Path("pyproject.toml").read_text(), re.M).group(1))')
gh release create "v$VERSION" --target main --generate-notes- Watch the Publish Python package Action. The workflow is triggered by the published Release, not by tag push alone.
- Verify:
uvx alpaca-mcp-server=="$VERSION" --versionRecovery:
- A failure before upload may be rerun from GitHub Actions. No new version is required.
- A bad published release must be yanked on PyPI and replaced by a new patch version. Do not overwrite or reuse the same version.
- Do not use local
uv publishortwine uploadafter the automated workflow is live.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

