A starter MCP server template that exposes RAG-style retrieval tools using Python.
This project demonstrates how to connect document retrieval capabilities to an MCP-compatible client through a clean, language-agnostic architecture.
- MCP server runtime using Python
- Tool registration through FastMCP
- Local MCP client for testing tool calls
- Structured tool outputs suitable for downstream LLM use
- Document loading from local files
- Text chunking
- Embedding generation using OpenAI
- Persistent vector storage with ChromaDB
- Retrieval of relevant chunks for a question
- Source tracking in results
list_sources_toolsearch_documents_toolretrieve_chunks_tool
This repo separates concerns into layers:
- MCP layer → tool registration and runtime
- Handler layer → tool implementations
- RAG layer → document loading, chunking, embeddings, vector search
- Client layer → local test harness
Flow: User → MCP Client → MCP Server → Tools → RAG Layer → OpenAI + ChromaDB → Structured Results
- list_sources_tool
- search_documents_tool
- retrieve_chunks_tool
main.py
client.py
server/
rag/
data/
outputs/
pip install -r requirements.txt
Create .env: OPENAI_API_KEY=your_openai_api_key_here
python main.py
python client.py
Star, fork, and extend this MCP-based retrieval service.