AI Stock Scanner MCP
Last updated November 3, 2026
Connect Claude or another MCP client to StashGamma and ask for stock scans in your own words. Your assistant writes the query, runs it against end-of-day data, and reads the matches back. It uses the same scan language as the AI Stock Scan Builder.
Get your API keyHow it works
- Your assistant reads the scan language from
get_scan_syntax. - It writes a query for what you asked, and can check it with
validate_scan_query. - It calls
run_stock_scanand gets the matches, the match count, and the date of the data. - If a query is rejected, the error gives the reason and position so it can fix the query and try again.
All of these tools are read-only. They can't read or change saved scans, reach another user's data, or place trades. The server doesn't use AI to write queries; your assistant does that.
Connect your client
You need a Data API key. Sign in and open Profile, Developer API to get one. Treat a URL with your key in it like a password, and rotate the key from the same page if it leaks.
Claude Code
claude mcp add --transport http stashgamma-scanner "https://www.stashgamma.com/api/dataapi/mcp?toolset=scanner" --header "X-Api-Key: sg_live_YOUR_KEY"Claude Desktop and Claude.ai
Go to Settings, then Connectors, then Add custom connector. That form takes a single URL, so the key goes in the path:
https://www.stashgamma.com/api/dataapi/mcp/sg_live_YOUR_KEY?toolset=scannerThe Claude and ChatGPT setup guide walks through connector setup click by click, with your own key filled in. Use the URL above to get only the scanner tools.
Other MCP clients
Any client that supports the Streamable HTTP transport can connect. Send the key as an X-Api-Key header or Authorization: Bearer, or put it in the URL as above. The server is stateless: each POST gets one JSON response, and a GET returns 405 because there is no event stream to open. You can test your key with curl:
curl -X POST "https://www.stashgamma.com/api/dataapi/mcp?toolset=scanner" \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-H "X-Api-Key: sg_live_YOUR_KEY" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}'Leaving out ?toolset=scanner connects to the full Data API server, which adds the price data, options analyzer and portfolio tools. The portfolio tools can change your account's position list, so those tools aren't read-only.
Tools
| Tool | Arguments | Returns | Quota |
|---|---|---|---|
| run_stock_scan | query, universe?, sort?, limit? | Date of the data, match count, truncated flag, and the matching symbols with their close and the fields the query uses. | Counts as 1 request. A rejected query does not count. |
| validate_scan_query | query, universe? | Whether the query compiles. If it does, the universe and the fields it can sort by. If not, the reason and position. | Free |
| get_scan_syntax | none | The scan language: timeframes, comparators, universes, every indicator with its allowed periods, every fundamentals field, and examples of what gets rejected. | Free |
| get_example_scans | none | Ready-made scan queries by category, each of which compiles as written. | Free |
| get_api_usage | none | Your plan, and the requests used and remaining per hour, day and week. | Free |
universe is one of ALL, SP500, NQ100 or DOW30. sort takes a field, which is close or a field the query uses such as daily.rsi14, and a direction of asc or desc. Without a sort, rows are in symbol order.
Example prompts
Ask in your own words. These are prompts you could use, each with a query your assistant could write for it.
“Find S&P 500 stocks with RSI under 30 that are still above their 200-day average, lowest RSI first.”
[Daily RSI(14) < 30]
AND [Daily Close > Daily SMA(200)]
AND [universe = SP500]“Which Nasdaq 100 stocks are within 5% of their 52-week high?”
[Daily Close >= Daily Week52High * 0.95]
AND [universe = NQ100]“Show me stocks where the 50-day EMA just crossed above the 200-day EMA.”
[Daily EMA(50) crosses_above Daily EMA(200)]“Screen for a P/E under 15, ROE over 10 and debt to equity under 0.5.”
[Fundamentals PE < 15]
AND [Fundamentals ROE > 10]
AND [Fundamentals DebtEquity < 0.5]“Which stocks have both daily and weekly RSI above 50?”
[Daily RSI(14) > 50]
AND [Weekly RSI(14) > 50]“Find stocks trading at more than 1.5 times their 20-day average volume.”
[Daily Volume > Daily SMA(20, Volume) * 1.5]Limits
- Results: 50 by default and 500 at most per scan. The match count is always the true total, and
truncatedis true when there are more matches than rows. - A long response is cut at about 200,000 characters of rows, and is marked truncated.
- Query length: 4,000 characters.
- Quota:
run_stock_scancounts as one request against your key's plan, shared with the other Data API tools. A free key has 300 requests per hour, 800 per day and 4,000 per week. See the API documentation for the other plans. - Data: end-of-day only, rebuilt at 5:15 PM Eastern on weekdays. Every result gives the date of the data.
Frequently asked questions
What is the AI Stock Scanner MCP?
It is a Model Context Protocol server that lets an AI assistant such as Claude run stock scans for you. It uses the same scan language and the same end-of-day data as the AI Stock Scan Builder on the website.
Does the server write the query?
No. Your assistant writes it. It reads the language reference from get_scan_syntax, writes a query, and fixes it from the error message if the query is rejected. The server only compiles and runs what it receives.
Do I need an API key?
Yes. It uses your StashGamma Data API key, and scans draw from the same hourly, daily and weekly quota as the data tools. The AI Stock Scan Builder on the website can run scans without a key or an account.
Can it see my saved scans or place trades?
No. These tools can only run a scan, check a query, and read the reference. They cannot read or change saved scans, reach another user's data, or place trades.
Is the data real-time?
No. Scans run on end-of-day data rebuilt at 5:15 PM Eastern on weekdays. Every result includes the date of the data.
What happens if there are more matches than I asked for?
The result gives the true match count and sets truncated to true. Pass a larger limit, up to 500, or a sort so the rows you get are the ones you want. Without a sort, rows are in symbol order.
Is a scan result a recommendation to buy a stock?
No. A scan only lists symbols that meet the conditions you set. StashGamma is for educational purposes and nothing here is investment advice.
Learn more
- AI Stock Scan Builder guide: the query syntax in full, with worked examples.
- AI Stock Scan Builder: try a query in the browser, with no key or account.
Related reading
Free Stock Data API
Start here — the free tier, no card required, 300 requests/hour.
EOD Data API Quickstart Guide
Get a key and pull your first end-of-day bars in under 5 minutes.
Historical Stock Data API
15 years of daily-to-yearly OHLCV across U.S.-listed tickers, for backtesting & research.
Free Stock Market APIs Compared
How the free tier stacks up against Alpha Vantage, IEX, and others.
OHLCV Data API
What OHLCV data is and exactly how the response is shaped.
MCP Server for Stock Data
Connect Claude, OpenAI, ChatGPT, or another MCP-capable agent directly to the data.
Options Analyzer MCP (no key)
Let Claude, OpenAI, or any MCP agent analyze a QQQ options trade — no API key needed.
Portfolio Tracker via MCP & CSV
Add positions from Claude or ChatGPT, or upload a CSV / Excel file — a private per-account portfolio.
Claude & ChatGPT Setup Guide
Click-by-click connector setup for Claude and ChatGPT, with your own key filled in.
Full API Documentation
Auth, endpoint reference, rate-limit headers, and error codes.
Ready to try it? Get your free API key — no card required.