|
1 |
| -# mcp_polygon MCP server |
| 1 | +# Polygon.io MCP Server |
2 | 2 |
|
3 |
| -A MCP server project that provides access to Polygon.io financial market data through the MCP protocol. |
| 3 | +A [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) server that provides access to [Polygon.io](https://polygon.io) financial market data API through an LLM-friendly interface. |
4 | 4 |
|
5 |
| -## Components |
| 5 | +## Overview |
6 | 6 |
|
7 |
| -### Resources |
| 7 | +This server exposes all Polygon.io API endpoints as MCP tools, providing access to comprehensive financial market data including: |
8 | 8 |
|
9 |
| -The server implements a simple note storage system with: |
10 |
| -- Custom note:// URI scheme for accessing individual notes |
11 |
| -- Each note resource has a name, description and text/plain mimetype |
| 9 | +- Stock, options, forex, and crypto aggregates and bars |
| 10 | +- Real-time and historical trades and quotes |
| 11 | +- Market snapshots |
| 12 | +- Ticker details and reference data |
| 13 | +- Dividends and splits data |
| 14 | +- Financial fundamentals |
| 15 | +- Market status and holidays |
12 | 16 |
|
13 |
| -### Prompts |
| 17 | +## Installation |
14 | 18 |
|
15 |
| -The server provides a single prompt: |
16 |
| -- summarize-notes: Creates summaries of all stored notes |
17 |
| - - Optional "style" argument to control detail level (brief/detailed) |
18 |
| - - Generates prompt combining all current notes with style preference |
| 19 | +### Prerequisites |
19 | 20 |
|
20 |
| -### Tools |
| 21 | +- Python 3.8+ |
| 22 | +- A Polygon.io API key ([Get one here](https://polygon.io)) |
21 | 23 |
|
22 |
| -The server implements the following tools: |
| 24 | +### Direct Installation |
23 | 25 |
|
24 |
| -1. Note Management: |
25 |
| - - add-note: Adds a new note to the server |
26 |
| - - Takes "name" and "content" as required string arguments |
27 |
| - - Updates server state and notifies clients of resource changes |
| 26 | +```bash |
| 27 | +# Install dependencies |
| 28 | +uv sync |
28 | 29 |
|
29 |
| -2. All of the Polygon API endpoints supported by the python client. |
| 30 | +# Run the server |
| 31 | +POLYGON_API_KEY=your_api_key_here uv run mcp_polygon |
| 32 | +``` |
30 | 33 |
|
31 |
| -## Configuration |
| 34 | +### Integration with Claude |
32 | 35 |
|
33 |
| -### Environment Variables |
| 36 | +For Claude users, you can add the Polygon MCP server: |
34 | 37 |
|
35 |
| -The following environment variables must be set for the server to function properly: |
| 38 | +```bash |
| 39 | +# Claude CLI |
| 40 | +claude mcp add polygon -e POLYGON_API_KEY=your_api_key_here -- uv run /path/to/mcp_polygon/entrypoint.py |
| 41 | +``` |
36 | 42 |
|
37 |
| -- `POLYGON_API_KEY`: Your Polygon.io API key |
| 43 | +## Usage Examples |
38 | 44 |
|
39 |
| -You can set this environment variable before running the server: |
| 45 | +Once integrated, you can prompt Claude to access Polygon.io data: |
40 | 46 |
|
41 |
| -```bash |
42 |
| -export POLYGON_API_KEY="your_polygon_api_key_here" |
43 | 47 | ```
|
| 48 | +Get the latest price for AAPL stock |
| 49 | +Show me yesterday's trading volume for MSFT |
| 50 | +What were the biggest stock market gainers today? |
| 51 | +Get me the latest crypto market data for BTC-USD |
| 52 | +``` |
| 53 | + |
| 54 | +## Available Tools |
| 55 | + |
| 56 | +This MCP server implements all Polygon.io API endpoints as tools, including: |
44 | 57 |
|
45 |
| -## Quickstart |
| 58 | +- `get_aggs` - Stock aggregates (OHLC) data for a specific ticker |
| 59 | +- `list_trades` - Historical trade data |
| 60 | +- `get_last_trade` - Latest trade for a symbol |
| 61 | +- `list_ticker_news` - Recent news articles for tickers |
| 62 | +- `get_snapshot_ticker` - Current market snapshot for a ticker |
| 63 | +- `get_market_status` - Current market status and trading hours |
| 64 | +- `list_stock_financials` - Fundamental financial data |
| 65 | +- And many more... |
46 | 66 |
|
47 |
| -### Install |
| 67 | +Each tool follows the Polygon.io SDK parameter structure while converting responses to standard JSON that LLMs can easily process. |
48 | 68 |
|
49 |
| -#### Claude code |
| 69 | +## Configuration |
| 70 | + |
| 71 | +### Environment Variables |
50 | 72 |
|
51 |
| -`claude mcp add polygon -e POLYGON_API_KEY=$POLY_API_KEY -- uv run /path/to/mcp_polygon/entrypoint.py` |
| 73 | +- `POLYGON_API_KEY` (required): Your Polygon.io API key |
52 | 74 |
|
53 | 75 | ## Development
|
54 | 76 |
|
55 | 77 | ### Building and Publishing
|
56 | 78 |
|
57 |
| -To prepare the package for distribution: |
58 |
| - |
59 |
| -1. Sync dependencies and update lockfile: |
60 | 79 | ```bash
|
| 80 | +# Sync dependencies |
61 | 81 | uv sync
|
62 |
| -``` |
63 | 82 |
|
64 |
| -2. Build package distributions: |
65 |
| -```bash |
| 83 | +# Build package distributions |
66 | 84 | uv build
|
67 | 85 | ```
|
68 | 86 |
|
69 |
| -This will create source and wheel distributions in the `dist/` directory. |
70 |
| - |
71 |
| -3. Publish to PyPI: |
72 |
| -```bash |
73 |
| -uv publish |
74 |
| -``` |
75 |
| - |
76 |
| -Note: You'll need to set PyPI credentials via environment variables or command flags: |
77 |
| -- Token: `--token` or `UV_PUBLISH_TOKEN` |
78 |
| -- Or username/password: `--username`/`UV_PUBLISH_USERNAME` and `--password`/`UV_PUBLISH_PASSWORD` |
79 |
| - |
80 | 87 | ### Debugging
|
81 | 88 |
|
82 |
| -Since MCP servers run over stdio, debugging can be challenging. For the best debugging |
83 |
| -experience, we strongly recommend using the [MCP Inspector](https://github.com/modelcontextprotocol/inspector). |
84 |
| - |
85 |
| - |
86 |
| -You can launch the MCP Inspector via [`npm`](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) with this command: |
| 89 | +For debugging and testing, we recommend using the [MCP Inspector](https://github.com/modelcontextprotocol/inspector): |
87 | 90 |
|
88 | 91 | ```bash
|
89 | 92 | npx @modelcontextprotocol/inspector uv --directory /path/to/mcp_polygon run mcp_polygon
|
90 | 93 | ```
|
91 | 94 |
|
| 95 | +This will launch a browser interface where you can interact with your MCP server directly and see input/output for each tool. |
| 96 | + |
| 97 | +## License |
| 98 | + |
| 99 | +[License information] |
| 100 | + |
| 101 | +## Links |
92 | 102 |
|
93 |
| -Upon launching, the Inspector will display a URL that you can access in your browser to begin debugging. |
| 103 | +- [Polygon.io Documentation](https://polygon.io/docs) |
| 104 | +- [Model Context Protocol](https://modelcontextprotocol.io) |
| 105 | +- [MCP Python SDK](https://github.com/modelcontextprotocol/python-sdk) |
0 commit comments