mcpField
A
Alpha Vantage MCP Server

Alpha Vantage MCP Server

本地服务
github.com/berlinbra金融数据10453 周前更新

关于 Alpha Vantage MCP Server

Alpha Vantage MCP Server 是一个 MCP 服务,通过免费的 Alpha Vantage API 提供金融市场数据,覆盖股票、ETF、加密货币与期权。它面向需要在 AI 助手中查询行情和公司信息的用户。

主要功能

  1. 01股票实时报价与公司信息
  2. 02加密货币汇率与历史时间序列
  3. 03期权链数据(实时与历史)
  4. 04ETF 概况,包括持仓与行业配置
  5. 05财报日历与历史财报数据
  6. 06内置错误处理与速率限制管理

适用场景

  1. 01在 AI 助手中查询股票报价与公司基本面
  2. 02分析加密货币的日线、周线或月线走势
  3. 03查看 ETF 的持仓与行业配置
  4. 04跟踪即将发布的财报日程

MCP 相关

该项目是一个 MCP 服务,向 MCP 客户端暴露 12 个工具,例如 get-stock-quote、get-crypto-daily 和 get-earnings-calendar。

配置

本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。

mcp.json · 通用配置
{
"mcpServers": {
"alpha-vantage": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"build"
]
}
}
}
启动命令docker run -i --rm build

本地服务需要在你的电脑上安装运行环境(如 Node.js 18+)。各客户端的配置文件位置不同,请参考客户端文档。

安装包
ocibuild

工具

还没有获取到工具列表

本地服务需要在你的电脑上运行后才能读取工具,维护者暂未提供工具列表。

详细介绍

Alpha Vantage MCP Server

smithery badge

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

AlphaVantage-MCP MCP 服务

功能

  • 实时股票报价,包含价格、成交量和涨跌数据
  • 详细的公司信息,包括行业板块、行业和市值
  • 实时加密货币汇率,包含买入价和卖出价
  • 加密货币每日、每周和每月时间序列数据
  • 实时期权链数据,包含希腊值和隐含波动率
  • 历史期权链数据,支持高级筛选和排序
  • 全面的 ETF 概况数据,包含持仓、行业板块配置和关键指标
  • 可自定义时间范围的即将公布的财报日历
  • 历史财报数据,包含年度和季度报告
  • 内置错误处理和速率限制管理

安装

使用 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 仓库中:

uv run src/alpha_vantage_mcp/server.py

使用 inspector

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

可用工具

该服务实现了十二种工具:

  • get-stock-quote:获取特定公司的最新股票报价
  • get-company-info:获取特定公司的股票相关信息
  • get-crypto-exchange-rate:获取当前加密货币汇率
  • get-time-series:获取股票的历史每日价格数据
  • get-realtime-options:获取实时期权链数据,包含希腊值和隐含波动率
  • get-historical-options:获取历史期权链数据,支持高级筛选和排序
  • get-etf-profile:获取全面的 ETF 概况信息,包含持仓和行业板块配置
  • get-crypto-daily:获取加密货币的每日时间序列数据
  • get-crypto-weekly:获取加密货币的每周时间序列数据
  • get-crypto-monthly:获取加密货币的每月时间序列数据
  • get-earnings-calendar:获取公司的即将公布的财报日历数据
  • get-historical-earnings:获取特定公司的历史财报数据
get-stock-quote

输入架构:

