股票分析MCP服务器

一个使用Alpha Vantage API提供股票市场数据工具的模型上下文协议(MCP)服务器,适用于金融数据分析和技术分析。

  • by bjoxiah
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 bjoxiah/custom-mcp-server

使用说明

股票分析MCP服务器

模型上下文协议(MCP)服务器,使用AlphaVantage API提供股票市场数据工具。

特性

工具

  • 公司简介
  • 公司_情感
    • 检索按股票代码或主题筛选的市场新闻和情绪数据 新闻与情绪
  • get_stock_price
    • 从以下网址获取任何股票的实时全球报价 引用端点
  • 获取月度历史数据

先决条件

安装

1.克隆存储库

git clone <repo-url>
cd custom-mcp-server

2.安装依赖项

poetry install

3.配置环境变量

创建一个 .env 项目根目录中的文件:

ALPHA_VANTAGE_BASE_API_URL=https://www.alphavantage.co/query
ALPHA_VANTAGE_KEY=your_api_key_here

4.测试服务器

poetry run server

如果成功,您应该看到MCP服务器启动时没有错误。

Claude桌面配置

1.找到你的诗歌虚拟环境

poetry env info --path

这将输出类似以下内容:

/Users/username/Library/Caches/pypoetry/virtualenvs/custom-mcp-server-xxxxx-py3.13

2.配置克劳德桌面

编辑您的Claude Desktop配置文件:

MacOS: ~/Library/Application Support/Claude/claude_desktop_config.json
视窗: %APPDATA%\Claude\claude_desktop_config.json

添加以下配置:

{
  "mcpServers": {
    "Stock Analysis": {
      "command": "/path/to/your/virtualenv/custom-mcp-server-xxxxx-py3.13/bin/python",
      "args": ["-m", "custom_mcp_server"],
      "cwd": "/absolute/path/to/custom-mcp-server",
      "env": {
        "ALPHA_VANTAGE_BASE_API_URL": "https://www.alphavantage.co/query",
        "ALPHA_VANTAGE_KEY": "your_api_key_here"
      }
    }
  }
}

重要:用实际路径替换路径:

  • 使用步骤1中的virtualenv路径
  • 使用项目目录的绝对路径
  • alpha vantage api每天允许25个请求

3.重新启动克劳德桌面

完全退出Claude Desktop(Mac上的Cmd+Q)并重新启动以使更改生效。

使用示例

配置后,您可以通过Claude Desktop与服务器交互:

获取公司信息

What's the company overview for Apple (AAPL)?

查看股票价格

What's the current stock price of Tesla?

分析市场情绪

Get news sentiment for Microsoft from the last week

查看历史数据

Show me the monthly historical data for Amazon stock

许可证

MIT许可证