How to Use an MCP Server for Stock Analysis with Claude
What Is MCP?
Model Context Protocol (MCP) is an open standard that lets AI assistants like Claude connect to external data sources and tools. Instead of copying data into a prompt, you install an MCP server that gives the AI direct access to a service's API. The AI decides when to call which tool based on your question — no manual API calls, no code, no prompt engineering.
Chart Library's MCP server gives Claude (and any MCP-compatible AI) access to 25M+ pre-computed chart pattern embeddings, real-time regime data, sector analysis, and forward return statistics. Ask a question in plain English, and the AI calls the right tools behind the scenes.
Installation: Two Commands
The MCP server is published on PyPI and takes about 30 seconds to set up. You need Python 3.9+ and a free Chart Library API key.
- Install the package: pip install chartlibrary-mcp
- Get a free API key at chartlibrary.io/developers (200 calls/day on the free tier)
- Add the server to Claude Desktop: open Settings > Developer > MCP Servers, click 'Add,' and enter the command: chartlibrary-mcp --api-key YOUR_KEY
- Restart Claude Desktop. You'll see the Chart Library tools appear in the tools panel.
Note:The MCP server also works with Cursor, Windsurf, and any other editor or agent framework that supports the MCP standard. The setup is the same — just point it at the chartlibrary-mcp command.
What the 19 Tools Do
The MCP server exposes a curated tool surface organized into a few intent groups. You never need to call them directly — Claude picks the right tool based on your question. But knowing what's available helps you ask better questions.
- Pattern Intelligence (3 tools): Search for similar chart patterns by ticker, analyze a specific ticker+date combination, and get full intelligence reports with AI summaries and forward return statistics.
- Market Context (4 tools): Get the current market regime for SPY/QQQ, check sector rotation rankings, detect crowding (many stocks trading the same pattern), and run scenario analysis for hypothetical market moves.
- Discovery (3 tools): Browse today's top patterns from the discover page, get trending tickers, and find the most interesting setups ranked by volume and pattern quality.
- Portfolio & Alerts (4 tools): Add holdings, get portfolio pattern analysis, set up pattern alerts, and check alert history.
- Data & Utilities (5 tools): Look up ticker details, get historical price data, check API usage, retrieve forward test accuracy stats, and access the track record dashboard.
Example Conversation with Claude Desktop
Here's a real conversation showing how Claude uses the MCP tools automatically. You just ask questions — Claude decides which tools to call.
You: "What does NVDA's chart look like right now? Anything interesting?" Claude calls: get_intelligence(symbol="NVDA") Claude: "NVDA's current intraday pattern closely matches 10 historical setups. The top match is AMD from August 2024 at 93% similarity. Looking at forward returns across all matches: the average 5-day return is +1.6% with 7 of 10 matches moving higher. The AI summary describes this as a post-earnings consolidation pattern with historical precedent favoring upside continuation, though 2 of the 10 matches saw drawdowns of 3%+ before recovering."
You: "What's the broader market doing? Should I be worried about anything?" Claude calls: get_regime(), get_crowding() Claude: "The current SPY regime most closely resembles March 2024 — a slow grind higher on moderate volume. 8 of 10 similar periods saw gains over the next 10 days. However, the crowding detector shows elevated correlation across tech stocks right now, which historically precedes short-term pullbacks in about 40% of cases. Not a red flag, but worth monitoring."
MCP vs. REST API: When to Use Which
The MCP server and the REST API access exactly the same data and endpoints. The difference is how you interact with them.
Use MCP when you want conversational access — asking questions in natural language, getting synthesized answers, and having the AI chain multiple calls together automatically. It's ideal for research sessions, market check-ins, and exploratory analysis where you don't know exactly what you're looking for.
Use the REST API when you're building automated systems — trading bots, dashboards, scheduled reports, or any programmatic workflow where you need structured JSON responses and precise control over which endpoints you call. The API is also better for high-volume use cases since you can batch requests and handle rate limits programmatically.
- Conversational research and exploration: MCP
- Automated trading systems and bots: REST API
- Building dashboards or apps: REST API
- Ad-hoc market analysis during the trading day: MCP
- Multi-agent workflows (LangChain, CrewAI): Either — MCP for simple setups, REST API for custom tool definitions
Tip:You can use both. Many users keep the MCP server running in Claude Desktop for quick research while also calling the REST API from their trading scripts.
Get Started
The MCP server is free to install and the free API tier gives you 200 calls per day — more than enough for a full day of research conversations. Install it with pip install chartlibrary-mcp, add your API key, and start asking Claude about any stock, market regime, or chart pattern.
For more advanced use cases, check out the LangChain and CrewAI tutorials on the Chart Library blog, or browse the full API documentation at chartlibrary.io/developers.
Install the MCP server: pip install chartlibrary-mcp. Get a free API key at chartlibrary.io/developers.
Ready to try Chart Library?
Anchor any ticker + date — see what history says about your setup, with cohort statistics, feature attribution, and AI narrative.
Try it freeLearn the methodology
Chart Library is built on four canonical concepts. Read the pillars to understand what backs the numbers in this post:
Related Articles
How to Build a Market-Research Agent Crew in 2026: Frameworks, Data Costs, and the Missing Primitive
A practical 2026 guide to building a multi-agent market-research crew — the specialist roles, what the data actually costs ($0 to ~$250/mo), the frameworks that wire it together, and the one calibrated-base-rate node most crews are missing.
What Does It Cost to Build an AI Trading Agent in 2026? A Data-Stack Breakdown
The honest 2026 line-item cost of feeding a multi-agent trading crew real market data — which lanes are free (SEC EDGAR, FRED), which actually cost money (price, options, news), and the two realistic budgets: a $0–30/mo one-day-lagged crew vs a ~$180–270/mo live-everything crew.
The Oracle Fallacy: Why Your Trading Agent's Backtest Lies — and What Calibrated Base Rates Fix
Most trading-agent backtests and demos quietly peek at the future they claim to predict — the Oracle Fallacy. Here's how it sneaks in (lookahead bias, hindsight base rates, LLMs inventing odds), why it inflates nearly every result, and the honest fix: real historical analogs plus time-gated calibration with provenance.