Skip to main content
Glama
FinanceExpert

FinanceExpert

by geddamsatish

mcp-stock-server (FinanceExpert)

一个使用 FastMCP 构建的小型 Model Context Protocol 服务器。它通过 yfinance 公开 Yahoo Finance 市场数据,以便助手能够获取报价、CSV 格式的历史记录以及纯文本 Unicode 价格走势图。

要求

  • Python 3.11+

  • uv(推荐)或其他从 pyproject.toml 安装依赖的方法

Related MCP server: Yahoo Finance MCP Server

设置

cd mcp-stock-server
uv sync

运行 (stdio)

该服务器通过 stdio(mcp.run() 的默认方式)进行 MCP 通信:

uv run python server.py

添加为 MCP 服务器 (Cursor)

  1. 打开 Cursor 设置 → MCP(或编辑您的 MCP JSON 配置 —— 在 macOS/Linux 上通常为 ~/.cursor/mcp.json)。

  2. 注册一个 stdio 服务器,其工作目录为该仓库,且命令以 server.py 开头。

选项 A — uv run(推荐)

将 /absolute/path/to/mcp-stock-server 替换为您克隆该仓库的实际路径。

{
  "mcpServers": {
    "FinanceExpert": {
      "command": "uv",
      "args": ["run", "python", "server.py"],
      "cwd": "/absolute/path/to/mcp-stock-server"
    }
  }
}

执行 uv sync 后,这将使用 uv.lock 中的锁定依赖项。

选项 B — 项目虚拟环境 Python

如果您不想从 MCP 客户端调用 uv,请使用此选项:

{
  "mcpServers": {
    "FinanceExpert": {
      "command": "/absolute/path/to/mcp-stock-server/.venv/bin/python",
      "args": ["server.py"],
      "cwd": "/absolute/path/to/mcp-stock-server"
    }
  }
}

首先创建虚拟环境(在仓库根目录下):uv sync(将依赖项安装到 .venv 中)。

  1. 保存配置并重启 Cursor(或重新加载 MCP)。在 MCP 面板中,您应该能看到 FinanceExpert 以及工具 get_stock_analysis、get_historical_prices 和 get_stock_price_chart。

其他 MCP 客户端(例如 Claude Code、支持 MCP 的编辑器)使用相同的思路:通过 command + args + cwd 来配置 stdio 服务器。

工具

工具

描述

get_stock_analysis

快照文本:当前价格、50 日均线、分析师建议关键指标(来自 Ticker.info)。

get_historical_prices

以 CSV 格式获取每日 收盘价 列,回溯 days 个日历天(period=f"{days}d")。默认 days=30。

get_stock_price_chart

框线绘制的 ASCII/Unicode 图表:包含区域填充、价格轴、时间轴上的开始/结束日期以及 8 步迷你走势图。

get_stock_price_chart 参数

  • ticker — 股票代码,例如 INTU、AAPL。

  • days — 当省略 period 时使用:Yahoo 范围 Nd(日历天)。默认 30。

  • period — 可选的 Yahoo 周期字符串;设置后将覆盖 days。示例:10y、5y、1y、6mo、ytd、max。

示例:

  • 最近一个月的交易时段(按日历天):days=30

  • 最近十个日历年(Yahoo 窗口):period="10y"

市场数据来自 Yahoo 的 yfinance;语义与 yfinance history(period=...) 一致。

免责声明

报价和历史记录仅供参考,不构成投资建议。Yahoo 数据可能会有延迟或包含错误;请在决策前独立核实。

Available Tools

3 tools
get_historical_pricesC

Fetches historical closing prices for chart generation.

Inputs: ticker (required), days. Returns: result

get_stock_analysisA

Fetches real-time stock price, 50-day average, and analyst recommendations.

Inputs: ticker (required). Returns: result

get_stock_price_chartA

Plain-text Unicode chart. Pass period (e.g. 10y, 5y, 1y) for calendar ranges, or use days alone.

Inputs: ticker (required), days, period. Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.5/5.0

    Scored across 3 tools

    Disambiguation4/5

    Tools are mostly distinct: get_historical_prices provides raw data for charts, get_stock_analysis gives real-time price and fundamentals, and get_stock_price_chart returns a visual chart. However, get_historical_prices and get_stock_price_chart both relate to historical data, causing slight overlap.

    Naming Consistency5/5

    All tools use a consistent get_verb_noun pattern (get_historical_prices, get_stock_analysis, get_stock_price_chart). Naming is clear and predictable.

    Tool Count5/5

    With 3 tools covering historical data, real-time analysis, and charting, the set is appropriately scoped for a finance assistant. No tool feels unnecessary.

    Completeness3/5

    The tools cover basic stock data retrieval and charting but lack fundamental operations like search, comparison, or portfolio management. Gaps exist for a fully comprehensive finance tool.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables querying Yahoo Finance data including stock prices, historical data, financial statements, dividends, news, analyst recommendations, and company information through the yfinance library.
      -
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables LLMs to retrieve stock market data and financial information from Yahoo Finance using the yfinance Python library. Supports querying stock prices, historical data, and other financial metrics through natural language.
      MIT
    • A
      license
      A
      quality
      C
      maintenance
      Enables retrieval of comprehensive financial data from Yahoo Finance, including stock prices, company info, financial statements, options, and news, for stock analysis and market research.
      9
      372
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      Provides access to Yahoo Finance data including real-time stock quotes, historical prices, financial statements, company info, symbol search, and news.
      6
      41 npm
      1
      MIT