[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-alpacahq--alpaca-mcp-server":3,"tool-alpacahq--alpaca-mcp-server":64},[4,23,32,40,48,56],{"id":5,"name":6,"github_repo":7,"description_zh":8,"stars":9,"difficulty_score":10,"last_commit_at":11,"category_tags":12,"status":22},2268,"ML-For-Beginners","microsoft\u002FML-For-Beginners","ML-For-Beginners 是由微软推出的一套系统化机器学习入门课程，旨在帮助零基础用户轻松掌握经典机器学习知识。这套课程将学习路径规划为 12 周，包含 26 节精炼课程和 52 道配套测验，内容涵盖从基础概念到实际应用的完整流程，有效解决了初学者面对庞大知识体系时无从下手、缺乏结构化指导的痛点。\n\n无论是希望转型的开发者、需要补充算法背景的研究人员，还是对人工智能充满好奇的普通爱好者，都能从中受益。课程不仅提供了清晰的理论讲解，还强调动手实践，让用户在循序渐进中建立扎实的技能基础。其独特的亮点在于强大的多语言支持，通过自动化机制提供了包括简体中文在内的 50 多种语言版本，极大地降低了全球不同背景用户的学习门槛。此外，项目采用开源协作模式，社区活跃且内容持续更新，确保学习者能获取前沿且准确的技术资讯。如果你正寻找一条清晰、友好且专业的机器学习入门之路，ML-For-Beginners 将是理想的起点。",84991,2,"2026-04-05T10:45:23",[13,14,15,16,17,18,19,20,21],"图像","数据工具","视频","插件","Agent","其他","语言模型","开发框架","音频","ready",{"id":24,"name":25,"github_repo":26,"description_zh":27,"stars":28,"difficulty_score":29,"last_commit_at":30,"category_tags":31,"status":22},2181,"OpenHands","OpenHands\u002FOpenHands","OpenHands 是一个专注于 AI 驱动开发的开源平台，旨在让智能体（Agent）像人类开发者一样理解、编写和调试代码。它解决了传统编程中重复性劳动多、环境配置复杂以及人机协作效率低等痛点，通过自动化流程显著提升开发速度。\n\n无论是希望提升编码效率的软件工程师、探索智能体技术的研究人员，还是需要快速原型验证的技术团队，都能从中受益。OpenHands 提供了灵活多样的使用方式：既可以通过命令行（CLI）或本地图形界面在个人电脑上轻松上手，体验类似 Devin 的流畅交互；也能利用其强大的 Python SDK 自定义智能体逻辑，甚至在云端大规模部署上千个智能体并行工作。\n\n其核心技术亮点在于模块化的软件智能体 SDK，这不仅构成了平台的引擎，还支持高度可组合的开发模式。此外，OpenHands 在 SWE-bench 基准测试中取得了 77.6% 的优异成绩，证明了其解决真实世界软件工程问题的能力。平台还具备完善的企业级功能，支持与 Slack、Jira 等工具集成，并提供细粒度的权限管理，适合从个人开发者到大型企业的各类用户场景。",70612,3,"2026-04-05T11:12:22",[19,17,20,16],{"id":33,"name":34,"github_repo":35,"description_zh":36,"stars":37,"difficulty_score":10,"last_commit_at":38,"category_tags":39,"status":22},3074,"gpt4free","xtekky\u002Fgpt4free","gpt4free 是一个由社区驱动的开源项目，旨在聚合多种可访问的大型语言模型（LLM）和媒体生成接口，让用户能更灵活、便捷地使用前沿 AI 能力。它解决了直接调用各类模型时面临的接口分散、门槛高或成本昂贵等痛点，通过统一的标准将不同提供商的资源整合在一起。\n\n无论是希望快速集成 AI 功能的开发者、需要多模型对比测试的研究人员，还是想免费体验最新技术的普通用户，都能从中受益。gpt4free 提供了丰富的使用方式：既包含易于上手的 Python 和 JavaScript 客户端库，也支持部署本地图形界面（GUI），更提供了兼容 OpenAI 标准的 REST API，方便无缝替换现有应用后端。\n\n其技术亮点在于强大的多提供商支持架构，能够动态调度包括 Opus、Gemini、DeepSeek 等多种主流模型资源，并支持 Docker 一键部署及本地推理。项目秉持社区优先原则，在降低使用门槛的同时，也为贡献者提供了扩展新接口的便利框架，是探索和利用多样化 AI 资源的实用工具。",65970,"2026-04-04T01:02:03",[16,19,17],{"id":41,"name":42,"github_repo":43,"description_zh":44,"stars":45,"difficulty_score":10,"last_commit_at":46,"category_tags":47,"status":22},51,"gstack","garrytan\u002Fgstack","gstack 是 Y Combinator CEO Garry Tan 亲自开源的一套 AI 工程化配置，旨在将 Claude Code 升级为你的虚拟工程团队。面对单人开发难以兼顾产品战略、架构设计、代码审查及质量测试的挑战，gstack 提供了一套标准化解决方案，帮助开发者实现堪比二十人团队的高效产出。\n\n这套配置特别适合希望提升交付效率的创始人、技术负责人，以及初次尝试 Claude Code 的开发者。gstack 的核心亮点在于内置了 15 个具有明确职责的 AI 角色工具，涵盖 CEO、设计师、工程经理、QA 等职能。用户只需通过简单的斜杠命令（如 `\u002Freview` 进行代码审查、`\u002Fqa` 执行测试、`\u002Fplan-ceo-review` 规划功能），即可自动化处理从需求分析到部署上线的全链路任务。\n\n所有操作基于 Markdown 和斜杠命令，无需复杂配置，完全免费且遵循 MIT 协议。gstack 不仅是一套工具集，更是一种现代化的软件工厂实践，让单人开发者也能拥有严谨的工程流程。",64604,"2026-04-05T23:10:16",[17,16],{"id":49,"name":50,"github_repo":51,"description_zh":52,"stars":53,"difficulty_score":10,"last_commit_at":54,"category_tags":55,"status":22},193,"meilisearch","meilisearch\u002Fmeilisearch","Meilisearch 是一个开源的极速搜索服务，专为现代应用和网站打造，开箱即用。它能帮助开发者快速集成高质量的搜索功能，无需复杂的配置或额外的数据预处理。传统搜索方案往往需要大量调优才能实现准确结果，而 Meilisearch 内置了拼写容错、同义词识别、即时响应等实用特性，并支持 AI 驱动的混合搜索（结合关键词与语义理解），显著提升用户查找信息的体验。\n\nMeilisearch 特别适合 Web 开发者、产品团队或初创公司使用，尤其适用于需要快速上线搜索功能的场景，如电商网站、内容平台或 SaaS 应用。它提供简洁的 RESTful API 和多种语言 SDK，部署简单，资源占用低，本地开发或生产环境均可轻松运行。对于希望在不依赖大型云服务的前提下，为用户提供流畅、智能搜索体验的团队来说，Meilisearch 是一个高效且友好的选择。",56972,"2026-04-05T22:34:33",[13,17,14,20,16,18],{"id":57,"name":58,"github_repo":59,"description_zh":60,"stars":61,"difficulty_score":10,"last_commit_at":62,"category_tags":63,"status":22},4022,"awesome-claude-skills","ComposioHQ\u002Fawesome-claude-skills","awesome-claude-skills 是一个精心整理的开源资源库，旨在帮助用户挖掘和扩展 Claude AI 的潜力。它不仅仅是一份列表，更提供了实用的“技能（Skills）”模块，让 Claude 从单纯的文本生成助手，进化为能执行复杂工作流的智能代理。\n\n许多用户在使用 AI 时，常受限于其无法直接操作外部软件或处理特定格式文件的痛点。awesome-claude-skills 通过预设的工作流解决了这一问题：它不仅能教会 Claude 专业地处理 Word、PDF 等文档，进行代码开发与数据分析，还能借助 Composio 插件连接 Slack、邮箱及数百种常用应用，实现发送邮件、创建任务等自动化操作。这使得重复性任务变得标准化且可复用，极大提升了工作效率。\n\n无论是希望优化日常办公流程的普通用户、需要处理复杂文档的研究人员，还是寻求将 AI 深度集成到开发管线中的开发者，都能从中找到适合的解决方案。其独特的技术亮点在于“技能”的可定制性与强大的应用连接能力，让用户无需编写复杂代码，即可通过简单的配置让 Claude 具备跨平台执行真实任务的能力。如果你希望让 Claude",51312,"2026-04-05T19:04:23",[17,16],{"id":65,"github_repo":66,"name":67,"description_en":68,"description_zh":69,"ai_summary_zh":70,"readme_en":71,"readme_zh":72,"quickstart_zh":73,"use_case_zh":74,"hero_image_url":75,"owner_login":76,"owner_name":77,"owner_avatar_url":78,"owner_bio":79,"owner_company":80,"owner_location":80,"owner_email":81,"owner_twitter":82,"owner_website":83,"owner_url":84,"languages":85,"stars":102,"forks":103,"last_commit_at":104,"license":105,"difficulty_score":10,"env_os":106,"env_gpu":107,"env_ram":107,"env_deps":108,"category_tags":115,"github_topics":116,"view_count":10,"oss_zip_url":80,"oss_zip_packed_at":80,"status":22,"created_at":127,"updated_at":128,"faqs":129,"releases":165},3846,"alpacahq\u002Falpaca-mcp-server","alpaca-mcp-server","Alpaca’s official MCP Server lets you trade stocks, ETFs, crypto, and options, run data analysis, and build strategies in plain English directly from your favorite LLM tools and IDEs","alpaca-mcp-server 是 Alpaca 官方推出的模型上下文协议（MCP）服务器，旨在让用户通过自然语言直接在 AI 助手或集成开发环境（如 Claude、Cursor、VS Code）中进行金融交易与数据分析。它打通了大型语言模型与 Alpaca 交易 API 之间的壁垒，使用户能用通俗的英语指令完成股票、ETF、加密货币及期权的买卖、投资组合管理和实时行情查询，无需编写复杂的代码或查阅繁琐的 API 文档。\n\n这一工具主要解决了传统量化交易门槛高、交互复杂的问题，让非专业程序员也能借助 AI 轻松构建交易策略并执行操作。它特别适合开发者、量化研究员以及希望将 AI 能力融入交易流程的金融从业者使用。对于熟悉 Python 或正在构建 AI 代理的工程师而言，它提供了极佳的集成体验；而对于普通投资者，它则提供了一种全新的、对话式的交易互动方式。\n\n技术层面，最新的 v2 版本基于 FastMCP 和 OpenAPI 规范彻底重构，不仅实现了工具定义的自动化生成，确保参数与官方 API 严格对齐，还支持通过环境变量灵活配置工具集权限，提升了系统的安全性与可维护性。无论是想","alpaca-mcp-server 是 Alpaca 官方推出的模型上下文协议（MCP）服务器，旨在让用户通过自然语言直接在 AI 助手或集成开发环境（如 Claude、Cursor、VS Code）中进行金融交易与数据分析。它打通了大型语言模型与 Alpaca 交易 API 之间的壁垒，使用户能用通俗的英语指令完成股票、ETF、加密货币及期权的买卖、投资组合管理和实时行情查询，无需编写复杂的代码或查阅繁琐的 API 文档。\n\n这一工具主要解决了传统量化交易门槛高、交互复杂的问题，让非专业程序员也能借助 AI 轻松构建交易策略并执行操作。它特别适合开发者、量化研究员以及希望将 AI 能力融入交易流程的金融从业者使用。对于熟悉 Python 或正在构建 AI 代理的工程师而言，它提供了极佳的集成体验；而对于普通投资者，它则提供了一种全新的、对话式的交易互动方式。\n\n技术层面，最新的 v2 版本基于 FastMCP 和 OpenAPI 规范彻底重构，不仅实现了工具定义的自动化生成，确保参数与官方 API 严格对齐，还支持通过环境变量灵活配置工具集权限，提升了系统的安全性与可维护性。无论是想快速验证交易想法，还是构建全自动的 AI 交易机器人，alpaca-mcp-server 都是一个强大且易用的桥梁。","\u003Cp align=\"center\">\n  \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Falpacahq_alpaca-mcp-server_readme_cf3e0a78463e.png\" alt=\"Alpaca logo\" width=\"220\">\n\u003C\u002Fp>\n\n\u003Cdiv align=\"center\">\n\n\u003Ca href=\"https:\u002F\u002Fx.com\u002Falpacahq?lang=en\" target=\"_blank\">\u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FX-DCDCDC?logo=x&logoColor=000\" alt=\"X\">\u003C\u002Fa>\n\u003Ca href=\"https:\u002F\u002Fwww.reddit.com\u002Fr\u002Falpacamarkets\u002F\" target=\"_blank\">\u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FReddit-DCDCDC?logo=reddit&logoColor=000\" alt=\"Reddit\">\u003C\u002Fa>\n\u003Ca href=\"https:\u002F\u002Falpaca.markets\u002Fslack\" target=\"_blank\">\u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FSlack-DCDCDC?logo=slack&logoColor=000\" alt=\"Slack\">\u003C\u002Fa>\n\u003Ca href=\"https:\u002F\u002Fwww.linkedin.com\u002Fcompany\u002Falpacamarkets\u002F\" target=\"_blank\">\u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FLinkedIn-DCDCDC\" alt=\"LinkedIn\">\u003C\u002Fa>\n\u003Ca href=\"https:\u002F\u002Fforum.alpaca.markets\u002F\" target=\"_blank\">\u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FForum-DCDCDC?logo=discourse&logoColor=000\" alt=\"Forum\">\u003C\u002Fa>\n\u003Ca href=\"https:\u002F\u002Fdocs.alpaca.markets\u002Fdocs\u002Fgetting-started\" target=\"_blank\">\u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FDocs-DCDCDC\" alt=\"Docs\">\u003C\u002Fa>\n\u003Ca href=\"https:\u002F\u002Falpaca.markets\u002Fsdks\u002Fpython\u002F\" target=\"_blank\">\u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FPython_SDK-DCDCDC?logo=python&logoColor=000\" alt=\"Python SDK\">\u003C\u002Fa>\n\n\u003C\u002Fdiv>\n\n\u003Cp align=\"center\">\n  A comprehensive Model Context Protocol (MCP) server for Alpaca's Trading API. Enable natural language trading operations through AI assistants like Claude, Cursor, and VS Code. Supports stocks, options, crypto, portfolio management, and real-time market data.\n\u003C\u002Fp>\n\n> **Alpaca MCP Server v2 is here.** This version is a complete rewrite built with FastMCP and OpenAPI. If you're upgrading from v1, please read the [Upgrade Guide](#upgrading-from-v1) — tool names, parameters, and configuration have changed.\n\n## Table of Contents\n\n- [Upgrading from V1](#upgrading-from-v1)\n- [Prerequisites](#prerequisites)\n- [Getting Your API Keys](#getting-your-api-keys)\n- [Setup](#setup)\n- [Configuration](#configuration)\n- [Features](#features)\n- [Example Prompts](#example-prompts)\n- [Available Tools](#available-tools)\n- [Testing](#testing)\n- [Project Structure](#project-structure)\n- [Troubleshooting](#troubleshooting)\n- [Disclosure](#disclosure)\n\n---\n\n## Upgrading from V1\n\nV2 is a **complete rewrite** built with FastMCP and OpenAPI. **None of the V1 tools exist in V2** — tool names, parameters, and schemas have changed. You cannot use V2 as a drop-in replacement if your setup depends on specific V1 tool names or parameters.\n\n### What changes\n\n\n| Aspect             | V1                                     | V2                                                                                           |\n| ------------------ | -------------------------------------- | -------------------------------------------------------------------------------------------- |\n| **Tool names**     | Hand-crafted (e.g. `get_account_info`) | Spec-derived with overrides (e.g. `get_account_info` — names may overlap but schemas differ) |\n| **Parameters**     | Custom schemas                         | Aligned with Alpaca API specs                                                                |\n| **Configuration**  | `.env` + `init` command                | Env vars in MCP client config only                                                           |\n| **Tool filtering** | Not supported                          | `ALPACA_TOOLSETS` env var                                                                    |\n| **Whitelisting**   | Not supported                          | Use `ALPACA_TOOLSETS` to restrict tools                                                      |\n\n\n### How to avoid V1-style usage in V2\n\nMCP clients discover tools dynamically from the server. There is no config file where you \"whitelist\" tool names — the client gets whatever tools the server exposes. To avoid your client or AI assistant using V2 incorrectly:\n\n1. **Do not reuse V1 config** — Treat V2 as a new server. Update your MCP client config with the new command\u002Fargs; remove any `.env` or `init`-based setup.\n2. **Clear tool caches** — Restart your MCP client (Claude Desktop, Cursor, VS Code, etc.) after switching so it fetches the new tool list instead of using a stale one.\n3. **Start a fresh chat\u002Fsession** — Existing conversations may have cached references to old tool names. Start a new chat so the LLM sees the current V2 tools and their schemas.\n4. **Update custom instructions and rules** — If you have Cursor rules, Claude instructions, or other prompts that mention specific V1 tool names (e.g. \"use `get_account_info`\"), update them to match V2 tool names or remove those references and let the LLM discover tools from context.\n5. **Restrict tools with** `ALPACA_TOOLSETS` — If you previously limited which capabilities your assistant could use, V2 supports server-side filtering via the `ALPACA_TOOLSETS` env var. See [Configuration > Toolset Filtering](#toolset-filtering) for the list of toolsets.\n\n### Summary\n\nAssume **no backward compatibility** with V1. Reconfigure your MCP client for V2, restart it, and use a fresh session. Check the [Available Tools](#available-tools) section for the current tool list.\n\n### If you had custom V1 workflows\n\nIf you documented allowed tools, wrote scripts that call tools by name, or built prompts around specific V1 tool\u002Fparameter shapes — treat them as obsolete. Recreate them using the [Available Tools](#available-tools) listed below and the current parameter schemas exposed by the server.\n\n### Staying on V1\n\nIf you need to stay on V1, pin to the last V1 release (e.g. `uvx alpaca-mcp-server==1.x.x serve`) in your MCP client config. V1 remains available on PyPI for existing setups.\n\n---\n\n## Prerequisites\n\n- **Python 3.10+** ([installation guide](https:\u002F\u002Fwww.python.org\u002Fdownloads\u002F))\n- **uv** ([installation guide](https:\u002F\u002Fdocs.astral.sh\u002Fuv\u002Fgetting-started\u002Finstallation\u002F))\n- **Alpaca Trading API keys** (free paper trading account)\n- **MCP client** (Claude Desktop, Cursor, VS Code, etc.)\n\n## Getting Your API Keys\n\n1. Visit the [Alpaca Dashboard](https:\u002F\u002Fapp.alpaca.markets\u002Fpaper\u002Fdashboard\u002Foverview)\n2. Create a free paper trading account\n3. Generate API keys from the dashboard\n\n## Setup\n\nAdd the server to your MCP client config, then restart the client. No `init` command, no `.env` files — credentials are set in **one place only**.\n\n### Claude Desktop\n\nEdit `~\u002FLibrary\u002FApplication Support\u002FClaude\u002Fclaude_desktop_config.json` (Mac) or `%APPDATA%\\Claude\\claude_desktop_config.json` (Windows):\n\n```json\n{\n  \"mcpServers\": {\n    \"alpaca\": {\n      \"command\": \"uvx\",\n      \"args\": [\"alpaca-mcp-server\"],\n      \"env\": {\n        \"ALPACA_API_KEY\": \"your_alpaca_api_key\",\n        \"ALPACA_SECRET_KEY\": \"your_alpaca_secret_key\"\n      }\n    }\n  }\n}\n```\n\n### Cursor\n\nInstall from the [Cursor Directory](https:\u002F\u002Fcursor.directory\u002Fmcp\u002Falpaca) in a few clicks, or add to `~\u002F.cursor\u002Fmcp.json`:\n\n```json\n{\n  \"mcpServers\": {\n    \"alpaca\": {\n      \"command\": \"uvx\",\n      \"args\": [\"alpaca-mcp-server\"],\n      \"env\": {\n        \"ALPACA_API_KEY\": \"your_alpaca_api_key\",\n        \"ALPACA_SECRET_KEY\": \"your_alpaca_secret_key\"\n      }\n    }\n  }\n}\n```\n\n### VS Code\n\nCreate `.vscode\u002Fmcp.json` in your project root. See the [official docs](https:\u002F\u002Fcode.visualstudio.com\u002Fdocs\u002Fcopilot\u002Fchat\u002Fmcp-servers).\n\n```json\n{\n  \"mcp\": {\n    \"servers\": {\n      \"alpaca\": {\n        \"type\": \"stdio\",\n        \"command\": \"uvx\",\n        \"args\": [\"alpaca-mcp-server\"],\n        \"env\": {\n          \"ALPACA_API_KEY\": \"your_alpaca_api_key\",\n          \"ALPACA_SECRET_KEY\": \"your_alpaca_secret_key\"\n        }\n      }\n    }\n  }\n}\n```\n\n**PyCharm**  \n\nSee the [official guide](https:\u002F\u002Fwww.jetbrains.com\u002Fhelp\u002Fai-assistant\u002Fconfigure-an-mcp-server.html).\n\n1. Go to File → Settings → Tools → Model Context Protocol (MCP)\n2. Add a new server:\n  - **Type**: stdio\n  - **Command**: uvx\n  - **Arguments**: alpaca-mcp-server\n3. Set environment variables:\n  ```\n   ALPACA_API_KEY=your_alpaca_api_key\n   ALPACA_SECRET_KEY=your_alpaca_secret_key\n  ```\n\n**Claude Code**  \n\n```bash\nclaude mcp add alpaca --scope user --transport stdio uvx alpaca-mcp-server \\\n  --env ALPACA_API_KEY=your_alpaca_api_key \\\n  --env ALPACA_SECRET_KEY=your_alpaca_secret_key\n```\n\nVerify with `\u002Fmcp` in the Claude Code CLI.\n\n**Gemini CLI**  \n\nSee the [Gemini CLI MCP docs](https:\u002F\u002Fgithub.com\u002Fgoogle-gemini\u002Fgemini-cli\u002Fblob\u002Fmain\u002Fdocs\u002Ftools\u002Fmcp-server.md).\n\nAdd to your `settings.json`:\n\n```json\n{\n  \"mcpServers\": {\n    \"alpaca\": {\n      \"type\": \"stdio\",\n      \"command\": \"uvx\",\n      \"args\": [\"alpaca-mcp-server\"],\n      \"env\": {\n        \"ALPACA_API_KEY\": \"your_alpaca_api_key\",\n        \"ALPACA_SECRET_KEY\": \"your_alpaca_secret_key\"\n      }\n    }\n  }\n}\n```\n\n**Docker**  \n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Falpacahq\u002Falpaca-mcp-server.git\ncd alpaca-mcp-server\ndocker build -t mcp\u002Falpaca:latest .\n```\n\nAdd to your MCP client config:\n\n```json\n{\n  \"mcpServers\": {\n    \"alpaca\": {\n      \"command\": \"docker\",\n      \"args\": [\n        \"run\", \"--rm\", \"-i\",\n        \"-e\", \"ALPACA_API_KEY=your_key\",\n        \"-e\", \"ALPACA_SECRET_KEY=your_secret\",\n        \"-e\", \"ALPACA_PAPER_TRADE=true\",\n        \"mcp\u002Falpaca:latest\"\n      ]\n    }\n  }\n}\n```\n\n## Configuration\n\nAll configuration is through environment variables set in your MCP client config. No files are written to disk.\n\n\n| Variable             | Required | Default | Description                                |\n| -------------------- | -------- | ------- | ------------------------------------------ |\n| `ALPACA_API_KEY`     | Yes      | —       | Your Alpaca API key                        |\n| `ALPACA_SECRET_KEY`  | Yes      | —       | Your Alpaca secret key                     |\n| `ALPACA_PAPER_TRADE` | No       | `true`  | Set to `false` for live trading            |\n| `ALPACA_TOOLSETS`    | No       | all     | Comma-separated list of toolsets to enable |\n\n\n### Switching to Live Trading\n\nUpdate the `env` block in your MCP client config and restart:\n\n```json\n{\n  \"env\": {\n    \"ALPACA_API_KEY\": \"your_live_api_key\",\n    \"ALPACA_SECRET_KEY\": \"your_live_secret_key\",\n    \"ALPACA_PAPER_TRADE\": \"false\"\n  }\n}\n```\n\n### Toolset Filtering\n\nBy default, all tools are enabled. To limit the server to specific toolsets, set `ALPACA_TOOLSETS`:\n\n```json\n{\n  \"env\": {\n    \"ALPACA_API_KEY\": \"...\",\n    \"ALPACA_SECRET_KEY\": \"...\",\n    \"ALPACA_TOOLSETS\": \"stock-data,crypto-data\"\n  }\n}\n```\n\nAvailable toolsets:\n\n\n| Toolset             | Description                                                   |\n| ------------------- | ------------------------------------------------------------- |\n| `account`           | Account info, config, portfolio history, activities           |\n| `trading`           | Orders, positions, exercise options                           |\n| `watchlists`        | Watchlist CRUD operations                                     |\n| `assets`            | Asset lookup, option contracts, calendar, clock               |\n| `stock-data`        | Stock bars, quotes, trades, snapshots, screeners              |\n| `crypto-data`       | Crypto bars, quotes, trades, snapshots, orderbooks            |\n| `options-data`      | Option bars, quotes, trades, snapshots, chain, exchange codes |\n| `corporate-actions` | Corporate action announcements                                |\n\n\n## Features\n\n- **Market Data** — Real-time quotes, trades, and price bars for stocks, crypto, and options. Historical data with flexible timeframes. Option Greeks and implied volatility.\n- **Account Management** — View balances, buying power, account status, and portfolio history.\n- **Order Management** — Place market, limit, stop, stop-limit, and trailing-stop orders for stocks, crypto, and options. Cancel orders individually or in bulk.\n- **Options Trading** — Search contracts by expiration\u002Fstrike\u002Ftype. Place single-leg or multi-leg strategies. Get latest quotes, Greeks, and IV.\n- **Crypto Trading** — Market, limit, and stop-limit orders with GTC\u002FIOC. Quantity or notional-based.\n- **Position Management** — View, close, or liquidate positions. Exercise option contracts.\n- **Market Status** — Market open\u002Fclose times, calendar, corporate actions.\n- **Watchlists** — Create, update, and manage watchlists.\n- **Asset Search** — Query details for stocks, ETFs, crypto, and options with filtering.\n\n## Example Prompts\n\n**Basic Trading**\n\n1. What's my current account balance and buying power on Alpaca?\n2. Show me my current positions in my Alpaca account.\n3. Buy 5 shares of AAPL at market price.\n4. Sell 5 shares of TSLA with a limit price of $300.\n5. Cancel all open stock orders.\n6. Cancel the order with ID abc123.\n7. Liquidate my entire position in GOOGL.\n8. Close 10% of my position in NVDA.\n9. Place a limit order to buy 100 shares of MSFT at $450.\n10. Place a market order to sell 25 shares of META.\n\n**Crypto Trading**\n\n1. Place a market order to buy 0.01 ETH\u002FUSD.\n2. Place a limit order to sell 0.01 BTC\u002FUSD at $110,000.\n\n**Option Trading**\n\n1. Show me available option contracts for AAPL expiring next month.\n2. Get the latest quote for the AAPL250613C00200000 option.\n3. Retrieve the option snapshot for the SPY250627P00400000 option.\n4. Liquidate my position in 2 contracts of QQQ calls expiring next week.\n5. Place a market order to buy 1 call option on AAPL expiring next Friday.\n6. What are the option Greeks for the TSLA250620P00500000 option?\n7. Find TSLA option contracts with strike prices within 5% of the current market price.\n8. Get SPY call options expiring the week of June 16th, 2025, within 10% of market price.\n9. Place a bull call spread using AAPL June 6th options: one with a 190.00 strike and the other with a 200.00 strike.\n10. Exercise my NVDA call option contract NVDA250919C001680.\n\n**Market Information**\n\n> To access the latest 15-minute data, you need to subscribe to the [Algo Trader Plus Plan](https:\u002F\u002Falpaca.markets\u002Fdata).\n>\n> 1. What are the market open and close times today?\n> 2. Show me the market calendar for next week.\n> 3. Show me recent cash dividends and stock splits for AAPL, MSFT, and GOOGL in the last 3 months.\n> 4. Get all corporate actions for SPY including dividends, splits, and any mergers in the past year.\n> 5. What are the upcoming corporate actions scheduled for SPY in the next 6 months?\n\n**Historical & Real-time Data**\n\n1. Show me AAPL's daily price history for the last 5 trading days.\n2. What was the closing price of TSLA yesterday?\n3. Get the latest bar for GOOGL.\n4. What was the latest trade price for NVDA?\n5. Show me the most recent quote for MSFT.\n6. Retrieve the last 100 trades for AMD.\n7. Show me 1-minute bars for AMZN from the last 2 hours.\n8. Get 5-minute intraday bars for TSLA from last Tuesday through last Friday.\n9. Get a comprehensive stock snapshot for AAPL showing latest quote, trade, minute bar, daily bar, and previous daily bar all in one view.\n10. Compare market snapshots for TSLA, NVDA, and MSFT to analyze their current bid\u002Fask spreads, latest trade prices, and daily performance.\n\n**Orders**\n\n1. Show me all my open and filled orders from this week.\n2. What orders do I have for AAPL?\n3. List all limit orders I placed in the past 3 days.\n4. Filter all orders by status: filled.\n5. Get me the order history for yesterday.\n\n**Watchlists**\n\n> At this moment, you can only view and update trading watchlists created via Alpaca's Trading API through the API itself\n>\n> 1. Create a new watchlist called \"Tech Stocks\" with AAPL, MSFT, and NVDA.\n> 2. Update my \"Tech Stocks\" watchlist to include TSLA and AMZN.\n> 3. What stocks are in my \"Dividend Picks\" watchlist?\n> 4. Remove META from my \"Growth Portfolio\" watchlist.\n> 5. List all my existing watchlists.\n\n**Asset Information**\n\n1. Search for details about the asset 'AAPL'.\n2. Show me the top 5 tradable crypto assets by trading volume.\n3. Get all NASDAQ active US equity assets and filter the results to show only tradable securities\n\n**Combined Scenarios**\n\n1. Get today's market clock and show me my buying power before placing a limit buy order for TSLA at $340.\n2. Place a bull call spread with SPY July 3rd options: sell one 5% above and buy one 3% below the current SPY price.\n\n## Available Tools\n\n**Account & Portfolio**\n\n- `get_account_info` — Balance, margin, and account status\n- `get_account_config` — Trading restrictions, margin settings, PDT checks\n- `update_account_config` — Update account configuration settings\n- `get_portfolio_history` — Equity and P\u002FL over time\n- `get_account_activities` — Fills, dividends, transfers\n- `get_account_activities_by_type` — Activities filtered by type\n\n**Trading (Orders)**\n\n- `get_orders` — Retrieve orders with filters\n- `get_order_by_id` — Single order by ID\n- `get_order_by_client_id` — Single order by client order ID\n- `replace_order_by_id` — Replace an existing open order\n- `cancel_order_by_id` — Cancel a specific order\n- `cancel_all_orders` — Cancel all open orders\n- `place_stock_order` — Stocks\u002FETFs (market, limit, stop, stop-limit, trailing-stop, brackets)\n- `place_crypto_order` — Crypto (market, limit, stop-limit)\n- `place_option_order` — Options (single-leg or multi-leg)\n\n**Positions**\n\n- `get_all_positions` — All current positions\n- `get_open_position` — Details for a specific position\n- `close_position` — Close a specific position\n- `close_all_positions` — Liquidate entire portfolio\n- `exercise_options_position` — Exercise a held option contract\n- `do_not_exercise_options_position` — Do-not-exercise instruction\n\n**Watchlists**\n\n- `create_watchlist` — Create a new watchlist\n- `get_watchlists` — List all watchlists\n- `get_watchlist_by_id` — Get a specific watchlist\n- `update_watchlist_by_id` — Update a watchlist\n- `delete_watchlist_by_id` — Delete a watchlist\n- `add_asset_to_watchlist_by_id` — Add an asset to a watchlist\n- `remove_asset_from_watchlist_by_id` — Remove an asset from a watchlist\n\n**Assets & Market Info**\n\n- `get_all_assets` — List assets with optional filtering\n- `get_asset` — Detailed info for a specific asset\n- `get_option_contracts` — Option contracts for underlying symbol(s)\n- `get_option_contract` — Single option contract by symbol or ID\n- `get_calendar` — Market calendar for a date range\n- `get_clock` — Current market status and next open\u002Fclose\n- `get_corporate_action_announcements` — Corporate action announcements\n- `get_corporate_action_announcement` — Single announcement by ID\n\n**Stock Data**\n\n- `get_stock_bars` — Historical OHLCV bars\n- `get_stock_quotes` — Historical bid\u002Fask quotes\n- `get_stock_trades` — Historical trades\n- `get_stock_latest_bar` — Latest minute bar\n- `get_stock_latest_quote` — Latest quote\n- `get_stock_latest_trade` — Latest trade\n- `get_stock_snapshot` — Comprehensive snapshot\n- `get_most_active_stocks` — Most active by volume\u002Ftrade count\n- `get_market_movers` — Top gainers and losers\n\n**Crypto Data**\n\n- `get_crypto_bars` — Historical OHLCV bars\n- `get_crypto_quotes` — Historical quotes\n- `get_crypto_trades` — Historical trades\n- `get_crypto_latest_bar` — Latest minute bar\n- `get_crypto_latest_quote` — Latest quote\n- `get_crypto_latest_trade` — Latest trade\n- `get_crypto_snapshot` — Comprehensive snapshot\n- `get_crypto_latest_orderbook` — Latest orderbook\n\n**Options Data**\n\n- `get_option_bars` — Historical OHLCV bars\n- `get_option_trades` — Historical trades\n- `get_option_latest_trade` — Latest trade\n- `get_option_latest_quote` — Latest quote with bid\u002Fask and exchange info\n- `get_option_snapshot` — Snapshot with Greeks and IV\n- `get_option_chain` — Full option chain for an underlying\n- `get_option_exchange_codes` — Exchange code to name mapping\n\n**Corporate Actions**\n\n- `get_corporate_actions` — Corporate action announcements from market data\n\n## Testing\n\nThe project includes a multi-layered test suite that runs in CI on every pull request:\n\n- **Integrity tests** — Validate consistency between OpenAPI specs, toolset definitions, and tool name\u002Fdescription overrides. No network or credentials required.\n- **Server construction tests** — Build the server with mocked credentials and verify the correct number of tools are exposed. No network required.\n- **Paper API integration tests** — Execute real calls against the Alpaca paper trading API, covering account info, market data, order lifecycle, watchlists, positions, and more. Requires `ALPACA_API_KEY` and `ALPACA_SECRET_KEY`.\n\nRun the full suite locally:\n\n```bash\n# Core tests (no credentials needed)\npytest tests\u002Ftest_integrity.py tests\u002Ftest_server_construction.py -v\n\n# Integration tests (requires paper API keys)\nALPACA_API_KEY=... ALPACA_SECRET_KEY=... pytest tests\u002F -m integration -v\n```\n\n## Project Structure\n\n```\nalpaca-mcp-server\u002F\n├── src\u002F\n│   └── alpaca_mcp_server\u002F\n│       ├── __init__.py\n│       ├── cli.py            ← CLI entry point\n│       ├── server.py         ← FastMCP server built from OpenAPI specs\n│       ├── names.py          ← Tool name and description overrides\n│       ├── toolsets.py       ← Toolset → operationId allowlists\n│       ├── overrides.py      ← Hand-crafted tools for complex trading endpoints\n│       ├── market_data_overrides.py ← Hand-crafted tools for historical data\n│       └── specs\u002F\n│           ├── trading-api.json\n│           └── market-data-api.json\n├── tests\u002F\n│   ├── conftest.py           ← Shared fixtures and paper-account cleanup\n│   ├── test_integrity.py     ← Spec ↔ toolset ↔ names consistency checks\n│   ├── test_server_construction.py ← Server build verification\n│   └── test_paper_integration.py   ← Paper API integration tests\n├── scripts\u002F\n│   └── sync-specs.sh        ← Download latest OpenAPI specs\n├── .github\u002F\n│   └── workflows\u002F\n│       └── ci.yml            ← CI pipeline (core + integration)\n├── AGENTS.md                 ← Instructions for coding agents\n├── pyproject.toml\n└── README.md\n```\n\n## Troubleshooting\n\n- **uv\u002Fuvx not found**: Install uv from the official guide ([https:\u002F\u002Fdocs.astral.sh\u002Fuv\u002Fgetting-started\u002Finstallation\u002F](https:\u002F\u002Fdocs.astral.sh\u002Fuv\u002Fgetting-started\u002Finstallation\u002F)) and then restart your terminal so `uv`\u002F`uvx` are on PATH.\n- **Credentials missing**: Set `ALPACA_API_KEY` and `ALPACA_SECRET_KEY` in the client's `env` block. Paper mode default is `ALPACA_PAPER_TRADE = True`.\n- **Client didn't pick up new config**: Restart the client (Cursor, Claude Desktop, VS Code) after changes.\n- **HTTP port conflicts**: If using `--transport streamable-http`, change `--port` to a free port.\n\n## Disclosure\n\nInsights generated by our MCP server and connected AI agents are for educational and informational purposes only and should not be taken as investment advice. Alpaca does not recommend any specific securities or investment strategies.Please conduct your own due diligence before making any decisions. All firms mentioned operate independently and are not liable for one another.\n\nOptions trading is not suitable for all investors due to its inherent high risk, which can potentially result in significant losses. Please read Characteristics and Risks of Standardized Options ([Options Disclosure Document](https:\u002F\u002Fwww.theocc.com\u002Fcompany-information\u002Fdocuments-and-archives\u002Foptions-disclosure-document?ref=alpaca.markets)) before investing in options.\n\nAlpaca does not prepare, edit, endorse, or approve Third Party Content. Alpaca does not guarantee the accuracy, timeliness, completeness or usefulness of Third Party Content, and is not responsible or liable for any content, advertising, products, or other materials on or available from third party sites.\n\nAll investments involve risk, and the past performance of a security, or financial product does not guarantee future results or returns. There is no guarantee that any investment strategy will achieve its objectives. Please note that diversification does not ensure a profit, or protect against loss. There is always the potential of losing money when you invest in securities, or other financial products. Investors should consider their investment objectives and risks carefully before investing.\n\nThe algorithm's calculations are based on historical and real-time market data but may not account for all market factors, including sudden price moves, liquidity constraints, or execution delays. Model assumptions, such as volatility estimates and dividend treatments, can impact performance and accuracy. Trades generated by the algorithm are subject to brokerage execution processes, market liquidity, order priority, and timing delays. These factors may cause deviations from expected trade execution prices or times. Users are responsible for monitoring algorithmic activity and understanding the risks involved. Alpaca is not liable for any losses incurred through the use of this system.\n\nPast hypothetical backtest results do not guarantee future returns, and actual results may vary from the analysis.\n\nThe Paper Trading API is offered by AlpacaDB, Inc. and does not require real money or permit a user to transact in real securities in the market. Providing use of the Paper Trading API is not an offer or solicitation to buy or sell securities, securities derivative or futures products of any kind, or any type of trading or investment advice, recommendation or strategy, given or in any manner endorsed by AlpacaDB, Inc. or any AlpacaDB, Inc. affiliate and the information made available through the Paper Trading API is not an offer or solicitation of any kind in any jurisdiction where AlpacaDB, Inc. or any AlpacaDB, Inc. affiliate (collectively, \"Alpaca\") is not authorized to do business.\n\nSecurities brokerage services are provided by Alpaca Securities LLC (\"Alpaca Securities\"), member [FINRA](https:\u002F\u002Fwww.finra.org\u002F)\u002F[SIPC](https:\u002F\u002Fwww.sipc.org\u002F), a wholly-owned subsidiary of AlpacaDB, Inc. Technology and services are offered by AlpacaDB, Inc.\n\nCryptocurrency services are provided by Alpaca Crypto LLC (\"Alpaca Crypto\"), a FinCEN registered money services business (NMLS # 2160858), and a wholly-owned subsidiary of AlpacaDB, Inc. Alpaca Crypto is not a member of SIPC or FINRA. Cryptocurrencies are not stocks and your cryptocurrency investments are not protected by either FDIC or SIPC.  Cryptocurrency assets are highly volatile and speculative, involving substantial risk of loss, and are not insured by the FDIC or any government agency. Customers should be aware of the various risks prior to engaging these services, including potential loss of principal, cybersecurity considerations, regulatory developments, and the evolving nature of digital asset technology. For additional information on the risks of cryptocurrency, please click [here](https:\u002F\u002Ffiles.alpaca.markets\u002Fdisclosures\u002Flibrary\u002FCryptoRiskDisclosures.pdf).\n\nThis is not an offer, solicitation of an offer, or advice to buy or sell securities or cryptocurrencies or open a brokerage account or cryptocurrency account in any jurisdiction where Alpaca Securities or Alpaca Crypto, respectively, are not registered or licensed, as applicable.\n\n## Privacy Policy\n\nFor information about how Alpaca handles your data, please review:\n\n- [Privacy Policy](https:\u002F\u002Fs3.amazonaws.com\u002Ffiles.alpaca.markets\u002Fdisclosures\u002FPrivacyPolicy.pdf)\n- [Disclosure Library](https:\u002F\u002Falpaca.markets\u002Fdisclosures)\n\n### Data Collection\n\n- **What is collected**: User agent string ('ALPACA-MCP-SERVER') for API calls\n- **How it's used**: To identify MCP server usage and improve user experience\n- **Third-party sharing**: Not shared with third parties\n- **Retention**: Retained per Alpaca's standard data retention policy\n- **Opt-out**: Modify the 'USER_AGENT' constant in '.github\u002Fcore\u002Fuser_agent_mixin.py' or remove 'UserAgentMixin' from client class definitions\n\n## Security Notice\n\nThis server can place real trades and access your portfolio. Treat your API keys as sensitive credentials. Review all actions proposed by the LLM carefully, especially for complex options strategies or multi-leg trades.\n\n**HTTP Transport Security**: When using HTTP transport, the server defaults to localhost (127.0.0.1:8000) for security. For remote access, you can bind to all interfaces with `--host 0.0.0.0`, use SSH tunneling (`ssh -L 8000:localhost:8000 user@server`), or set up a reverse proxy with authentication for secure access.\n\n## Support\n\nFor issues or questions, please contact us at [support@alpaca.markets](mailto:support@alpaca.markets).\n\nGitHub Issues: [https:\u002F\u002Fgithub.com\u002Falpacahq\u002Falpaca-mcp-server\u002Fissues](https:\u002F\u002Fgithub.com\u002Falpacahq\u002Falpaca-mcp-server\u002Fissues)\nGitHub Pull requests: [https:\u002F\u002Fgithub.com\u002Falpacahq\u002Falpaca-mcp-server\u002Fpulls](https:\u002F\u002Fgithub.com\u002Falpacahq\u002Falpaca-mcp-server\u002Fpulls)\n\n### MCP Registry Metadata\n\nmcp-name: io.github.alpacahq\u002Falpaca-mcp-server","\u003Cp align=\"center\">\n  \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Falpacahq_alpaca-mcp-server_readme_cf3e0a78463e.png\" alt=\"Alpaca logo\" width=\"220\">\n\u003C\u002Fp>\n\n\u003Cdiv align=\"center\">\n\n\u003Ca href=\"https:\u002F\u002Fx.com\u002Falpacahq?lang=en\" target=\"_blank\">\u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FX-DCDCDC?logo=x&logoColor=000\" alt=\"X\">\u003C\u002Fa>\n\u003Ca href=\"https:\u002F\u002Fwww.reddit.com\u002Fr\u002Falpacamarkets\u002F\" target=\"_blank\">\u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FReddit-DCDCDC?logo=reddit&logoColor=000\" alt=\"Reddit\">\u003C\u002Fa>\n\u003Ca href=\"https:\u002F\u002Falpaca.markets\u002Fslack\" target=\"_blank\">\u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FSlack-DCDCDC?logo=slack&logoColor=000\" alt=\"Slack\">\u003C\u002Fa>\n\u003Ca href=\"https:\u002F\u002Fwww.linkedin.com\u002Fcompany\u002Falpacamarkets\u002F\" target=\"_blank\">\u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FLinkedIn-DCDCDC\" alt=\"LinkedIn\">\u003C\u002Fa>\n\u003Ca href=\"https:\u002F\u002Fforum.alpaca.markets\u002F\" target=\"_blank\">\u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FForum-DCDCDC?logo=discourse&logoColor=000\" alt=\"Forum\">\u003C\u002Fa>\n\u003Ca href=\"https:\u002F\u002Fdocs.alpaca.markets\u002Fdocs\u002Fgetting-started\" target=\"_blank\">\u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FDocs-DCDCDC\" alt=\"Docs\">\u003C\u002Fa>\n\u003Ca href=\"https:\u002F\u002Falpaca.markets\u002Fsdks\u002Fpython\u002F\" target=\"_blank\">\u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FPython_SDK-DCDCDC?logo=python&logoColor=000\" alt=\"Python SDK\">\u003C\u002Fa>\n\n\u003C\u002Fdiv>\n\n\u003Cp align=\"center\">\n  一款面向 Alpaca 交易 API 的综合模型上下文协议（MCP）服务器。通过 Claude、Cursor 和 VS Code 等 AI 助手，实现自然语言的交易操作。支持股票、期权、加密货币、投资组合管理以及实时市场数据。\n\u003C\u002Fp>\n\n> **Alpaca MCP 服务器 v2 已发布。** 此版本基于 FastMCP 和 OpenAPI 完全重写。如果您正在从 v1 升级，请阅读[升级指南](#upgrading-from-v1)——工具名称、参数和配置均已更改。\n\n## 目录\n\n- [从 V1 升级](#upgrading-from-v1)\n- [先决条件](#prerequisites)\n- [获取您的 API 密钥](#getting-your-api-keys)\n- [设置](#setup)\n- [配置](#configuration)\n- [功能](#features)\n- [示例提示](#example-prompts)\n- [可用工具](#available-tools)\n- [测试](#testing)\n- [项目结构](#project-structure)\n- [故障排除](#troubleshooting)\n- [披露](#disclosure)\n\n---\n\n## 从 V1 升级\n\nV2 是使用 FastMCP 和 OpenAPI 构建的**全新重写版本**。**V1 中的所有工具在 V2 中均不存在**——工具名称、参数和模式都已更改。如果您的设置依赖于特定的 V1 工具名称或参数，则无法将 V2 作为直接替代品。\n\n### 变化对比\n\n\n| 方面             | V1                                     | V2                                                                                           |\n| ------------------ | -------------------------------------- | -------------------------------------------------------------------------------------------- |\n| **工具名称**     | 手工定义（如 `get_account_info`）       | 基于规范派生并可覆盖（如 `get_account_info`——名称可能重复，但模式不同）                 |\n| **参数**         | 自定义模式                             | 与 Alpaca API 规范一致                                                                       |\n| **配置**         | `.env` 文件 + `init` 命令               | 仅通过 MCP 客户端配置中的环境变量进行配置                                                   |\n| **工具过滤**     | 不支持                                 | 使用 `ALPACA_TOOLSETS` 环境变量                                                              |\n| **白名单机制**   | 不支持                                 | 使用 `ALPACA_TOOLSETS` 来限制可用工具                                                        |\n\n\n### 如何避免在 V2 中沿用 V1 的用法\n\nMCP 客户端会动态地从服务器发现工具。不存在用于“白名单”工具名称的配置文件——客户端只会获取服务器暴露的工具列表。为避免您的客户端或 AI 助手错误地使用 V2：\n\n1. **请勿复用 V1 配置**——将 V2 视为全新的服务器。更新您的 MCP 客户端配置以使用新的命令和参数；移除任何基于 `.env` 或 `init` 的设置。\n2. **清除工具缓存**——切换后重启您的 MCP 客户端（Claude Desktop、Cursor、VS Code 等），以便它获取最新的工具列表，而不是继续使用过时的缓存。\n3. **开启新的聊天\u002F会话**——现有对话可能仍缓存着旧工具名称的引用。请开始一个新的聊天，让 LLM 能够看到当前的 V2 工具及其模式。\n4. **更新自定义指令和规则**——如果您有 Cursor 规则、Claude 指令或其他提及特定 V1 工具名称的提示（例如“使用 `get_account_info`”），请将其更新为匹配 V2 工具名称，或移除这些引用，让 LLM 根据上下文自行发现工具。\n5. **使用 `ALPACA_TOOLSETS` 限制工具**——如果您之前曾限制助手可用的功能，V2 支持通过 `ALPACA_TOOLSETS` 环境变量进行服务器端过滤。有关工具集列表，请参阅[配置 > 工具集过滤](#toolset-filtering)。\n\n### 总结\n\n请假设**与 V1 无向后兼容性**。为 V2 重新配置您的 MCP 客户端，重启它，并使用全新的会话。请查看[可用工具](#available-tools)部分以获取当前的工具列表。\n\n### 如果您有自定义的 V1 工作流\n\n如果您曾记录允许使用的工具、编写按名称调用工具的脚本，或围绕特定 V1 工具\u002F参数形状构建提示——请视这些内容为已过时。请使用下方列出的[可用工具](#available-tools)以及服务器公开的当前参数模式重新创建它们。\n\n### 继续使用 V1\n\n如果您需要继续使用 V1，请在您的 MCP 客户端配置中锁定到最后一个 V1 版本（例如：`uvx alpaca-mcp-server==1.x.x serve`）。V1 仍然可在 PyPI 上获取，供现有设置使用。\n\n---\n\n## 先决条件\n\n- **Python 3.10+**（[安装指南](https:\u002F\u002Fwww.python.org\u002Fdownloads\u002F)）\n- **uv**（[安装指南](https:\u002F\u002Fdocs.astral.sh\u002Fuv\u002Fgetting-started\u002Finstallation\u002F)）\n- **Alpaca 交易 API 密钥**（免费模拟交易账户）\n- **MCP 客户端**（Claude Desktop、Cursor、VS Code 等）\n\n## 获取您的 API 密钥\n\n1. 访问 [Alpaca 控制台](https:\u002F\u002Fapp.alpaca.markets\u002Fpaper\u002Fdashboard\u002Foverview)\n2. 创建一个免费的模拟交易账户\n3. 在控制台生成 API 密钥\n\n## 设置\n\n将服务器添加到您的 MCP 客户端配置中，然后重启客户端。无需 `init` 命令，也不再使用 `.env` 文件——凭据只需在**一处**设置即可。\n\n### Claude Desktop\n\n编辑 `~\u002FLibrary\u002FApplication Support\u002FClaude\u002Fclaude_desktop_config.json`（Mac）或 `%APPDATA%\\Claude\\claude_desktop_config.json`（Windows）：\n\n```json\n{\n  \"mcpServers\": {\n    \"alpaca\": {\n      \"command\": \"uvx\",\n      \"args\": [\"alpaca-mcp-server\"],\n      \"env\": {\n        \"ALPACA_API_KEY\": \"your_alpaca_api_key\",\n        \"ALPACA_SECRET_KEY\": \"your_alpaca_secret_key\"\n      }\n    }\n  }\n}\n```\n\n### Cursor\n\n只需点击几下即可从 [Cursor 目录](https:\u002F\u002Fcursor.directory\u002Fmcp\u002Falpaca) 安装，或将以下内容添加到 `~\u002F.cursor\u002Fmcp.json`：\n\n```json\n{\n  \"mcpServers\": {\n    \"alpaca\": {\n      \"command\": \"uvx\",\n      \"args\": [\"alpaca-mcp-server\"],\n      \"env\": {\n        \"ALPACA_API_KEY\": \"your_alpaca_api_key\",\n        \"ALPACA_SECRET_KEY\": \"your_alpaca_secret_key\"\n      }\n    }\n  }\n}\n```\n\n### VS Code\n\n在项目根目录下创建 `.vscode\u002Fmcp.json`。请参阅[官方文档](https:\u002F\u002Fcode.visualstudio.com\u002Fdocs\u002Fcopilot\u002Fchat\u002Fmcp-servers)。\n\n```json\n{\n  \"mcp\": {\n    \"servers\": {\n      \"alpaca\": {\n        \"type\": \"stdio\",\n        \"command\": \"uvx\",\n        \"args\": [\"alpaca-mcp-server\"],\n        \"env\": {\n          \"ALPACA_API_KEY\": \"your_alpaca_api_key\",\n          \"ALPACA_SECRET_KEY\": \"your_alpaca_secret_key\"\n        }\n      }\n    }\n  }\n}\n```\n\n**PyCharm**\n\n请参阅[官方指南](https:\u002F\u002Fwww.jetbrains.com\u002Fhelp\u002Fai-assistant\u002Fconfigure-an-mcp-server.html)。\n\n1. 转到 文件 → 设置 → 工具 → 模型上下文协议 (MCP)\n2. 添加新服务器：\n   - **类型**: stdio\n   - **命令**: uvx\n   - **参数**: alpaca-mcp-server\n3. 设置环境变量：\n   ```\n   ALPACA_API_KEY=your_alpaca_api_key\n   ALPACA_SECRET_KEY=your_alpaca_secret_key\n   ```\n\n**Claude Code**\n\n```bash\nclaude mcp add alpaca --scope user --transport stdio uvx alpaca-mcp-server \\\n  --env ALPACA_API_KEY=your_alpaca_api_key \\\n  --env ALPACA_SECRET_KEY=your_alpaca_secret_key\n```\n\n通过 Claude Code CLI 中的 `\u002Fmcp` 命令进行验证。\n\n**Gemini CLI**\n\n请参阅[Gemini CLI 的 MCP 文档](https:\u002F\u002Fgithub.com\u002Fgoogle-gemini\u002Fgemini-cli\u002Fblob\u002Fmain\u002Fdocs\u002Ftools\u002Fmcp-server.md)。\n\n将以下内容添加到你的 `settings.json`：\n\n```json\n{\n  \"mcpServers\": {\n    \"alpaca\": {\n      \"type\": \"stdio\",\n      \"command\": \"uvx\",\n      \"args\": [\"alpaca-mcp-server\"],\n      \"env\": {\n        \"ALPACA_API_KEY\": \"your_alpaca_api_key\",\n        \"ALPACA_SECRET_KEY\": \"your_alpaca_secret_key\"\n      }\n    }\n  }\n}\n```\n\n**Docker**\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Falpacahq\u002Falpaca-mcp-server.git\ncd alpaca-mcp-server\ndocker build -t mcp\u002Falpaca:latest .\n```\n\n将以下内容添加到你的 MCP 客户端配置中：\n\n```json\n{\n  \"mcpServers\": {\n    \"alpaca\": {\n      \"command\": \"docker\",\n      \"args\": [\n        \"run\", \"--rm\", \"-i\",\n        \"-e\", \"ALPACA_API_KEY=your_key\",\n        \"-e\", \"ALPACA_SECRET_KEY=your_secret\",\n        \"-e\", \"ALPACA_PAPER_TRADE=true\",\n        \"mcp\u002Falpaca:latest\"\n      ]\n    }\n  }\n}\n```\n\n## 配置\n\n所有配置均通过 MCP 客户端配置中的环境变量进行设置，不会向磁盘写入任何文件。\n\n\n| 变量             | 必需 | 默认值 | 描述                                |\n| ---------------- | ---- | ------ | ----------------------------------- |\n| `ALPACA_API_KEY` | 是   | —      | 你的 Alpaca API 密钥                |\n| `ALPACA_SECRET_KEY` | 是   | —      | 你的 Alpaca 秘密密钥                |\n| `ALPACA_PAPER_TRADE` | 否   | `true` | 设置为 `false` 以进行实盘交易     |\n| `ALPACA_TOOLSETS` | 否   | all    | 用逗号分隔的要启用的工具集列表     |\n\n\n### 切换到实盘交易\n\n更新 MCP 客户端配置中的 `env` 块并重启：\n\n```json\n{\n  \"env\": {\n    \"ALPACA_API_KEY\": \"your_live_api_key\",\n    \"ALPACA_SECRET_KEY\": \"your_live_secret_key\",\n    \"ALPACA_PAPER_TRADE\": \"false\"\n  }\n}\n```\n\n### 工具集过滤\n\n默认情况下，所有工具都已启用。若要限制服务器仅使用特定工具集，请设置 `ALPACA_TOOLSETS`：\n\n```json\n{\n  \"env\": {\n    \"ALPACA_API_KEY\": \"...\",\n    \"ALPACA_SECRET_KEY\": \"...\",\n    \"ALPACA_TOOLSETS\": \"stock-data,crypto-data\"\n  }\n}\n```\n\n可用工具集如下：\n\n\n| 工具集             | 描述                                                   |\n| ------------------- | ----------------------------------------------------- |\n| `account`           | 账户信息、配置、投资组合历史、活动                   |\n| `trading`           | 订单、持仓、期权行权                                 |\n| `watchlists`        | 关注列表的增删改查操作                               |\n| `assets`            | 资产查询、期权合约、日历、市场时钟                   |\n| `stock-data`        | 股票K线、报价、成交、快照、筛选器                     |\n| `crypto-data`       | 加密货币K线、报价、成交、快照、订单簿                 |\n| `options-data`      | 期权K线、报价、成交、快照、链、交易所代码             |\n| `corporate-actions` | 公司公告                                             |\n\n\n## 功能\n\n- **市场数据** — 实时股票、加密货币和期权的报价、成交及K线。灵活时间框架的历史数据。期权希腊字母及隐含波动率。\n- **账户管理** — 查看余额、可买金额、账户状态及投资组合历史。\n- **订单管理** — 下达市价单、限价单、止损单、止损限价单及追踪止损单，适用于股票、加密货币和期权。可单独或批量取消订单。\n- **期权交易** — 按到期日\u002F执行价\u002F类型搜索合约。可构建单腿或多腿策略。获取最新报价、希腊字母及隐含波动率。\n- **加密货币交易** — 市价单、限价单及止损限价单，支持GTC\u002FIOC指令。可按数量或名义价值下单。\n- **头寸管理** — 查看、平仓或清算头寸。行使期权合约。\n- **市场状态** — 市场开盘\u002F收盘时间、日历、公司公告。\n- **关注列表** — 创建、更新和管理关注列表。\n- **资产搜索** — 查询股票、ETF、加密货币和期权的详细信息，并支持筛选。\n\n## 示例提示\n\n**基础交易**\n\n1. 我在Alpaca上的当前账户余额和可买金额是多少？\n2. 展示我在Alpaca账户中的当前持仓。\n3. 以市价买入5股AAPL。\n4. 以限价300美元卖出5股TSLA。\n5. 取消所有未成交的股票订单。\n6. 取消ID为abc123的订单。\n7. 清空我在GOOGL上的全部头寸。\n8. 平掉我在NVDA上10%的仓位。\n9. 下单以450美元的价格买入100股MSFT的限价单。\n10. 下单以市价卖出25股META。\n\n**加密货币交易**\n\n1. 下单以市价买入0.01枚ETH\u002FUSD。\n2. 下单以11万美元的价格卖出0.01枚BTC\u002FUSD的限价单。\n\n**期权交易**\n\n1. 展示AAPL下月到期的可用期权合约。\n2. 获取AAPL250613C00200000期权的最新报价。\n3. 检索SPY250627P00400000期权的快照信息。\n4. 清空我持有的下周到期的2份QQQ看涨期权合约。\n5. 下单以市价买入一份下周五到期的AAPL看涨期权。\n6. TSLA250620P00500000期权的希腊字母指标是什么？\n7. 查找行权价在当前市场价格上下5%范围内的TSLA期权合约。\n8. 获取2025年6月16日当周到期、行权价在市场价格上下10%范围内的SPY看涨期权。\n9. 使用AAPL6月6日到期的期权构建牛市看涨价差策略：一份行权价为190.00，另一份行权价为200.00。\n10. 行使我的NVDA看涨期权合约NVDA250919C001680。\n\n**市场信息**\n\n> 若要获取最新的15分钟行情数据，您需要订阅[Algo Trader Plus计划](https:\u002F\u002Falpaca.markets\u002Fdata)。\n>\n> 1. 今天市场的开盘和收盘时间分别是几点？\n> 2. 展示下周的市场日历。\n> 3. 展示过去3个月内AAPL、MSFT和GOOGL的现金分红及股票拆分情况。\n> 4. 获取SPY在过去一年内发生的所有公司行为，包括分红、拆股及任何并购事件。\n> 5. SPY未来6个月内计划进行的公司行为有哪些？\n\n**历史与实时数据**\n\n1. 展示AAPL最近5个交易日的日线价格走势。\n2. TSLA昨日的收盘价是多少？\n3. 获取GOOGL的最新K线。\n4. NVDA的最新成交价是多少？\n5. 展示MSFT的最新报价。\n6. 检索AMD最近100笔成交记录。\n7. 展示AMZN过去2小时内的1分钟K线。\n8. 获取TSLA上周二至上周五的5分钟盘中K线。\n9. 获取AAPL的综合股票快照，将最新报价、最新成交、1分钟K线、日线以及前一日日线整合到一个视图中。\n10. 对比TSLA、NVDA和MSFT的市场快照，分析它们当前的买卖价差、最新成交价及当日表现。\n\n**订单**\n\n1. 展示我本周所有未成交及已成交的订单。\n2. 我有哪些关于AAPL的订单？\n3. 列出我过去3天内下达的所有限价单。\n4. 按订单状态筛选：仅显示已成交的订单。\n5. 获取昨天的订单历史。\n\n**自选列表**\n\n> 目前，您只能通过Alpaca的交易API来查看和更新通过该API创建的交易自选列表。\n>\n> 1. 创建一个名为“科技股”的新自选列表，包含AAPL、MSFT和NVDA。\n2. 更新我的“科技股”自选列表，加入TSLA和AMZN。\n3. 我的“分红精选”自选列表里都有哪些股票？\n4. 从我的“成长型投资组合”自选列表中移除META。\n5. 列出我现有的所有自选列表。\n\n**资产信息**\n\n1. 搜索关于‘AAPL’资产的详细信息。\n2. 展示按交易量排名前5位的可交易加密货币资产。\n3. 获取所有纳斯达克上市的美国股票资产，并筛选出其中可交易的证券。\n\n**综合场景**\n\n1. 获取今日的市场时钟，并在我以340美元的限价买入TSLA之前，展示我的可买金额。\n2. 使用SPY7月3日到期的期权构建牛市看涨价差策略：一份卖出价比当前SPY价格高5%，另一份买入价比当前价格低3%。\n\n## 可用工具\n\n**账户与投资组合**\n\n- `get_account_info` — 账户余额、保证金及账户状态\n- `get_account_config` — 交易限制、保证金设置、PDT检查\n- `update_account_config` — 更新账户配置设置\n- `get_portfolio_history` — 投资组合权益及盈亏随时间的变化\n- `get_account_activities` — 成交记录、股息、资金划转\n- `get_account_activities_by_type` — 按类型筛选的账户活动\n\n**交易（订单）**\n\n- `get_orders` — 带过滤条件的订单列表\n- `get_order_by_id` — 根据订单ID获取单个订单\n- `get_order_by_client_id` — 根据客户订单ID获取单个订单\n- `replace_order_by_id` — 替换现有未成交订单\n- `cancel_order_by_id` — 取消指定订单\n- `cancel_all_orders` — 取消所有未成交订单\n- `place_stock_order` — 股票\u002FETF（市价、限价、止损、止损限价、追踪止损、括号单）\n- `place_crypto_order` — 加密货币（市价、限价、止损限价）\n- `place_option_order` — 期权（单腿或多腿）\n\n**持仓**\n\n- `get_all_positions` — 当前所有持仓\n- `get_open_position` — 特定持仓的详细信息\n- `close_position` — 平仓特定持仓\n- `close_all_positions` — 清空整个投资组合\n- `exercise_options_position` — 行权持有的期权合约\n- `do_not_exercise_options_position` — 不行权指令\n\n**自选列表**\n\n- `create_watchlist` — 创建新的自选列表\n- `get_watchlists` — 列出所有自选列表\n- `get_watchlist_by_id` — 获取特定自选列表\n- `update_watchlist_by_id` — 更新自选列表\n- `delete_watchlist_by_id` — 删除自选列表\n- `add_asset_to_watchlist_by_id` — 向自选列表添加资产\n- `remove_asset_from_watchlist_by_id` — 从自选列表移除资产\n\n**资产与市场信息**\n\n- `get_all_assets` — 列出资产，可选过滤\n- `get_asset` — 特定资产的详细信息\n- `get_option_contracts` — 标的证券的期权合约\n- `get_option_contract` — 根据标的或ID获取单个期权合约\n- `get_calendar` — 指定日期范围内的市场日历\n- `get_clock` — 当前市场状态及下一交易时段的开收盘时间\n- `get_corporate_action_announcements` — 公司行为公告\n- `get_corporate_action_announcement` — 根据ID获取单个公告\n\n**股票数据**\n\n- `get_stock_bars` — 历史OHLCV分时数据\n- `get_stock_quotes` — 历史买卖盘报价\n- `get_stock_trades` — 历史成交记录\n- `get_stock_latest_bar` — 最新一分钟K线\n- `get_stock_latest_quote` — 最新报价\n- `get_stock_latest_trade` — 最新成交\n- `get_stock_snapshot` — 综合快照\n- `get_most_active_stocks` — 按成交量\u002F成交次数最活跃的股票\n- `get_market_movers` — 涨幅最大和跌幅最大的股票\n\n**加密货币数据**\n\n- `get_crypto_bars` — 历史OHLCV分时数据\n- `get_crypto_quotes` — 历史报价\n- `get_crypto_trades` — 历史成交记录\n- `get_crypto_latest_bar` — 最新一分钟K线\n- `get_crypto_latest_quote` — 最新报价\n- `get_crypto_latest_trade` — 最新成交\n- `get_crypto_snapshot` — 综合快照\n- `get_crypto_latest_orderbook` — 最新委托簿\n\n**期权数据**\n\n- `get_option_bars` — 历史OHLCV分时数据\n- `get_option_trades` — 历史成交记录\n- `get_option_latest_trade` — 最新成交\n- `get_option_latest_quote` — 包含买卖盘及交易所信息的最新报价\n- `get_option_snapshot` — 包含希腊字母及隐含波动率的快照\n- `get_option_chain` — 标的证券的完整期权链\n- `get_option_exchange_codes` — 交易所代码与名称的映射\n\n**公司行为**\n\n- `get_corporate_actions` — 从市场数据中获取公司行为公告\n\n## 测试\n\n该项目包含多层测试套件，在每次拉取请求时都会在CI中运行：\n\n- **完整性测试** — 验证OpenAPI规范、工具集定义以及工具名称\u002F描述覆盖之间的一致性。无需网络或凭证。\n- **服务器构建测试** — 使用模拟凭证构建服务器，并验证暴露的工具数量是否正确。无需网络。\n- **纸面API集成测试** — 对Alpaca纸面交易API执行真实调用，涵盖账户信息、市场数据、订单生命周期、自选列表、持仓等。需要`ALPACA_API_KEY`和`ALPACA_SECRET_KEY`。\n\n本地运行完整测试套件：\n\n```bash\n# 核心测试（无需凭证）\npytest tests\u002Ftest_integrity.py tests\u002Ftest_server_construction.py -v\n\n# 集成测试（需要纸面API密钥）\nALPACA_API_KEY=... ALPACA_SECRET_KEY=... pytest tests\u002F -m integration -v\n```\n\n## 项目结构\n\n```\nalpaca-mcp-server\u002F\n├── src\u002F\n│   └── alpaca_mcp_server\u002F\n│       ├── __init__.py\n│       ├── cli.py            ← CLI入口点\n│       ├── server.py         ← 基于OpenAPI规范构建的FastMCP服务器\n│       ├── names.py          ← 工具名称和描述覆盖\n│       ├── toolsets.py       ← 工具集→operationId白名单\n│       ├── overrides.py      ← 用于复杂交易端点的手工工具\n│       ├── market_data_overrides.py ← 用于历史数据的手工工具\n│       └── specs\u002F\n│           ├── trading-api.json\n│           └── market-data-api.json\n├── tests\u002F\n│   ├── conftest.py           ← 共享fixture及纸面账户清理\n│   ├── test_integrity.py     ← 规范↔工具集↔名称一致性检查\n│   ├── test_server_construction.py ← 服务器构建验证\n│   └── test_paper_integration.py   ← 纸面API集成测试\n├── scripts\u002F\n│   └── sync-specs.sh        ← 下载最新OpenAPI规范\n├── .github\u002F\n│   └── workflows\u002F\n│       └── ci.yml            ← CI流水线（核心+集成）\n├── AGENTS.md                 ← 编程代理使用说明\n├── pyproject.toml\n└── README.md\n```\n\n## 故障排除\n\n- **找不到uv\u002Fuvx**：按照官方指南安装uv（[https:\u002F\u002Fdocs.astral.sh\u002Fuv\u002Fgetting-started\u002Finstallation\u002F](https:\u002F\u002Fdocs.astral.sh\u002Fuv\u002Fgetting-started\u002Finstallation\u002F)），然后重启终端，使`uv`\u002F`uvx`位于PATH中。\n- **缺少凭证**：在客户端的`env`块中设置`ALPACA_API_KEY`和`ALPACA_SECRET_KEY`。纸面模式默认为`ALPACA_PAPER_TRADE = True`。\n- **客户端未加载新配置**：更改后请重启客户端（Cursor、Claude Desktop、VS Code）。\n- **HTTP端口冲突**：如果使用`--transport streamable-http`，请将`--port`更改为未被占用的端口。\n\n## 公告\n\n我们MCP服务器及连接的AI智能体生成的洞察仅供教育和信息参考之用，不应被视为投资建议。Alpaca不推荐任何特定的证券或投资策略。请在做出任何决策前自行进行尽职调查。所有提及的公司均独立运营，彼此之间不承担连带责任。\n\n由于期权交易本身具有高风险，可能导致重大损失，因此并不适合所有投资者。在投资期权之前，请务必阅读《标准化期权的特点与风险》（[期权披露文件](https:\u002F\u002Fwww.theocc.com\u002Fcompany-information\u002Fdocuments-and-archives\u002Foptions-disclosure-document?ref=alpaca.markets)）。\n\nAlpaca不会编制、编辑、认可或批准第三方内容。Alpaca不保证第三方内容的准确性、时效性、完整性或实用性，且不对第三方网站上或通过其提供的任何内容、广告、产品或其他材料负责或承担法律责任。\n\n所有投资均存在风险，证券或金融产品的过往表现并不能保证未来的结果或收益。没有任何投资策略能够确保实现其目标。请注意，分散投资并不能保证盈利，也不能避免亏损。投资于证券或其他金融产品时，始终存在资金损失的可能性。投资者在投资前应仔细考虑自身的投资目标和风险。\n\n本算法的计算基于历史和实时市场数据，但可能无法涵盖所有市场因素，包括价格的突然波动、流动性限制或执行延迟等。模型假设，如波动率估算和股息处理方式，可能会影响其性能和准确性。由该算法生成的交易将受到经纪商执行流程、市场流动性、订单优先级以及时间延迟等因素的影响。这些因素可能导致实际成交价格或时间与预期出现偏差。用户有责任监控算法活动并充分了解相关风险。Alpaca对因使用本系统而产生的任何损失不承担任何责任。\n\n过去的模拟回测结果并不保证未来的回报，实际结果可能会与分析结果有所不同。\n\n纸面交易API由AlpacaDB, Inc.提供，无需真实资金，也不允许用户在市场上进行真实的证券交易。提供纸面交易API并不构成购买或出售任何证券、证券衍生品或期货产品，或任何形式的交易或投资建议、推荐或策略的要约或招揽；此类要约或招揽既未由AlpacaDB, Inc.或其任何关联公司提出，也未以任何方式得到其认可。通过纸面交易API所提供的信息，在AlpacaDB, Inc.或其任何关联公司（统称“Alpaca”）未获授权开展业务的司法管辖区内，均不构成任何形式的要约或招揽。\n\n证券经纪服务由Alpaca Securities LLC（“Alpaca Securities”）提供，该公司是[FINRA](https:\u002F\u002Fwww.finra.org\u002F)和[SIPC](https:\u002F\u002Fwww.sipc.org\u002F)的成员，为AlpacaDB, Inc.的全资子公司。技术和相关服务则由AlpacaDB, Inc.提供。\n\n加密货币服务由Alpaca Crypto LLC（“Alpaca Crypto”）提供，这是一家经FinCEN注册的资金服务企业（NMLS # 2160858），也是AlpacaDB, Inc.的全资子公司。Alpaca Crypto并非SIPC或FINRA的成员。加密货币不同于股票，您的加密货币投资不受FDIC或SIPC的保护。加密货币资产波动性极高，具有高度投机性，存在较大的亏损风险，且不受FDIC或其他政府机构的保险保障。客户在使用这些服务前，应充分了解各种风险，包括本金损失、网络安全问题、监管动态以及数字资产技术的不断演变等。有关加密货币风险的更多信息，请点击[此处](https:\u002F\u002Ffiles.alpaca.markets\u002Fdisclosures\u002Flibrary\u002FCryptoRiskDisclosures.pdf)。\n\n在Alpaca Securities或Alpaca Crypto尚未注册或获得许可的司法管辖区内，本内容不构成购买或出售证券或加密货币，或开设经纪账户或加密货币账户的要约、招揽或建议。\n\n## 隐私政策\n\n有关Alpaca如何处理您的数据的信息，请参阅：\n\n- [隐私政策](https:\u002F\u002Fs3.amazonaws.com\u002Ffiles.alpaca.markets\u002Fdisclosures\u002FPrivacyPolicy.pdf)\n- [披露资料库](https:\u002F\u002Falpaca.markets\u002Fdisclosures)\n\n### 数据收集\n\n- **收集的内容**：用于API调用的用户代理字符串（‘ALPACA-MCP-SERVER’）\n- **用途**：用于识别MCP服务器的使用情况并改善用户体验\n- **第三方共享**：不会与第三方共享\n- **保留期限**：按照Alpaca的标准数据保留政策进行保留\n- **退出机制**：可通过修改“.github\u002Fcore\u002Fuser_agent_mixin.py”中的‘USER_AGENT’常量，或将‘UserAgentMixin’从客户端类定义中移除来退出\n\n## 安全须知\n\n本服务器可以执行真实交易并访问您的投资组合。请将您的API密钥视为敏感凭证。请仔细审查LLM提出的各项操作建议，尤其是涉及复杂期权策略或多腿交易时。\n\n**HTTP传输安全**：在使用HTTP传输时，服务器默认绑定到本地主机（127.0.0.1:8000）以确保安全性。如需远程访问，您可以使用`--host 0.0.0.0`将服务器绑定到所有网络接口，或通过SSH隧道（`ssh -L 8000:localhost:8000 user@server`）进行连接，亦或设置带有身份验证的反向代理以实现安全访问。\n\n## 支持\n\n如遇问题或疑问，请通过[support@alpaca.markets](mailto:support@alpaca.markets)与我们联系。\n\nGitHub问题：[https:\u002F\u002Fgithub.com\u002Falpacahq\u002Falpaca-mcp-server\u002Fissues](https:\u002F\u002Fgithub.com\u002Falpacahq\u002Falpaca-mcp-server\u002Fissues)  \nGitHub拉取请求：[https:\u002F\u002Fgithub.com\u002Falpacahq\u002Falpaca-mcp-server\u002Fpulls](https:\u002F\u002Fgithub.com\u002Falpacahq\u002Falpaca-mcp-server\u002Fpulls)\n\n### MCP注册表元数据\n\nmcp名称：io.github.alpacahq\u002Falpaca-mcp-server","# Alpaca MCP Server 快速上手指南\n\nAlpaca MCP Server 是一个基于模型上下文协议（MCP）的服务端工具，允许你通过 AI 助手（如 Claude、Cursor、VS Code Copilot 等）使用自然语言进行股票、期权、加密货币的交易操作及市场数据查询。\n\n> **注意**：本文档针对 **v2 版本**。v2 是完全重构版，与 v1 不兼容（工具名称、参数及配置方式均已变更）。如果你正在从 v1 升级，请视为全新安装并清除旧的缓存配置。\n\n## 环境准备\n\n在开始之前，请确保你的开发环境满足以下要求：\n\n*   **操作系统**：macOS, Windows, 或 Linux\n*   **Python**：版本 3.10 或更高 ([下载链接](https:\u002F\u002Fwww.python.org\u002Fdownloads\u002F))\n*   **uv 包管理器**：推荐使用的快速 Python 包管理工具 ([安装指南](https:\u002F\u002Fdocs.astral.sh\u002Fuv\u002Fgetting-started\u002Finstallation\u002F))\n    *   安装命令 (macOS\u002FLinux): `curl -LsSf https:\u002F\u002Fastral.sh\u002Fuv\u002Finstall.sh | sh`\n    *   安装命令 (Windows PowerShell): `powershell -c \"irm https:\u002F\u002Fastral.sh\u002Fuv\u002Finstall.ps1 | iex\"`\n*   **Alpaca 账户**：需要拥有 Alpaca Trading API 密钥（免费模拟交易账户即可）。\n*   **MCP 客户端**：已安装支持 MCP 的 AI 编辑器或终端，例如：\n    *   Claude Desktop\n    *   Cursor\n    *   VS Code (需安装相关 MCP 扩展)\n    *   JetBrains IDEs (PyCharm 等)\n\n## 获取 API 密钥\n\n1.  访问 [Alpaca Dashboard](https:\u002F\u002Fapp.alpaca.markets\u002Fpaper\u002Fdashboard\u002Foverview)。\n2.  注册并创建一个免费的**模拟交易账户 (Paper Trading Account)**。\n3.  在仪表盘中生成你的 `API Key` 和 `Secret Key`。\n\n## 安装与配置\n\nAlpaca MCP Server v2 无需复杂的初始化命令或 `.env` 文件，所有配置直接写在 MCP 客户端的配置文件中。\n\n### 1. Claude Desktop\n\n编辑配置文件：\n*   **macOS**: `~\u002FLibrary\u002FApplication Support\u002FClaude\u002Fclaude_desktop_config.json`\n*   **Windows**: `%APPDATA%\\Claude\\claude_desktop_config.json`\n\n添加以下内容：\n\n```json\n{\n  \"mcpServers\": {\n    \"alpaca\": {\n      \"command\": \"uvx\",\n      \"args\": [\"alpaca-mcp-server\"],\n      \"env\": {\n        \"ALPACA_API_KEY\": \"你的_ALPACA_API_KEY\",\n        \"ALPACA_SECRET_KEY\": \"你的_ALPACA_SECRET_KEY\",\n        \"ALPACA_PAPER_TRADE\": \"true\"\n      }\n    }\n  }\n}\n```\n\n### 2. Cursor\n\n编辑 `~\u002F.cursor\u002Fmcp.json` 或在 Cursor 设置中直接添加：\n\n```json\n{\n  \"mcpServers\": {\n    \"alpaca\": {\n      \"command\": \"uvx\",\n      \"args\": [\"alpaca-mcp-server\"],\n      \"env\": {\n        \"ALPACA_API_KEY\": \"你的_ALPACA_API_KEY\",\n        \"ALPACA_SECRET_KEY\": \"你的_ALPACA_SECRET_KEY\",\n        \"ALPACA_PAPER_TRADE\": \"true\"\n      }\n    }\n  }\n}\n```\n\n### 3. VS Code\n\n在项目根目录创建 `.vscode\u002Fmcp.json` 文件：\n\n```json\n{\n  \"mcp\": {\n    \"servers\": {\n      \"alpaca\": {\n        \"type\": \"stdio\",\n        \"command\": \"uvx\",\n        \"args\": [\"alpaca-mcp-server\"],\n        \"env\": {\n          \"ALPACA_API_KEY\": \"你的_ALPACA_API_KEY\",\n          \"ALPACA_SECRET_KEY\": \"你的_ALPACA_SECRET_KEY\",\n          \"ALPACA_PAPER_TRADE\": \"true\"\n        }\n      }\n    }\n  }\n}\n```\n\n### 4. 其他客户端简要配置\n\n*   **PyCharm**: 进入 `File` → `Settings` → `Tools` → `Model Context Protocol (MCP)`，新建服务器，类型选 `stdio`，命令填 `uvx`，参数填 `alpaca-mcp-server`，并在环境变量中添加 Key。\n*   **Claude Code (CLI)**:\n    ```bash\n    claude mcp add alpaca --scope user --transport stdio uvx alpaca-mcp-server \\\n      --env ALPACA_API_KEY=你的_ALPACA_API_KEY \\\n      --env ALPACA_SECRET_KEY=你的_ALPACA_SECRET_KEY\n    ```\n*   **Docker**:\n    ```json\n    {\n      \"mcpServers\": {\n        \"alpaca\": {\n          \"command\": \"docker\",\n          \"args\": [\n            \"run\", \"--rm\", \"-i\",\n            \"-e\", \"ALPACA_API_KEY=你的_KEY\",\n            \"-e\", \"ALPACA_SECRET_KEY=你的_SECRET\",\n            \"-e\", \"ALPACA_PAPER_TRADE=true\",\n            \"mcp\u002Falpaca:latest\"\n          ]\n        }\n      }\n    }\n    ```\n\n## 基本使用\n\n配置完成后，**重启你的 MCP 客户端**（关闭并重新打开编辑器或对话窗口），以确保加载最新的工具列表。\n\n### 开启实盘交易（可选）\n默认情况下，服务器运行在**模拟交易模式** (`ALPACA_PAPER_TRADE: true`)。若需进行真实资金交易，请将配置中的该值改为 `\"false\"` 并使用实盘 API 密钥：\n\n```json\n\"env\": {\n  \"ALPACA_API_KEY\": \"你的实盘_API_KEY\",\n  \"ALPACA_SECRET_KEY\": \"你的实盘_SECRET_KEY\",\n  \"ALPACA_PAPER_TRADE\": \"false\"\n}\n```\n\n### 功能示例\n\n在 AI 聊天窗口中，你可以直接使用自然语言下达指令：\n\n**1. 查询账户状态**\n> \"帮我查看当前的账户余额和购买力。\"\n> \"显示我目前的持仓情况。\"\n\n**2. 获取市场数据**\n> \"查询苹果公司 (AAPL) 今天的股价走势和最新报价。\"\n> \"给我看看比特币 (BTCUSD) 最近的交易量数据。\"\n\n**3. 执行交易操作**\n> \"以市价买入 10 股特斯拉 (TSLA)。\"\n> \"为微软 (MSFT) 设置一个限价买单，价格为 400 美元，数量 5 股。\"\n> \"平仓我所有的亚马逊 (AMZN) 持仓。\"\n\n**4. 期权与高级功能**\n> \"查找下个月到期的苹果看涨期权合约。\"\n> \"列出我所有的观察列表。\"\n\n### 限制工具范围（可选）\n\n如果你只想让 AI 访问特定功能（例如只读数据，不允许交易），可以在配置中添加 `ALPACA_TOOLSETS` 环境变量：\n\n```json\n\"env\": {\n  \"ALPACA_API_KEY\": \"...\",\n  \"ALPACA_SECRET_KEY\": \"...\",\n  \"ALPACA_TOOLSETS\": \"stock-data,crypto-data,account\"\n}\n```\n可用工具集包括：`account`, `trading`, `watchlists`, `assets`, `stock-data`, `crypto-data`, `options-data`, `corporate-actions`。","量化分析师小李正在 IDE 中调试一个基于动量因子的自动交易策略，需要频繁验证实时行情并执行模拟下单。\n\n### 没有 alpaca-mcp-server 时\n- **上下文频繁切换**：小李必须在代码编辑器、浏览器行情网页和交易终端之间来回跳转，打断编程心流。\n- **数据获取繁琐**：为了测试策略，需手动编写复杂的 Python 脚本调用 REST API 来获取历史 K 线和账户持仓，调试耗时。\n- **操作门槛高**：执行简单的“买入 10 股特斯拉”指令，也需要查阅 SDK 文档确认参数格式，容易因手误导致下单失败。\n- **策略迭代缓慢**：每次调整策略逻辑后，无法立即用自然语言询问 AI 助手进行回测分析，必须重新运行整个笔记本环境。\n\n### 使用 alpaca-mcp-server 后\n- **沉浸式开发体验**：小李直接在 Cursor 或 VS Code 的聊天窗口中，用自然语言即可完成从查询行情到下单的全流程，无需离开编辑器。\n- **即时数据洞察**：只需输入“显示过去一个月 AAPL 的波动率”，alpaca-mcp-server 即刻调用 API 返回结构化数据供 AI 分析，零代码编写。\n- **自然语言交易**：直接命令“以市价买入 10 股 TSLA\"，工具自动解析意图并安全执行，大幅降低操作错误率。\n- **敏捷策略验证**：调整因子参数后，立即让 AI 基于实时数据评估策略表现，将原本数小时的验证周期缩短至几分钟。\n\nalpaca-mcp-server 通过将交易能力无缝嵌入开发环境，让开发者能用最自然的语言实现“所想即所得”的量化交易闭环。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Falpacahq_alpaca-mcp-server_cf3e0a78.png","alpacahq","Alpaca","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Falpacahq_b2484d28.png","Alpaca builds high performance APIs for Stock and Crypto Trading",null,"info@alpaca.markets","AlpacaHQ","https:\u002F\u002Falpaca.markets\u002F","https:\u002F\u002Fgithub.com\u002Falpacahq",[86,90,94,98],{"name":87,"color":88,"percentage":89},"Python","#3572A5",96.8,{"name":91,"color":92,"percentage":93},"Go Template","#00ADD8",2.1,{"name":95,"color":96,"percentage":97},"Dockerfile","#384d54",0.8,{"name":99,"color":100,"percentage":101},"Shell","#89e051",0.4,604,188,"2026-04-05T10:56:43","MIT","Linux, macOS, Windows","未说明",{"notes":109,"python":110,"dependencies":111},"该工具是一个 MCP 服务器，需配合 MCP 客户端（如 Claude Desktop、Cursor、VS Code 等）使用。运行前需安装 'uv' 包管理器并获取 Alpaca 交易 API 密钥。支持通过 Docker 部署。配置通过环境变量在客户端中设置，无需本地 .env 文件。默认开启模拟交易（Paper Trading），实盘交易需修改配置。","3.10+",[112,113,114],"uv","FastMCP","OpenAPI",[16],[117,118,119,120,121,122,123,124,125,126],"ai-trading","algorithmic-trading","mcp","mcp-server","options","stocks","trading","trading-api","crypto","etfs","2026-03-27T02:49:30.150509","2026-04-06T07:14:57.158927",[130,135,140,145,150,155,160],{"id":131,"question_zh":132,"answer_zh":133,"source_url":134},17613,"如何在 VS Code 中配置 alpaca-mcp-server，特别是当使用虚拟环境时？","在 VS Code 的 settings.json 中配置 MCP 服务器时，如果使用了虚拟环境，必须先在命令中激活该环境。配置示例如下：\n{\n  \"mcp\": {\n    \"servers\": {\n      \"alpaca\": {\n        \"type\": \"stdio\",\n        \"command\": \"bash\",\n        \"args\": [\"-c\", \"cd \u002F你的\u002F项目\u002F路径 && source .\u002F.venv\u002Fbin\u002Factivate && python alpaca_mcp_server.py\"],\n        \"env\": {\n          \"ALPACA_API_KEY\": \"...你的 API 密钥...\",\n          \"ALPACA_SECRET_KEY\": \"...你的密钥...\"\n        }\n      }\n    }\n  }\n}\n关键点是通过 bash -c 执行一串命令，先切换目录，再 source 激活脚本，最后运行 Python 脚本。","https:\u002F\u002Fgithub.com\u002Falpacahq\u002Falpaca-mcp-server\u002Fissues\u002F10",{"id":136,"question_zh":137,"answer_zh":138,"source_url":139},17614,"运行时报错 'ModuleNotFoundError: No module named alpaca' 或 'Alpaca is not installed' 如何解决？","这通常是因为安装了错误的包。你需要安装 `alpaca-py` SDK 而不是名为 `alpaca` 的包。\n解决步骤：\n1. 卸载错误的包：pip uninstall alpaca\n2. 进入项目目录，创建并激活虚拟环境（推荐使用 uv 或 venv）。\n3. 安装依赖：pip install -r requirements.txt（这将安装正确的 alpaca-py）。\n4. 验证安装：python -c \"from alpaca.common.enums import SupportedCurrencies; print('OK')\"","https:\u002F\u002Fgithub.com\u002Falpacahq\u002Falpaca-mcp-server\u002Fissues\u002F19",{"id":141,"question_zh":142,"answer_zh":143,"source_url":144},17615,"Cursor 显示 \"no tool or prompts\"（没有工具或提示）怎么办？","这通常是因为 AI 不知道项目文件的路径。确保你的交易算法代码引用了 `alpaca_mcp_server.py`。\n如果你的项目文件夹不在 `alpaca-mcp-server` 目录下，你必须在提示词中明确告知 AI 项目结构和文件路径（例如：“在路径 ***** 中使用 Alpaca MCP”）。否则，AI 会默认文件在同一文件夹下从而找不到工具。","https:\u002F\u002Fgithub.com\u002Falpacahq\u002Falpaca-mcp-server\u002Fissues\u002F20",{"id":146,"question_zh":147,"answer_zh":148,"source_url":149},17616,"在 PyCharm 中添加 alpaca-mcp-server 后，MCP 无法上线或立即停止怎么办？","这是由于日志级别冲突导致的。维护者已更新代码以自动检测 PyCharm 环境并调整日志。\n如果你遇到此问题，请确保升级到最新版本。作为临时变通方法，你可以在初始化 FastMCP 时将日志级别设置为最高，以抑制输出：\nmcp = FastMCP(\"alpaca-trading\", log_level=\"CRITICAL\")","https:\u002F\u002Fgithub.com\u002Falpacahq\u002Falpaca-mcp-server\u002Fissues\u002F11",{"id":151,"question_zh":152,"answer_zh":153,"source_url":154},17617,"期权交易下单失败，报错提示 'side is required for all order classes other than mleg' 是怎么回事？","这是一个已知问题，单腿期权订单（single-leg option orders）曾存在 Schema 验证错误。维护者已修复此代码问题，请尝试更新到最新版本。\n在修复前或如果问题依旧，可以尝试让 AI 使用 `place_stock_order` 函数来代替专门的期权下单函数，这在某些单腿订单场景下是有效的变通方案。","https:\u002F\u002Fgithub.com\u002Falpacahq\u002Falpaca-mcp-server\u002Fissues\u002F7",{"id":156,"question_zh":157,"answer_zh":158,"source_url":159},17618,"如何为 VS Code 设置 alpaca-mcp-server？文档中只有 Claude Desktop 的说明。","维护者已根据用户反馈在 README.md 中添加了针对 VS Code 的设置说明。虽然早期文档主要侧重 Windows 上的 Claude Desktop，但现在已支持并在文档中包含了 VS Code 的配置指南（通常涉及修改 settings.json 文件）。此外，Claude Desktop 也支持在 MacBook 上使用。","https:\u002F\u002Fgithub.com\u002Falpacahq\u002Falpaca-mcp-server\u002Fissues\u002F9",{"id":161,"question_zh":162,"answer_zh":163,"source_url":164},17619,"Claude Desktop 连接 WebSocket 时报 'spawn websocket ENOENT' 错误如何解决？","该错误通常表示系统找不到 websocket 相关的可执行文件或依赖未正确安装。请检查以下步骤：\n1. 确保在虚拟环境中安装了所有必要的 WebSocket 依赖包。\n2. 确认防火墙（如 UFW）已允许端口 9001\u002FTCP。\n3. 检查启动命令是否正确指向了激活虚拟环境后的 Python 解释器。\n（注：此问题在较新版本中可能已通过改进启动脚本得到缓解，建议查阅最新 Issue 讨论）。","https:\u002F\u002Fgithub.com\u002Falpacahq\u002Falpaca-mcp-server\u002Fissues\u002F6",[]]