stock-research-assistant

stock-research-assistant

A stock research MCP server that enables natural-language queries for market data, watchlist management, company analysis, and research note tracking, using FastMCP and Databricks Lakebase Postgres.

Category
访问服务器

README

Stock Research Assistant MCP Server

A comprehensive stock research assistant built with FastMCP for Databricks AI/BI integration. Enables natural-language interaction with real market data, watchlist management, company analysis, and research note tracking.

Features

🎯 Watchlist Management

  • Track personal watchlists of tickers
  • Add/remove stocks with custom notes
  • View watchlist with live prices and performance

📊 Market Data

  • Real-time quotes from Massive Stocks API
  • Historical price data and performance metrics
  • Company fundamentals and profile information
  • Multi-ticker comparisons

📰 News & Research

  • Fetch and summarize recent company news
  • Save research notes with investment thesis
  • Set price targets and confidence levels
  • Flag notable price moves automatically

🗄️ Data Persistence

  • Lakebase Postgres backend for all user data
  • Complete schema for users, watchlists, prices, news, and research
  • Optimized for future semantic search capabilities

Architecture

┌─────────────────┐
│  AI/BI Agent    │  ← Natural language queries
└────────┬────────┘
         │
         ▼
┌─────────────────┐
│  FastMCP Server │  ← stocks_mcp_server.py
└────────┬────────┘
         │
    ┌────┴────┐
    ▼         ▼
┌─────────┐ ┌──────────────┐
│Lakebase │ │Massive Stocks│  
│Postgres │ │     API      │
└─────────┘ └──────────────┘

MCP Tools

The server exposes 10 agent tools:

Watchlist Tools

  • add_to_watchlist(ticker, watchlist_name, notes) - Add a stock to your watchlist
  • remove_from_watchlist(ticker, watchlist_name) - Remove a stock
  • get_watchlist(watchlist_name) - View all stocks with live prices

Market Data Tools

  • get_price_data(ticker, days) - Current and historical prices with performance summary
  • get_company_info(ticker) - Company fundamentals and profile
  • compare_tickers(tickers, metric) - Compare multiple stocks

Research Tools

  • get_recent_news(ticker, limit) - Fetch and summarize recent news
  • save_research_note(ticker, title, content, thesis, target_price, confidence) - Log analysis
  • flag_notable_moves(threshold_percent) - Alert on significant price changes

Utility

  • get_current_user() - Get authenticated user email

Setup Instructions

1. Set Up Databricks Secrets

You need two secrets:

Lakebase Connection URL

databricks secrets create-scope database
databricks secrets put-secret database lakebase-url

The value should be a standard Postgres connection URL:

postgresql://role:password@host:5432/databricks_postgres?sslmode=require

Massive Stocks API Key

databricks secrets create-scope massive
databricks secrets put-secret massive api-key

Get your API key from Massive Stocks API or similar provider.

2. Initialize Database Schema

Run the SQL schema against your Lakebase instance:

psql <lakebase-url> < schema_stocks.sql

This creates all required tables:

  • users - User profiles
  • watchlists - Named watchlists per user
  • watchlist_tickers - Stocks in watchlists
  • companies - Company profiles and fundamentals
  • price_snapshots - Historical price data
  • news_articles - News articles per ticker
  • research_notes - User research and theses
  • analysis_reports - Agent-generated reports

3. Deploy as Databricks App

cd stocks_research_assistant
databricks apps create stock-research-assistant \
  --description "Stock Research Assistant with MCP" \
  --source-code-path .

databricks apps deploy stock-research-assistant

Or use the UI:

  1. Go to Databricks Apps → Create App
  2. Set source path to /Workspace/Users/<your-email>/databricks-lakebase-app-day-3-hw/stocks_research_assistant
  3. Click Deploy

4. Connect to AI Playground or Agent Bricks

Once deployed, your app URL will be: https://stock-research-assistant-<id>.aws.databricksapps.com

Option A: AI Playground

  • The Playground auto-discovers workspace MCP servers
  • Your tools should appear automatically

