使用说明
多边形市场数据MCP服务器
一个通过Polygon.io API提供实时市场数据的模型上下文协议(MCP)服务器。该服务器使Claude Desktop和其他MCP客户端能够访问全面的股票市场信息。
特点/特性
- 实时股票报价 - 获取当前价格、成交量和变化指标
- 市场状况 - 检查市场是否开放/关闭
- 股票搜索 - 通过股票代码或公司名称查找股票
- 新闻推送 - 任何股票的最新新闻文章
- 历史数据 - 用于技术分析的价格聚合数据
演示
安装
- 克隆此存储库:
git clone https://github.com/YOUR_USERNAME/polygon-mcp-server.git
cd polygon-mcp-server
- 安装依赖项:
pip install -r requirements.txt
- 设置您的API密钥:
# Edit .env and replace with your Polygon API key
nano .env # or open in any text editor
从以下链接获取您的免费API密钥: Polygon.io(可译为“波利贡网”或根据具体语境保留原名,若作为网站名称,通常直接使用原名)
两种服务器实现
此存储库提供了两种不同的MCP服务器实现:
server.py- 使用官方MCP Python SDK(推荐)server_fastmcp.py- 使用FastMCP框架(替代方案)
这两台服务器提供相同的功能,请根据您的偏好选择。
Claude 桌面版的配置
将此添加到您的Claude Desktop配置文件中:
macOS(发音为“Mac OS”,中文常译为“苹果电脑操作系统”或简称“苹果系统”): ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
选项1:使用MCP SDK(推荐)
{
"mcpServers": {
"polygon-market-data": {
"command": "python",
"args": ["/path/to/polygon-mcp-server/server.py"],
"env": {
"POLYGON_API_KEY": "your_polygon_api_key_here"
}
}
}
}
选项2:使用FastMCP
{
"mcpServers": {
"polygon-market-data": {
"command": "python",
"args": ["/path/to/polygon-mcp-server/server_fastmcp.py"],
"env": {
"POLYGON_API_KEY": "your_polygon_api_key_here"
}
}
}
}
可用工具
get_stock_quote
获取任何股票代码的实时报价
get_stock_quote(symbol="AAPL")
get_market_status
查看当前市场交易时间和状态
get_market_status()
search_stocks
通过股票代码或公司名称搜索股票
search_stocks(query="Tesla", limit=5)
get_stock_news
获取某只股票的最新新闻文章
get_stock_news(symbol="TSLA", limit=10)
get_aggregates
获取历史价格数据
get_aggregates(symbol="GOOGL", timespan="day", from_date="2024-01-01", to_date="2024-01-31")
发展
使用MCP SDK服务器:
python server.py
使用FastMCP服务器:
python server_fastmcp.py
使用FastMCP Inspector进行测试:
fastmcp dev server_fastmcp.py
要求
- Python 3.8或更高版本
- Polygon.io API密钥(提供免费层级)
- requirements.txt 中列出的依赖项
定制MCP服务器开发
我们为客户提供MCP服务器开发服务,如果您需要为自己的系统开发类似于Polygon MCP服务器的MCP服务器,请联系我们(https://www.flowhunt.io/contact/)。以下是关于我们如何为客户开发MCP服务器的说明:https://www.flowhunt.io/services/mcp-server-development/
许可证
MIT 许可证 - 详情请参见 LICENSE 文件
做出贡献
欢迎贡献!请随时提交拉取请求。
支持
如需报告问题或提出疑问,请使用GitHub的Issues页面。