{
    "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
get-company-info

获取指定代码对应公司的详细信息。

输入架构:

{
    "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
get-crypto-exchange-rate

获取实时加密货币汇率及其他市场数据。

输入架构:

{
    "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
get-time-series

获取每日时间序列(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). When start_date or end_date is specified, defaults to 'full'",
        "default": "compact"
    },
    "start_date": {
        "type": "string",
        "description": "Optional: Start date in YYYY-MM-DD format for filtering results",
        "pattern": "^20[0-9]{2}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12][0-9]|3[01])$"
    },
    "end_date": {
        "type": "string",
        "description": "Optional: End date in YYYY-MM-DD format for filtering results",
        "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 data points to return when no date filtering is applied (default: 5)",
        "default": 5,
        "minimum": 1
    }
}

响应示例(近期数据):

Time Series Data for AAPL (Last Refreshed: 2024-12-17 16:00:00):
(Showing 5 most recent data points)

Date: 2024-12-16
Open: $195.09
High: $197.68
Low: $194.83
Close: $197.57
Volume: 55,751,011
---
Date: 2024-12-13
Open: $194.50
High: $196.25
Low: $193.80
Close: $195.12
Volume: 48,320,567
---

响应示例(日期范围筛选):

Time Series Data for AAPL (Last Refreshed: 2024-12-17 16:00:00):
Date Range: 2024-12-01 to 2024-12-07 (5 data points)

Date: 2024-12-06
Open: $191.25
High: $193.80
Low: $190.55
Close: $192.90
Volume: 52,145,890
---
Date: 2024-12-05
Open: $189.75
High: $192.40
Low: $188.90
Close: $191.30
Volume: 47,892,345
---
get-realtime-options

获取股票的实时期权链数据,可选择计算希腊值并筛选合约。

⚠️ 需要高级订阅:此端点需要 Alpha Vantage Premium 的 600 requests/minute 或 1200 requests/minute 套餐。标准的 75 requests/minute 套餐和免费账户会收到占位符/演示数据,而非真实市场数据。对于大多数使用场景,可考虑使用 get-historical-options,它适用于所有 API 密钥套餐。

输入架构:

{
    "symbol": {
        "type": "string",
        "description": "Stock symbol (e.g., AAPL, MSFT)"
    },
    "require_greeks": {
        "type": "boolean",
        "description": "Optional: Enable Greeks and implied volatility calculation (default: false)",
        "default": false
    },
    "contract": {
        "type": "string",
        "description": "Optional: Specific options contract ID to retrieve"
    },
    "datatype": {
        "type": "string",
        "description": "Optional: Response format (json or csv, default: json)",
        "enum": ["json", "csv"],
        "default": "json"
    }
}

示例响应:

Realtime Options Data for AAPL
Last Updated: 2025-01-21 16:00:00

=== Expiration: 2025-01-24 ===

Strike: $220.0 (CALL)
Last: $5.25
Bid: $5.10
Ask: $5.30
Volume: 1250
Open Interest: 8420
IV: 0.28
Delta: 0.65
Gamma: 0.02
Theta: -0.15
Vega: 0.45
Rho: 0.12
---

Strike: $220.0 (PUT)
Last: $1.85
Bid: $1.80
Ask: $1.90
Volume: 820
Open Interest: 5240
IV: 0.25
Delta: -0.35
Gamma: 0.02
Theta: -0.12
Vega: 0.42
Rho: -0.08
---

注意:以上示例展示的是真实市场数据,仅限使用 Alpha Vantage Premium 600+ requests/minute 套餐的用户获取。免费账户或使用 75 requests/minute 套餐的用户会看到占位符数据(例如 "XXYYZZ" 之类的代码、"2099-99-99" 之类的日期),应改用 get-historical-options。

get-historical-options

获取历史期权链数据,并提供高级筛选和排序功能,以查找特定合约。

输入架构:

{
    "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])$"
    },
    "expiry_date": {
        "type": "string",
        "description": "Optional: Filter by expiration date in YYYY-MM-DD format",
        "pattern": "^20[0-9]{2}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12][0-9]|3[01])$"
    },
    "min_strike": {
        "type": "number",
        "description": "Optional: Minimum strike price filter (e.g., 100.00)",
        "minimum": 0
    },
    "max_strike": {
        "type": "number",
        "description": "Optional: Maximum strike price filter (e.g., 200.00)",
        "minimum": 0
    },
    "contract_id": {
        "type": "string",
        "description": "Optional: Filter by specific contract ID (e.g., MSTR260116C00000500)"
    },
    "contract_type": {
        "type": "string",
        "description": "Optional: Filter by contract type (call or put)",
        "enum": ["call", "put", "C", "P"]
    },
    "limit": {
        "type": "integer",
        "description": "Optional: Number of contracts to return after filtering (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):
Status: success
Found 156 contracts, sorted by: strike (asc)

Contract Details:
Contract ID: AAPL240315C00190000
Expiration: 2024-03-15
Strike: $190.00
Type: call
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
---

示例响应(筛选后):

Historical Options Data for MSTR (2024-02-20):
Status: success
Filters: Expiry: 2026-01-16, Strike: min $400 - max $600, Type: call
Found 3 contracts, sorted by: strike (asc)

Contract Details:
Contract ID: MSTR260116C00000500
Expiration: 2026-01-16
Strike: $500.00
Type: call
Last: $125.30
Bid: $124.50
Ask: $126.10
Volume: 89
Open Interest: 1234
---
get-etf-profile

获取全面的 ETF 简介信息,包括基本指标、行业配置和主要持仓。

输入架构:

{
    "symbol": {
        "type": "string",
        "description": "ETF symbol (e.g., QQQ, SPY, VTI)"
    }
}

示例响应:

ETF profile for QQQ:

ETF Profile

Basic Information:
Net Assets: $352,700,000,000
Net Expense Ratio: 0.200%
Portfolio Turnover: 8.0%
Dividend Yield: 0.50%
Inception Date: 1999-03-10
Leveraged: NO

Sector Allocation:
INFORMATION TECHNOLOGY: 51.9%
COMMUNICATION SERVICES: 15.4%
CONSUMER DISCRETIONARY: 12.2%
CONSUMER STAPLES: 4.8%
HEALTHCARE: 4.5%
INDUSTRIALS: 4.4%
UTILITIES: 1.4%
MATERIALS: 1.3%
ENERGY: 0.5%
FINANCIALS: 0.4%

Top Holdings:
 1. NVDA - NVIDIA CORP: 9.80%
 2. MSFT - MICROSOFT CORP: 8.85%
 3. AAPL - APPLE INC: 7.35%
 4. AMZN - AMAZON.COM INC: 5.65%
 5. AVGO - BROADCOM INC: 5.14%
 6. META - META PLATFORMS INC CLASS A: 3.63%
 7. NFLX - NETFLIX INC: 3.10%
 8. TSLA - TESLA INC: 2.66%
 9. GOOGL - ALPHABET INC CLASS A: 2.49%
10. COST - COSTCO WHOLESALE CORP: 2.49%

... and 92 more holdings

Total Holdings: 102
get-crypto-daily

获取加密货币的每日时间序列数据。

输入架构:

{
    "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
---
get-crypto-weekly

获取加密货币的每周时间序列数据。

输入架构:

{
    "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
---
get-crypto-monthly

获取加密货币的每月时间序列数据。

输入架构:

{
    "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
---
get-earnings-calendar

获取即将公布财报的日历数据,支持自定义时间范围和排序。

输入架构:

{
    "symbol": {
        "type": "string",
        "description": "Optional: Stock symbol to filter earnings for a specific company (e.g., AAPL, MSFT, IBM)"
    },
    "horizon": {
        "type": "string",
        "description": "Optional: Time horizon for earnings data (3month, 6month, or 12month)",
        "enum": ["3month", "6month", "12month"],
        "default": "12month"
    },
    "limit": {
        "type": "integer",
        "description": "Optional: Number of earnings entries to return (default: 100)",
        "default": 100,
        "minimum": 1
    },
    "sort_by": {
        "type": "string",
        "description": "Optional: Field to sort by",
        "enum": ["reportDate", "symbol", "name", "fiscalDateEnding", "estimate"],
        "default": "reportDate"
    },
    "sort_order": {
        "type": "string",
        "description": "Optional: Sort order",
        "enum": ["asc", "desc"],
        "default": "desc"
    }
}

示例响应(默认 - 最新优先):

Earnings calendar (12month):

Upcoming Earnings Calendar (Sorted by reportDate desc):

Company: NVDA - NVIDIA Corp
Report Date: 2025-08-15
Fiscal Date End: 2025-07-31
Estimate: $4.25 USD
---
Company: AAPL - Apple Inc
Report Date: 2025-07-30
Fiscal Date End: 2025-06-30
Estimate: $1.85 USD
---
Company: MSTR - MicroStrategy Inc
Report Date: 2025-05-08
Fiscal Date End: 2025-03-31
Estimate: $1.30 USD
---
Company: MSTR - MicroStrategy Inc
Report Date: 2025-02-06
Fiscal Date End: 2024-12-31
Estimate: $1.25 USD
---

示例响应(按代码排序):

Earnings calendar (12month):

Upcoming Earnings Calendar (Sorted by symbol asc):

Company: AAPL - Apple Inc
Report Date: 2025-07-30
Fiscal Date End: 2025-06-30
Estimate: $1.85 USD
---
Company: GOOGL - Alphabet Inc
Report Date: 2025-04-25
Fiscal Date End: 2025-03-31
Estimate: $2.15 USD
---
Company: MSTR - MicroStrategy Inc
Report Date: 2025-02-06
Fiscal Date End: 2024-12-31
Estimate: $1.25 USD
---
get-historical-earnings

获取特定公司的历史财报数据,包括年度和季度报告。

输入架构:

{
    "symbol": {
        "type": "string",
        "description": "Stock symbol for the company (e.g., AAPL, MSFT, IBM)"
    },
    "limit_annual": {
        "type": "integer",
        "description": "Optional: Number of annual earnings to return (default: 5)",
        "default": 5,
        "minimum": 1
    },
    "limit_quarterly": {
        "type": "integer",
        "description": "Optional: Number of quarterly earnings to return (default: 8)",
        "default": 8,
        "minimum": 1
    }
}

示例响应:

Historical Earnings for MSTR:

=== ANNUAL EARNINGS ===
Fiscal Year End: 2023-12-31
Reported EPS: $5.40
---
Fiscal Year End: 2022-12-31
Reported EPS: $-9.98
---

=== QUARTERLY EARNINGS ===
Fiscal Quarter End: 2024-09-30
Reported Date: 2024-10-30
Reported EPS: $1.10
Estimated EPS: $0.98
Surprise: +$0.12 (+12.24%)
Report Time: post-market
---
Fiscal Quarter End: 2024-06-30
Reported Date: 2024-08-01
Reported EPS: $1.05
Estimated EPS: $0.92
Surprise: +$0.13 (+14.13%)
Report Time: post-market
---

错误处理

服务会针对各种情况进行全面的错误处理:

  • 超出速率限制
  • API 密钥无效
  • 网络连接问题
  • 超时处理
  • 响应格式错误

错误消息以清晰易懂的格式返回。

先决条件

  • Python 3.12 或更高版本
  • httpx
  • mcp

贡献者

参与贡献

欢迎贡献!请随时提交 Pull Request。

许可证

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

评论

支持 Markdown

第一次接触 MCP?

从协议是什么,到在客户端里装上第一个服务,这几条回答覆盖了大多数入门问题。

一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。