How to Build an MCP Stock Analysis Server

“The best software is written and rewritten and rewritten again. Each iteration makes it a little bit better.” — Brian Kernighan

Hey folks! If you’ve been following my MCP stock analysis server series, you’ve seen how we built up from a basic tutorial in Part 1 to adding sophisticated features in Part 2. Today, I’m excited to share the next chapter in this journey—a complete ground-up rebuild that transforms our educational MCP server into a production-ready personal trading platform.

Meet MaverickMCP: the evolution of everything we’ve learned, rebuilt for real-world use.

The Problem with Tutorial Code

Don’t get me wrong. mcp-trader served its purpose beautifully. It was perfect for teaching MCP concepts, demonstrating financial APIs, and gaining an initial understanding of building an MCP server from scratch. But the approach suffered from a number of issues:

  • Limited Scope: 7-8 basic tools vs. the 29 professional-grade tools I actually needed
  • Educational Focus: Great for learning, but lacking the polish for daily trading decisions
  • Missing Developer Experience: No hot reload, limited error handling, slow startup times
  • Performance Gaps: No parallel processing, basic caching, single-threaded screening
  • Configuration Complexity: Multiple setup steps, unclear error messages

The classic problem: tutorial code that works great for demos but falls short when you need to rely on it every day.

Enter MaverickMCP: Built for the Long Haul

MaverickMCP isn’t just an upgrade, it’s a complete architectural rethink. I had initially planned to create a commercial MCP offering in this space, but opted for open-source in the end to help everyone.

The Personal Trading Platform Philosophy

The biggest shift? Removing all the complexity I didn’t need.

Gone are the authentication systems, billing integrations, and multi-user considerations. MaverickMCP embraces being a personal tool, and it’s better for it. No login screens, no API keys to manage (beyond data providers), no subscription logic. Just pure financial analysis power.

This “personal-first” approach let me focus on what actually matters:

  • Reliability: Zero authentication failures blocking your analysis
  • Performance: Every optimization benefits you directly
  • Simplicitymake dev and you’re running
  • Features: 29 tools covering everything from basic quotes to portfolio optimization

The Developer Experience Revolution

One area where I went completely overboard (in the best way) is developer experience. If you’re going to use a tool daily, it better be pleasant to work with:

One-Command Everything:

Bash
make dev    # Start everything
make test   # Run tests (5-10 seconds)
make lint   # Check code quality
make format # Auto-format code

Smart Error Handling:
Instead of cryptic pandas errors, you get helpful suggestions:

Plaintext
Error: KeyError 'Close'
→ Suggestion: Column should be 'close' (lowercase). DataFrame columns: ['open', 'high', 'low', 'close', 'volume']
→ Fix: Use df['close'] instead of df['Close']

Hot Reload Development:

Bash
uv run python tools/hot_reload.py
# Auto-restart server on any code change

Parallel Everything:
4x faster stock screening with parallel processing. What used to take 40 seconds now completes in 10.

The Technical Evolution

Let me walk you through some key improvements that make MaverickMCP feel like a different beast entirely:

Modern Python Tooling

uv Package Manager:

Bash
# Old way (mcp-trader)
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

# New way (maverick-mcp)
uv sync  # One command, lightning fast

The switch to uv alone cut setup time from 2+ minutes to 15 seconds.

Type Checking Evolution:
Migrated from mypy to modern type checkers for instant feedback:

Bash
uvx ty check .  # Ultra-fast type checking, no installation needed

FastMCP 2.0 Architecture

The server architecture got a complete overhaul:

Python
# Old approach - basic MCP tools
@server.call_tool()
async def handle_call_tool(name: str, arguments: dict):
    if name == "analyze-stock":
        # Handle individual tool
        
# New approach - organized routers
@mcp.tool()
async def get_full_technical_analysis(ticker: str):
    """Comprehensive technical analysis with 20+ indicators."""
    # Professional-grade analysis
    
@mcp.tool() 
async def get_maverick_stocks(min_price: float = 5.0):
    """Bullish momentum screening with parallel processing."""
    # 4x faster with ProcessPoolExecutor

Smart Caching Strategy

The caching system got completely rebuilt:

Python
# Intelligent cache with graceful fallbacks
class CacheService:
    def __init__(self):
        self.redis_client = self._try_redis_connection()
        self.memory_cache = {}  # Fallback
        
    async def get(self, key: str):
        # Try Redis first, fall back to memory
        if self.redis_client:
            return await self.redis_client.get(key)
        return self.memory_cache.get(key)

No more Redis connection failures breaking your analysis. It just works.

Database Flexibility

SQLAlchemy integration with your choice of database:

Bash
# Works with PostgreSQL for production
DATABASE_URL=postgresql://localhost/maverick_mcp

# Or SQLite for simplicity  
DATABASE_URL=sqlite:///maverick.db

# Or skip database entirely - works fine in memory

Tool Arsenal: From 7 to 29 Professional Tools

The tool expansion tells the real story. We went from basic educational tools to a comprehensive trading platform:

Original mcp-trader (7-8 tools):

  • Basic technical analysis
  • Simple relative strength
  • Volume profile
  • Pattern detection
  • Position sizing
  • Stop suggestions

