Skip to main content
Glama
berlinbra

AlphaVantage-MCP

Alpha Vantage MCP 服务器

铁匠徽章

模型上下文协议 (MCP) 服务器,通过免费的Alpha Vantage API提供对金融市场数据的实时访问。该服务器实现了用于检索股票报价和公司信息的标准化接口。

特征

  • 实时股票报价,包括价格、交易量和变化数据

  • 详细的公司信息,包括部门、行业和市值

  • 实时加密货币汇率及买入/卖出价格

  • 每日、每周和每月的加密货币时间序列数据

  • 具有高级过滤和排序功能的历史期权链数据

  • 内置错误处理和速率限制管理

安装

使用 Claude Desktop

通过 Docker 安装

  • 克隆存储库并构建本地映像以供 Claude 桌面客户端使用

cd alpha-vantage-mcp
docker build -t mcp/alpha-vantage .
  • 更改您的claude_desktop_config.json以匹配以下内容,将REPLACE_API_KEY替换为您的实际密钥:

claude_desktop_config.json路径

  • 在 MacOS 上: ~/Library/Application\ Support/Claude/claude_desktop_config.json

  • 在 Windows 上: %APPDATA%/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "alphavantage": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "-e",
        "ALPHA_VANTAGE_API_KEY",
        "mcp/alpha-vantage"
      ],
      "env": {
        "ALPHA_VANTAGE_API_KEY": "REPLACE_API_KEY"
      }
    }
  }
}

通过 Smithery 安装

要通过Smithery自动为 Claude Desktop 安装 Alpha Vantage MCP Server:

npx -y @smithery/cli install @berlinbra/alpha-vantage-mcp --client claude
{
 "mcpServers": {
  "alpha-vantage-mcp": {
   "args": [
    "--directory",
    "/Users/{INSERT_USER}/YOUR/PATH/TO/alpha-vantage-mcp",
    "run",
    "alpha-vantage-mcp"
   ],
   "command": "uv",
   "env": {
    "ALPHA_VANTAGE_API_KEY": "<insert api key>"
   }
  }
 }
}

安装软件包

uv install -e .

跑步

通过 json 文件将 Claude 客户端与 MCP 工具连接并安装软件包后,Claude 应该可以看到服务器的 mcp 工具:

您可以通过以下方式自行运行服务器:在 alpha-vantage-mcp repo 中:

uv run src/alpha_vantage_mcp/server.py

与检查员

