stock-rag-mcp
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@stock-rag-mcpWho is the CEO of Zenith Capital?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Stock Agent — RAG with LangChain + pgVector + Ollama
A fully local Retrieval-Augmented Generation (RAG) sample app. It loads details about several stock-trading companies, stores their embeddings in a pgVector database, and answers questions using a local LLM served by Ollama — no cloud API keys, nothing leaves your machine.
┌──────────┐ load+split ┌──────────────┐ embed (Ollama) ┌───────────┐
│ data/*.md │ ─────────────▶ │ LangChain │ ───────────────▶ │ pgVector │
└──────────┘ │ ingest.py │ │ (Postgres)│
└──────────────┘ └─────┬─────┘
│ top-k
┌──────────┐ question ┌──────────────┐ context + prompt │
│ you │ ────────────▶ │ query.py │ ◀───────────────────────┘
└──────────┘ │ (RAG chain) │ ── Ollama LLM ──▶ grounded answer
└──────────────┘Tech stack
LangChain — orchestration (loaders, splitter, retriever, prompt chain)
pgVector — Postgres extension used as the vector store
Ollama — runs the local LLM (
llama3.1) and embedding model (nomic-embed-text)MCP — an optional server exposing the pipeline as tools to MCP clients like Claude Desktop (see below)
Related MCP server: MCP Generix
Prerequisites
Install the pieces below. Commands assume Windows + PowerShell.
Python version: use Python 3.12 (or 3.11). The pinned dependencies in
requirements.txtship prebuilt wheels for these versions. On Python 3.13/3.14 some packages (e.g.numpy 1.26.4) have no wheel yet and fall back to a source build that fails without a C compiler. Ifpy -3.12isn't available, install it withwinget install Python.Python.3.12.
1. Ollama (local LLM)
Download and install from https://ollama.com/download (Windows installer). Then pull the two models this app uses:
ollama pull llama3.1
ollama pull nomic-embed-textOllama runs a server at http://localhost:11434 automatically after install.
Verify:
ollama listTip:
llama3.1(8B) needs ~5–6 GB RAM. If low on memory, use a smaller model likellama3.2:3band setLLM_MODEL=llama3.2:3bin.env.
2. Postgres with pgVector
Option A — Docker. Install Docker Desktop from https://www.docker.com/products/docker-desktop/, then from this folder:
docker compose up -dThat starts Postgres 16 with the pgvector extension on port 5432
(db stockrag, user/pass postgres/postgres).
On Windows, Docker Desktop's engine requires WSL2. If WSL2 isn't installed,
docker compose up -dfails with a500 Internal Server Errorand nothing listens on 5432. Install it from an admin terminal withwsl --install(needs a reboot), or use Option B, which needs neither WSL2 nor Docker.
Option B — native Postgres (no Docker/WSL2 needed). Install Postgres 16:
winget install PostgreSQL.PostgreSQL.16The installer runs a Windows service on port 5432 with superuser
postgres/postgres — matching the defaults in config.py. Postgres does
not bundle pgvector, so install it too:
Download the prebuilt Windows binary matching your Postgres minor version (e.g.
vector.v0.8.3-pg16.zipfor Postgres 16.14) from andreiramani/pgvector_pgsql_windows. (Community-compiled — a third-party binary. If you'd rather not trust one, build from source with the Visual Studio C++ tools instead.)Copy its contents into your Postgres install (needs admin):
vector.dll→C:\Program Files\PostgreSQL\16\lib\, and everything undershare\extension\→C:\Program Files\PostgreSQL\16\share\extension\.
Then create the database and enable the extension (psql lives in
C:\Program Files\PostgreSQL\16\bin):
CREATE DATABASE stockrag;
\c stockrag
CREATE EXTENSION IF NOT EXISTS vector;3. Python dependencies
Create the venv with Python 3.12 (see the version note above):
cd C:\Users\khema\stock-rag
py -3.12 -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -r requirements.txtConfigure
copy .env.example .envEdit .env only if your Postgres credentials/host differ from the defaults.
Run
Step 1 — ingest the company data into pgVector (run once, or after
changing files in data/):
python ingest.pyStep 2 — ask questions using the local LLM:
python query.py "Who is the CEO of Zenith Capital?"
python query.py "Which company does crypto market making and is not publicly listed?"
python query.py "Compare the 2024 revenue of Summit Brokerage and Meridian Securities."Or interactive mode:
python query.py
> What ticker does Meridian Securities trade under, and on which exchange?Each answer is grounded strictly in the retrieved context and prints its sources.
Example output

The sample data
Four fictional stock-trading companies live in data/:
File | Company | Ticker |
| Zenith Capital Markets, Inc. | ZCM |
| Meridian Securities Group PLC | MSG.L |
| Apex Trading Technologies Ltd. | (private) |
| Summit Brokerage Corporation | SMB |
Drop in your own .md, .txt, or .pdf files and re-run python ingest.py
to expand the knowledge base.
Use it from an MCP client (Claude Desktop, IDEs, …)
The same RAG pipeline is exposed as an MCP server (mcp_server.py) so any MCP client can call it as tools. Three tools are published:
Tool | What it does |
| Full RAG answer (retrieve + local LLM) with sources |
| Raw top-k retrieved chunks, no LLM — fast lookup |
| Lists the documents loaded in the knowledge base |
You must still run python ingest.py once first, and have Ollama + pgVector
running (the server calls them on the first tool invocation).
Wiring it into Claude Desktop
Copy the sample config into Claude Desktop's config file:
%APPDATA%\Claude\claude_desktop_config.json(use claude_desktop_config.example.json as the template — adjust the two absolute paths if your project isn't atC:\Users\khema\stock-rag).Make sure the
commandpoints at the venv's Python (.venv\Scripts\python.exe) so the dependencies are on the path.Fully quit and reopen Claude Desktop. The
stock-ragtools appear under the tools (🔧) menu.Ask, e.g. "Use stock-rag to tell me which company does crypto market making." Claude will call
ask_companiesand answer from your local data.
The server speaks MCP over stdio, which is what Claude Desktop and most IDE MCP integrations expect. The client launches the process for you — you don't run
mcp_server.pyyourself in normal use.
Quick sanity check (optional)
Install the MCP Inspector and point it at the server:
npx @modelcontextprotocol/inspector .\.venv\Scripts\python.exe mcp_server.pyProject layout
stock-rag/
├─ data/ # source documents (the RAG knowledge base)
├─ config.py # env-driven settings
├─ ingest.py # load → split → embed → store in pgVector
├─ query.py # retrieve → prompt → local LLM answer (CLI + importable ask())
├─ mcp_server.py # MCP server exposing the RAG tools
├─ docker-compose.yml # Postgres + pgvector
├─ claude_desktop_config.example.json # sample MCP client config
├─ requirements.txt
└─ .env.exampleTroubleshooting
No module named 'langchain_ollama'(or any dependency) — you're running the system Python, not the venv. Activate it (.\.venv\Scripts\Activate.ps1) or call it directly:.\.venv\Scripts\python.exe ingest.py.Socket is not connected/connection refusedon 5432 — Postgres isn't running. Start your native Postgres service, or Docker Desktop +docker compose up -d.docker compose up→500 Internal Server Error— Docker's engine needs WSL2. Install it (wsl --installfrom an admin terminal, then reboot) or use native Postgres (Prerequisites → Option B).Failed to create vector extension/could not open extension control file "vector.control"— pgvector isn't installed into Postgres. See Prerequisites → Option B.pip installfails buildingnumpy— you're on Python 3.13/3.14. Rebuild the venv with Python 3.12 (see the version note under Prerequisites).model 'llama3.1' not found— runollama pull llama3.1.Ollama call failed/ connection error — make sure the Ollama app is running (ollama listshould respond).Slow first answer — the model loads into memory on first use; later queries are faster.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/hemanthkumarkp/stock-analysis-rag-langchain-olama-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server