MaverickMCP (29 tools):

Stock Data & Analysis:

  • fetch_stock_data – Historical data with intelligent caching
  • fetch_stock_data_batch – Parallel batch fetching
  • get_news_sentiment – News sentiment analysis
  • get_full_technical_analysis – 20+ indicators

Professional Screening:

  • get_maverick_stocks – Bullish momentum (4x faster)
  • get_maverick_bear_stocks – Bearish setups
  • get_trending_breakout_stocks – Strong uptrend identification
  • get_all_screening_recommendations – Combined results

Portfolio Management:

  • risk_adjusted_analysis – Position sizing with risk metrics
  • portfolio_correlation_analysis – Correlation matrices
  • compare_tickers – Side-by-side comparisons

Market Intelligence:

  • Real-time market movers
  • Sector performance analysis
  • Economic indicators
  • Earnings calendar data

Getting Started is Actually Easy

The setup experience is night and day different:

Bash
# Clone and go
git clone https://github.com/wshobson/maverick-mcp.git
cd maverick-mcp

# One command setup
uv sync

# Add your (free) Tiingo API key
cp .env.example .env
# Edit .env to add TIINGO_API_KEY

# Start everything
make dev

Claude Desktop Configuration:

JSON
{
  "mcpServers": {
    "maverick-mcp": {
      "command": "npx",
      "args": ["-y", "mcp-remote", "http://localhost:8000/sse"]
    }
  }
}

That’s it. MaverickMCP tools are now available in Claude Desktop.

Real-World Usage Examples

Here’s what daily usage looks like now:

Morning Market Analysis:

Plaintext
"Give me a full technical analysis of NVDA and compare it to the semiconductor sector"

Screening for Opportunities:

Plaintext
"Show me bullish momentum stocks above $50 with strong relative strength"

Portfolio Risk Assessment:

Plaintext
"Analyze the correlation between my tech holdings: AAPL, MSFT, GOOGL, NVDA"

Position Sizing:

Plaintext
"Help me size a position in TSLA with a $15 stop loss and 2% portfolio risk"

The difference? These queries now return professional-grade analysis in seconds, not the basic educational responses from the original server.

Performance That Actually Matters

The performance improvements are dramatic:

  • 4x Faster Screening: Parallel processing cut screening time from 40s to 10s
  • Smart Caching: Repeated analysis is instant with Redis caching
  • < 3 Second Startup: Fast development iteration with ./tools/fast_dev.sh
  • 5-10 Second Tests: Quick feedback loop for development

Lessons Learned from the Journey

What Worked from the Tutorial

  • MCP as a Protocol: Still the right choice for AI tool integration
  • Tiingo API: Remains excellent for reliable market data
  • Technical Analysis Core: The fundamental analysis approach was sound

What Needed to Change

  • Developer Experience: Tutorial code doesn’t prioritize this, production code must
  • Performance: Educational examples focus on clarity, real usage demands speed
  • Error Handling: Tutorials show happy paths, production needs comprehensive error handling
  • Architecture: Monolithic tutorial files vs. organized domain-driven design

The Road Ahead

MaverickMCP represents where I wanted mcp-trader to evolve. It’s not just a tutorial anymore, it’s a trading tool I use every day. But this is still just the beginning:

Coming Soon:

  • Options Analysis: Pricing models and strategy evaluation
  • Backtesting Engine: Test strategies on historical data
  • Real-time Alerts: Price and indicator notifications
  • Custom Strategies: Framework for personalized trading rules

Community Contributions:
The GitHub repo is MIT licensed and ready for contributions. Whether you’re adding new indicators, improving performance, or enhancing the developer experience—all contributions are welcome.

Try MaverickMCP Today

Ready to upgrade from educational to production? The setup is simpler than the original tutorial:

  1. Clone the repogit clone https://github.com/wshobson/maverick-mcp.git
  2. Install dependenciesuv sync
  3. Configure API key: Add your Tiingo key to .env
  4. Start the servermake dev
  5. Connect Claude Desktop: Use the mcp-remote bridge configuration

Within 5 minutes, you’ll have a professional-grade stock analysis platform running locally.

For readers who want an even more complete trading solution, I invite you to explore Capital Companion, my full-featured AI trading assistant with advanced portfolio management, multi-timeframe analysis, and intelligent trade execution features.

Conclusion

The evolution from mcp-trader to MaverickMCP represents more than just adding features—it’s the difference between tutorial code and production software. We’ve moved from educational examples to a platform I trust with real trading decisions.

This journey reinforced a key lesson: start with tutorials, but don’t stay there. The constraints that make tutorials great (simplicity, focus, clarity) are exactly what limit them for real-world use. MaverickMCP embraces complexity where it adds value and ruthlessly removes it where it doesn’t.

Whether you’re building your own financial tools, exploring MCP development, or just want better stock analysis in Claude Desktop, I hope MaverickMCP serves as both a useful tool and a blueprint for turning educational projects into production platforms.

The complete code is available on GitHub, and as always, I’d love to hear about your experiences building with MCP.

Happy trading, and may your backtests be profitable! 📈


Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top