Option B: Agent Bricks

  1. Go to Machine Learning → Agents
  2. Create a new agent
  3. Add External Tool → MCP Server
  4. URL: https://stock-research-assistant-<id>.aws.databricksapps.com

Example Usage

Natural Language Queries

Managing Watchlists:

"Add AAPL and MSFT to my watchlist"
"Show me my watchlist"
"Remove TSLA from my default watchlist"

Market Research:

"What's the price of NVDA over the last 30 days?"
"Compare GOOGL and META on performance"
"Show me recent news for AAPL"

Investment Analysis:

"Save a research note for TSLA: Bullish on FSD progress, target $350"
"Which stocks in my watchlist moved more than 5% today?"
"Get company fundamentals for AMD"

Direct Tool Calls

You can also call tools directly via the MCP protocol:

# Add to watchlist
{
  "tool": "add_to_watchlist",
  "arguments": {
    "ticker": "AAPL",
    "watchlist_name": "tech_giants",
    "notes": "Strong services revenue, AI potential"
  }
}

# Get price data
{
  "tool": "get_price_data",
  "arguments": {
    "ticker": "NVDA",
    "days": 90
  }
}

# Save research note
{
  "tool": "save_research_note",
  "arguments": {
    "ticker": "TSLA",
    "title": "Q4 2025 Analysis",
    "content": "Strong deliveries, margin expansion expected...",
    "thesis": "Bullish on FSD monetization and energy storage growth",
    "target_price": 350.0,
    "confidence": "high"
  }
}

Database Schema

Key tables and relationships:

users
  ├── watchlists
  │     └── watchlist_tickers
  ├── research_notes
  └── analysis_reports

companies (ticker lookup)
price_snapshots (time series)
news_articles (ticker, published_at)

API Rate Limits

Massive Stocks API (Polygon.io) free tier:

  • 5 API calls per minute
  • Delayed data (15-minute delay for stocks)

For production use, upgrade to a paid plan for:

  • Real-time data
  • Higher rate limits
  • WebSocket streaming

Future Enhancements

Context Engineering (Semantic Search)

The schema includes VECTOR columns for embeddings:

  • companies.profile_embedding
  • news_articles.content_embedding
  • research_notes.content_embedding

Enables queries like:

  • "Find companies exposed to rising interest rates in regional banking"
  • "Show me research notes about AI chip manufacturers"
  • "Surface news about EV battery supply chain issues"

Implement with:

  • Databricks sentence-transformers models
  • pgvector extension in Lakebase
  • Semantic similarity search

Additional Features

  • Real-time price alerts via WebSocket
  • Technical analysis indicators (RSI, MACD, etc.)
  • Portfolio tracking and P&L
  • Earnings calendar integration
  • Options data and Greeks
  • Sector rotation analysis

Troubleshooting

"API request failed"

  • Check that your Massive Stocks API key is valid
  • Verify the secret is properly configured
  • Check API rate limits

"Could not retrieve Lakebase connection"

  • Verify Lakebase secret is set correctly
  • Test connection string manually: psql <connection-url>
  • Check that Lakebase endpoint is running

"No results returned for {ticker}"

  • Ticker may be invalid or delisted
  • Use search_companies tool to find correct symbol
  • Some tickers may not be available on free tier

App deployment failed

  • Check logs: databricks apps logs stock-research-assistant --tail 100
  • Verify all dependencies in requirements.txt
  • Ensure app.yaml env vars match your secret scopes

Files

stocks_research_assistant/
├── README.md                      # This file
├── app.yaml                       # Databricks App configuration
├── requirements.txt               # Python dependencies
├── schema_stocks.sql              # Lakebase schema
├── lakebase.py                    # Postgres connection helper
├── massive_stocks_broker.py       # Massive API client
└── stocks_mcp_server.py           # FastMCP server with tools

License

MIT

Support

For issues or questions:

  1. Check the troubleshooting section
  2. Review Databricks Apps documentation
  3. Check FastMCP docs at https://gofastmcp.com
  4. Review Massive Stocks API docs at https://polygon.io/docs

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选