DEV Community

grahammccain
grahammccain

Posted on • Originally published at chartlibrary.io

How to Use an MCP Server for Stock Analysis with Claude

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.

Chart Library's MCP server gives Claude (and any MCP-compatible AI) access to 24 million pre-computed chart pattern embeddings, real-time regime data, sector analysis, and forward return statistics.

Installation: Two Commands

pip install chartlibrary-mcp
Enter fullscreen mode Exit fullscreen mode
  1. Get a free API key at chartlibrary.io/developers (200 calls/day free)
  2. Add the server to Claude Desktop: Settings > Developer > MCP Servers > Add
  3. Enter the command: chartlibrary-mcp --api-key YOUR_KEY
  4. Restart Claude Desktop -- Chart Library tools appear in the tools panel

The MCP server also works with Cursor, Windsurf, and any editor or agent framework that supports MCP.

What the 19 Tools Do

You never call them directly -- Claude picks the right tool based on your question:

  • Pattern Intelligence (3 tools): Search for similar chart patterns, analyze ticker+date combos, get full intelligence reports with AI summaries
  • Market Context (4 tools): Market regime for SPY/QQQ, sector rotation rankings, crowding detection, scenario analysis
  • Discovery (3 tools): Today's top patterns, trending tickers, interesting setups
  • Portfolio & Alerts (4 tools): Add holdings, portfolio analysis, pattern alerts
  • Data & Utilities (5 tools): Ticker lookup, historical prices, API usage, accuracy stats

Example Conversation

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. The average 5-day return is +1.6% with 7 of 10 matches moving higher."

You: "What's the broader market doing? Should I be worried?"

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 10 days. However, the crowding detector shows elevated correlation across tech stocks, which historically precedes short-term pullbacks in about 40% of cases."

MCP vs. REST API: When to Use Which

Both access the same data. The difference is the interface:

Use Case Best Choice
Conversational research MCP
Automated trading systems REST API
Building dashboards REST API
Ad-hoc market analysis MCP
Multi-agent workflows Either

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

pip install chartlibrary-mcp
Enter fullscreen mode Exit fullscreen mode

The free tier gives you 200 calls per day -- more than enough for a full day of research. For more advanced use cases, check out the LangChain tutorial and CrewAI tutorial.


Chart Library: 24 million chart pattern embeddings. 10 years of history. Pattern intelligence for AI agents. chartlibrary.io/developers

Top comments (0)