stock-mcp
Stores and retrieves stock market data in a MySQL database, providing tools for querying quotes, historical K-line data, company profiles, financial statements, ratios, dividends, analyst forecasts, earnings, holders, news, and options chains.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@stock-mcpGet latest quote for AAPL"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
stock-mcp
MCP server(TypeScript / Node.js)通过 Yahoo Finance 和 Investing.com(GraphQL + TVC) 获取股票全量信息,持久化到 外部 MySQL(通过 DATABASE_URL 连接串配置,不随 server 内置),按标的代码查询。
架构上 MCP server 保持轻量:它只是一个薄查询层 + 同步触发器,数据库是完全外部的依赖。
快速开始
npm install
npm run build:all # TypeScript + Go sidecar
# 0. 配置外部 MySQL 连接(.env)
# DATABASE_URL=mysql://user:pass@host:3306/stock_mcp
# 本地临时开发库可用 deploy/docker-compose.mysql.yml 起一个:
# docker compose -f deploy/docker-compose.mysql.yml up -d
# 1. 对配置的数据库初始化表结构
npm run db:init
# 2. 全量同步一只股票(从 2000-01-01 开始拉历史 + 全部基本面)
npm run sync -- --symbol NVDA --full
# 之后增量同步(只拉新增数据)
npm run sync -- --symbol NVDA
# 同步所有已入库标的
npm run sync -- --all --full
# 3. 启动 MCP server(stdio)
npm run serverRelated MCP server: YFinance MCP Server
测试
# 需要本地 MySQL(默认 127.0.0.1:3306,见 deploy/docker-compose.mysql.yml)且已初始化表结构
npm run test:db # 查询层:覆盖全部查询函数、LIMIT 绑定回归、边界参数
npm run test:mcp # 协议层:initialize/tools/list/tools/call 全工具端到端 + stdin 关闭退出
npm test # 两者一起测试使用独立的 ZZTEST 标的,跑完自动清理,不会动已有数据。
MCP 工具
工具 | 说明 |
| 全量/增量同步一只股票到 MySQL |
| 搜索已入库标的 |
| 最新行情 + 关键指标 |
| 历史 K 线(1d/1wk/1mo) |
| 公司资料 |
| 三张财务报表 |
| 估值/财务比率 |
| 分红历史与摘要 |
| 分析师共识与目标价 |
| 盈利历史与预测 |
| 机构持有人 |
| 新闻 |
| 期权链快照 |
数据源
Yahoo Finance:K 线(v8 chart)、quoteSummary(需 cookie+crumb)、期权(v7)、新闻(v1 search)、财务(fundamentals-timeseries,免认证)
Investing.com:GraphQL
gql.api.investing.com/graphql(行情/三表/比率/分红/预测/盈利/公司资料/高管/持有人,免认证)、TVC K 线(carrier token)
客户端接入示例(Claude Desktop / Cursor / Codex)
{
"mcpServers": {
"stock-mcp": {
"command": "node",
"args": ["/path/to/stock-mcp/dist/cli.js", "server"]
}
}
}说明
全量同步:从
BARS_START_DATE(默认 2000-01-01)拉全部日 K + 全部基本面 + 期权快照 + 新闻。增量同步:按
sync_state.last_bar_date只拉新 K 线,并刷新行情、比率、预测、新闻、期权快照。所有写入均为幂等 upsert(
INSERT ... ON DUPLICATE KEY UPDATE),可重复执行。限流已内置(默认 300ms/请求),Yahoo crumb 缓存 25 分钟,TVC token 缓存 25 分钟。
关于 investing.com 的 TLS 拦截
investing.com 通过 Cloudflare TLS 指纹拦截 Node.js 的请求(HTTP 403),Go 客户端可正常访问。因此项目内置了一个极小的 Go 传输代理 cmd/gqlproxy(约 200 行,仅标准库):
npm run build:sidecar # 生成 bin/gqlproxyTS 数据源层默认先试 Node fetch,遇到 403 自动切换到该代理(含持久化 cookie 会话,自动处理 Cloudflare challenge)。从不受指纹拦截的网络访问时无需代理,可设置 INVESTING_TRANSPORT=node 强制纯 Node。
# 完整构建(TypeScript + Go sidecar)
npm run build:all环境变量
变量 | 默认 | 说明 |
| 127.0.0.1/3306/stock/stock123/stock_mcp | MySQL 连接 |
| Chrome 148 UA | 请求指纹 |
| 300 | 请求间隔限流 |
| 2000-01-01 | 全量同步起点 |
| yahoo | K 线来源(yahoo/investing) |
| auto | node / go / auto |
| .cache/gqlproxy_cookies.txt | sidecar cookie 会话文件 |
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- -license-quality-maintenanceReal-time financial market data MCP server. Stocks, crypto, technicals, sentiment, FDA calendar. No API keys required.
- Alicense-qualityDmaintenanceA comprehensive MCP server that provides seamless access to Yahoo Finance stock market data, enabling retrieval of real-time quotes, historical data, charts, financial summaries, and market searches.27ISC
- Flicense-qualityCmaintenanceA production-grade MCP server that provides tools to fetch historical stock data, company information, and technical indicators (SMA, EMA, RSI, MACD, Bollinger Bands) via yfinance, and includes a Flask web dashboard for visual analysis.
- Flicense-qualityDmaintenanceA lightweight MCP server for accessing Yahoo Finance data, providing stock prices, history, company information, and financial statements.
Related MCP Connectors
Multi-tenant FastMCP server for Charles Schwab brokerage data, monetized via DPYC Tollbooth
7-factor stock scoring MCP server. US/HK/CN, 74 stocks. Free + Premium (USDC/Base). x402 ready.
Alpha Vantage MCP — Stock market data, fundamentals, and earnings
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/jamespud/stock-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server