A document knowledge base system that enables users to upload PDFs and query them semantically through a web interface or via the Model Context Protocol, allowing integration with AI tools like Cursor.
A powerful document knowledge base system that leverages PDF processing, vector storage, and MCP (Model Context Protocol) to provide semantic search capabilities for PDF documents. This system allows you to upload, process, and query PDF documents through a modern web interface or via the MCP protocol for integration with AI tools like Cursor.
The system consists of:
Clone the repository:
git clone https://github.com/yourusername/PdfRagMcpServer.git cd PdfRagMcpServer
Install uv if you don't have it already:
curl -sS https://astral.sh/uv/install.sh | bash
Install dependencies using uv:
uv init . uv venv source .venv/bin/activate uv pip install -r backend/requirements.txt
Start the application with the convenient script:
uv run run.py
Access the web interface at http://localhost:8000
Using with Cursor
Go Settings -> Cursor Settings -> MCP -> Add new global MCP server, paste below into your Cursor ~/.cursor/mcp.json file. See Cursor MCP docs for more info.
{ "mcpServers": { "pdf-rag": { "url": "http://localhost:7800/mcp" } } }
You could also change localhost into the host ip you deployed the service. After this confige added to the mcp json, you will see the mcp server showes at the Cursor mcp config page, switch it on to enable the server:
If you need to rebuild the frontend, you have two options:
# Make the script executable if needed chmod +x build_frontend.py # Run the script ./build_frontend.py
This script will automatically:
# Navigate to frontend directory cd frontend # Install dependencies npm install # Build the frontend npm run build # Create static directory if it doesn't exist mkdir -p ../backend/static # Copy build files cp -r dist/* ../backend/static/
After building the frontend, you can start the application using the run.py script.
For a production environment where the static files have already been built:
backend/static
directorycd backend uv pip install -r requirements.txt python -m app.main
If you want to run the services separately for development:
Navigate to the backend directory:
cd backend
Install the dependencies with uv:
uv pip install -r requirements.txt
Run the backend server:
python -m uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload
Navigate to the frontend directory:
cd frontend
Install the dependencies:
npm install
Run the development server:
npm run dev
http://localhost:8000/mcp/v1
PdfRagMcpServer/
├── backend/ # FastAPI backend
│ ├── app/
│ │ ├── __init__.py
│ │ ├── main.py # Main FastAPI application
│ │ ├── database.py # Database models
│ │ ├── pdf_processor.py # PDF processing logic
│ │ ├── vector_store.py # Vector database interface
│ │ └── websocket.py # WebSocket handling
│ ├── static/ # Static files for the web interface
│ └── requirements.txt # Backend dependencies
├── frontend/ # React frontend
│ ├── public/
│ ├── src/
│ │ ├── components/ # UI components
│ │ ├── context/ # React context
│ │ ├── pages/ # Page components
│ │ └── App.jsx # Main application component
│ ├── package.json # Frontend dependencies
│ └── vite.config.js # Vite configuration
├── uploads/ # PDF file storage
└── README.md # This documentation
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
Discover shared experiences
Shared threads will appear here, showcasing real-world applications and insights from the community. Check back soon for updates!