* npx @modelcontextprotocol/inspector uv --directory /Users/{INSERT_USER}/YOUR/PATH/TO/alpha-vantage-mcp run src/alpha_vantage_mcp/server.py `

Related MCP server: @qubaomingg/stock-mcp

可用工具

该服务器实现了八个工具:

  • get-stock-quote :获取特定公司的最新股票报价

  • get-company-info :获取特定公司的股票相关信息

  • get-crypto-exchange-rate :获取当前加密货币汇率

  • get-time-series :获取股票的历史每日价格数据

  • get-historical-options :获取具有排序功能的历史期权链数据

  • get-crypto-daily :获取加密货币的每日时间序列数据

  • get-crypto-weekly :获取加密货币的每周时间序列数据

  • get-crypto-monthly :获取加密货币的每月时间序列数据

获取股票报价

输入模式:

{
    "symbol": {
        "type": "string",
        "description": "Stock symbol (e.g., AAPL, MSFT)"
    }
}

响应示例:

Stock quote for AAPL:

Price: $198.50
Change: $2.50 (+1.25%)
Volume: 58942301
High: $199.62
Low: $197.20

获取公司信息

检索给定符号的详细公司信息。

输入模式:

{
    "symbol": {
        "type": "string",
        "description": "Stock symbol (e.g., AAPL, MSFT)"
    }
}

响应示例:

Company information for AAPL:

Name: Apple Inc
Sector: Technology
Industry: Consumer Electronics
Market Cap: $3000000000000
Description: Apple Inc. designs, manufactures, and markets smartphones...
Exchange: NASDAQ
Currency: USD

获取加密货币汇率

通过附加市场数据检索实时加密货币汇率。

输入模式:

{
    "crypto_symbol": {
        "type": "string",
        "description": "Cryptocurrency symbol (e.g., BTC, ETH)"
    },
    "market": {
        "type": "string",
        "description": "Market currency (e.g., USD, EUR)",
        "default": "USD"
    }
}

响应示例:

Cryptocurrency exchange rate for BTC/USD:

From: Bitcoin (BTC)
To: United States Dollar (USD)
Exchange Rate: 43521.45000
Last Updated: 2024-12-17 19:45:00 UTC
Bid Price: 43521.00000
Ask Price: 43522.00000

获取时间序列

检索每日时间序列(OHLCV)数据。

输入模式:

{
    "symbol": {
        "type": "string",
        "description": "Stock symbol (e.g., AAPL, MSFT)"
    },
    "outputsize": {
        "type": "string",
        "description": "compact (latest 100 data points) or full (up to 20 years of data)",
        "default": "compact"
    }
}

响应示例:

Time Series Data for AAPL (Last Refreshed: 2024-12-17 16:00:00):

Date: 2024-12-16
Open: $195.09
High: $197.68
Low: $194.83
Close: $197.57
Volume: 55,751,011

获取历史选项

使用高级排序和过滤功能检索历史期权链数据。

输入模式:

{
    "symbol": {
        "type": "string",
        "description": "Stock symbol (e.g., AAPL, MSFT)"
    },
    "date": {
        "type": "string",
        "description": "Optional: Trading date in YYYY-MM-DD format (defaults to previous trading day, must be after 2008-01-01)",
        "pattern": "^20[0-9]{2}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12][0-9]|3[01])$"
    },
    "limit": {
        "type": "integer",
        "description": "Optional: Number of contracts to return (default: 10, use -1 for all contracts)",
        "default": 10,
        "minimum": -1
    },
    "sort_by": {
        "type": "string",
        "description": "Optional: Field to sort by",
        "enum": ["strike", "expiration", "volume", "open_interest", "implied_volatility", "delta", "gamma", "theta", "vega", "rho", "last", "bid", "ask"],
        "default": "strike"
    },
    "sort_order": {
        "type": "string",
        "description": "Optional: Sort order",
        "enum": ["asc", "desc"],
        "default": "asc"
    }
}

响应示例:

Historical Options Data for AAPL (2024-02-20):

Contract 1:
Strike: $190.00
Expiration: 2024-03-15
Last: $8.45
Bid: $8.40
Ask: $8.50
Volume: 1245
Open Interest: 4567
Implied Volatility: 0.25
Greeks:
  Delta: 0.65
  Gamma: 0.04
  Theta: -0.15
  Vega: 0.30
  Rho: 0.25

Contract 2:
...

每日获取加密货币

检索加密货币的每日时间序列数据。

输入模式:

{
    "symbol": {
        "type": "string",
        "description": "Cryptocurrency symbol (e.g., BTC, ETH)"
    },
    "market": {
        "type": "string",
        "description": "Market currency (e.g., USD, EUR)",
        "default": "USD"
    }
}

响应示例:

Daily cryptocurrency time series for SOL in USD:

Daily Time Series for Solana (SOL)
Market: United States Dollar (USD)
Last Refreshed: 2025-04-17 00:00:00 UTC

Date: 2025-04-17
Open: 131.31000000 USD
High: 131.67000000 USD
Low: 130.74000000 USD
Close: 131.15000000 USD
Volume: 39652.22195178
---
Date: 2025-04-16
Open: 126.10000000 USD
High: 133.91000000 USD
Low: 123.46000000 USD
Close: 131.32000000 USD
Volume: 1764240.04195810
---

每周获取加密货币

检索加密货币的每周时间序列数据。

输入模式:

{
    "symbol": {
        "type": "string",
        "description": "Cryptocurrency symbol (e.g., BTC, ETH)"
    },
    "market": {
        "type": "string",
        "description": "Market currency (e.g., USD, EUR)",
        "default": "USD"
    }
}

响应示例:

Weekly cryptocurrency time series for SOL in USD:

Weekly Time Series for Solana (SOL)
Market: United States Dollar (USD)
Last Refreshed: 2025-04-17 00:00:00 UTC

Date: 2025-04-17
Open: 128.32000000 USD
High: 136.00000000 USD
Low: 123.46000000 USD
Close: 131.15000000 USD
Volume: 4823091.05667581
---
Date: 2025-04-13
Open: 105.81000000 USD
High: 134.11000000 USD
Low: 95.16000000 USD
Close: 128.32000000 USD
Volume: 18015328.38860037
---

每月获取加密货币

检索加密货币的每月时间序列数据。

输入模式:

{
    "symbol": {
        "type": "string",
        "description": "Cryptocurrency symbol (e.g., BTC, ETH)"
    },
    "market": {
        "type": "string",
        "description": "Market currency (e.g., USD, EUR)",
        "default": "USD"
    }
}

响应示例:

Monthly cryptocurrency time series for SOL in USD:

Monthly Time Series for Solana (SOL)
Market: United States Dollar (USD)
Last Refreshed: 2025-04-17 00:00:00 UTC

Date: 2025-04-17
Open: 124.51000000 USD
High: 136.18000000 USD
Low: 95.16000000 USD
Close: 131.15000000 USD
Volume: 34268628.85976021
---
Date: 2025-03-31
Open: 148.09000000 USD
High: 180.00000000 USD
Low: 112.00000000 USD
Close: 124.54000000 USD
Volume: 42360395.75443056
---

错误处理

该服务器包括针对各种场景的全面错误处理:

  • 超出速率限制

  • API 密钥无效

  • 网络连接问题

  • 超时处理

  • 格式错误的响应

错误消息以清晰、人类可读的格式返回。

先决条件

  • Python 3.12 或更高版本

  • httpx

  • 甲基氯丙烯

贡献者

贡献

欢迎贡献代码!欢迎提交 Pull 请求。

执照

此 MCP 服务器采用 MIT 许可证。这意味着您可以自由使用、修改和分发该软件,但须遵守 MIT 许可证的条款和条件。更多详情,请参阅项目仓库中的 LICENSE 文件。

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/berlinbra/alpha-vantage-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server