股票数据服务

一个基于Model Context Protocol (MCP)的服务器,提供实时股票数据、历史分析和股票比较功能。

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

使用说明

库存助理MCP服务器

该项目实现了一个简单的模型上下文协议(MCP)服务器,该服务器使用Yahoo Finance API提供实时股票数据、历史分析和股票比较。

此MCP服务器使用SSE传输,并使用API密钥进行身份验证。

在本地运行

先决条件:

在本地运行服务器:

uv venv
uv sync

# linux/macOS
export API_KEYS=<AN_API_KEY>
# windows
set API_KEYS=<AN_API_KEY>

uv run fastapi dev main.py

VS代码MCP配置(MCP.json):

{
    "inputs": [
        {
            "type": "promptString",
            "id": "my-api-key",
            "description": "Stock Assistant API Key",
            "password": true
        }
    ],
    "servers": {
        "stock-mcp-sse": {
            "type": "sse",
            "url": "http://localhost:8000/sse",
            "headers": {
                "x-api-key": "${input:my-api-key}"
            }
        }
    }
}

部署到Azure容器应用程序

az containerapp up -g <RESOURCE_GROUP_NAME> -n stock-mcp --environment mcp -l westus --env-vars API_KEYS=<AN_API_KEY> --source .

如果部署成功,Azure CLI将返回应用程序的URL。您可以使用此URL从Visual Studio代码连接到服务器。