Get the FREE Ultimate OpenClaw Setup Guide →

stock_mcp_server

MCP server from ingpoc/stock_mcp_server

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio ingpoc-stock_mcp_server python server.py \
  --env CACHE_TTL="3600" \
  --env LOG_LEVEL="INFO" \
  --env MONGODB_URI="mongodb://localhost:27017" \
  --env CACHE_ENABLED="True" \
  --env MCP_SERVER_NAME="stock-analysis-mcp" \
  --env MONGODB_DB_NAME="stock_data" \
  --env MCP_SERVER_VERSION="0.1.0" \
  --env ALPHA_VANTAGE_API_KEY="your_api_key_here" \
  --env ALPHA_VANTAGE_BASE_URL="https://www.alphavantage.co/query" \
  --env MONGODB_HOLDINGS_COLLECTION="holdings" \
  --env ALPHA_VANTAGE_RATE_LIMIT_DAY="500" \
  --env MONGODB_FINANCIALS_COLLECTION="detailed_financials" \
  --env ALPHA_VANTAGE_DEFAULT_EXCHANGE="NSE" \
  --env ALPHA_VANTAGE_RATE_LIMIT_MINUTE="5" \
  --env MONGODB_KNOWLEDGE_GRAPH_COLLECTION="stock_knowledge_graph"

How to use

This MCP server is designed to help Claude analyze your Indian stock portfolio by connecting to a local MongoDB data store, querying stock data directly, and leveraging Alpha Vantage for NSE/BSE market data within the free tier limits. It also maintains a persistent knowledge graph of your stock analyses to improve context over time. Once running, Claude can access tools to summarize portfolios, analyze segments of holdings, fetch stock-specific metrics, and generate tailored recommendations for NSE/BSE stocks. The server segments large portfolios into smaller analyses to avoid timeouts and to provide quicker, actionable insights.

How to install

Prerequisites:

  • Python 3.9+
  • MongoDB running on localhost:27017 with database "stock_data"
  • Alpha Vantage API key (free tier supported)
  • Claude Desktop application

Setup steps:

  1. Clone the repository and navigate to the project folder:
git clone <repository-url>
cd stock-mcp-server
  1. Create and activate a Python virtual environment (optional but recommended):
python -m venv venv
source venv/bin/activate  # on macOS/Linux
venv\Scripts\activate     # on Windows
  1. Install dependencies:
pip install -r requirements.txt
  1. Create a .env file from the example and configure settings:
cp .env.example .env

Edit .env to configure:

  • MONGODB_URI=mongodb://localhost:27017
  • MONGODB_DB_NAME=stock_data
  • ALPHA_VANTAGE_API_KEY=your_api_key_here
  • ALPHA_VANTAGE_DEFAULT_EXCHANGE=NSE # NSE or BSE

5) Start the MCP server:
```bash
python server.py
  1. Configure Claude Desktop to connect to this MCP server (as shown in the README example). Ensure the server name in Claude config matches MCP_SERVER_NAME and that all paths are absolute.

Additional notes

Tips and common issues:

  • Ensure MongoDB is running and accessible at the configured URI. If connection issues arise, verify MONGODB_URI and MongoDB service status.
  • For Claude tool availability, after starting the server, restart Claude or open a new conversation to load the new tools.
  • The server uses a segmented analysis approach for large portfolios; you can explicitly request segments and control segment size with the segment_size parameter.
  • If you encounter Python path issues in Claude configuration, provide the full path to the Python executable and the full path to server.py.
  • Manage Alpha Vantage rate limits by relying on the built-in limiter; for larger analyses, consider segmenting requests to stay within free-tier quotas.
  • Environment variables in the Claude config must exactly match the MCP configuration (MCP_SERVER_NAME should match the key value).
  • Review logs at Claude logs folder (for example, ~/Library/Logs/Claude/mcp-server-stock-analysis-mcp.log) for troubleshooting tool loading or connection problems.

Related MCP Servers

Sponsor this space

Reach thousands of developers