MCP RAG + Agent Server for AI Tutor
Provides a RAG knowledge base backed by PostgreSQL with pgvector, enabling document ingestion and semantic search using cosine similarity.
Click on "Deploy 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., "@MCP RAG + Agent Server for AI TutorIngest my biology notes and answer: what is osmosis?"
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.
MCP RAG + Agent Server for AI Tutor
A complete Model Context Protocol (MCP) server that combines:
RAG (Retrieval-Augmented Generation) with PostgreSQL + pgvector
Free LLM integration via OpenRouter
Dynamic agent creation as an MCP tool
FastMCP framework for building the server
Features
Tools
ingest_documents— Import documents into the vector knowledge basesearch_knowledge— Semantic search using cosine similarityask_with_rag— Full RAG pipeline (retrieve + LLM generation)create_agent— Dynamically create and run specialized AI agents
Resources
knowledge://stats— Knowledge base statisticsknowledge://config— Current server configuration
Prompts
explain_concept— Generate explanation prompts for any concept
Related MCP server: KB-MCP Server
Architecture
User → MCP Client (VS Code Copilot) → MCP Server → PostgreSQL+pgvector → OpenRouter LLM
Setup
1. Start PostgreSQL + pgvector
docker run -d --name pgvector-demo \
-e POSTGRES_USER=tutor \
-e POSTGRES_PASSWORD=tutor123 \
-e POSTGRES_DB=ai_tutor \
-p 5432:5432 pgvector/pgvector:pg16
##2. Install dependencies
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -r requirements.txt
3. Configure .env
DATABASE_URL=postgresql://tutor:tutor123@localhost:5432/ai_tutor
OPENROUTER_API_KEY=sk-or-v1-your-key
OPENAI_API_KEY=sk-your-openai-key
OPENROUTER_MODEL=openrouter/free
EMBEDDING_MODEL=nvidia/nemotron-3-embed-1b:free
EMBEDDING_BASE_URL=https://openrouter.ai/api/v1
4. Run the server
python server.py
Testing
Use MCP Inspector:
fastmcp dev inspector server.py
Tech Stack
FastMCP (MCP SDK for Python)
PostgreSQL 16 + pgvector
OpenAI Python SDK (via OpenRouter)
Python 3.11+
License
Apache 2.0This server cannot be deployed
Maintenance
Related MCP Connectors
Ingest, manage, and retrieve documents for RAG-powered AI applications
- KumbukaOAuthai.kumbuka
Governed, auditable knowledge your team curates for its AI assistants, self-hostable
Shared knowledge base for AI agents. Semantic search across agents, no setup required — just a URL.
Cloud or self-hosted knowledge for AI agents: hybrid search, reranking, GraphRAG, scoped MCP tools.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables semantic search across text documents using vector embeddings stored in PostgreSQL. Provides multiple search modalities including semantic similarity, question/answer, and style-based search through a retrieval-augmented generation system.3Apache 2.0
- FlicenseAqualityNot gradedmaintenanceA local-first knowledge base server that enables AI clients to store, retrieve, and manage documents using semantic search. Provides privacy-focused, offline-capable memory for AI assistants with tools for ingesting, querying, updating, and deleting knowledge.7191 npm-
- FlicenseCqualityDmaintenanceEnables AI agents to ingest documents, generate embeddings, and perform semantic search via PostgREST APIs.3-
- AlicenseAqualityBmaintenanceEnables ingestion and semantic search over text documents using PostgreSQL + pgvector and OpenAI-compatible embeddings, allowing any LLM agent to retrieve relevant chunks for grounded answers.4AGPL 3.0