MCP PDF Server
Enables AI assistants to query PDF documents by ingesting them into a vector database and generating answers grounded in the actual documents.
README
π MCP PDF Server
An MCP (Model Context Protocol) server that lets AI assistants query your PDF documents. Drop your PDFs, ingest them into a vector database, and ask questions β answers are grounded in your actual documents.
β¨ Features
- π MCP-Compatible β Works with any MCP client (GitHub Copilot, Antigravity, etc.)
- π Auto PDF Discovery β Automatically finds, extracts, chunks, and embeds all PDFs in your folder
- π Vector Search β Retrieves the most relevant passages before generating answers
- π³ Docker-Ready β Runs as a containerized server with one command
- ποΈ Qdrant β Fast, open-source vector database for similarity search
ποΈ How It Works
βββββββββββββββ MCP (stdio) βββββββββββββββββββββ HTTP ββββββββββββ
β AI Assistant ββββββββββββββββββββββΊβ MCP PDF Server βββββββββββββββΊβ Qdrant β
β β β β β Vector DBβ
βββββββββββββββ β 1. Embed question β ββββββββββββ
β 2. Search vectors β
β 3. Generate answerβ LLM API
β βββββββββββββββΊ
βββββββββββββββββββββ (Embeddings
+ Generation)
- You ask a question via your AI assistant.
- The server embeds the question using your choice of embedding model.
- It searches Qdrant for the top 5 most relevant text chunks from your PDFs.
- It generates an answer using an LLM, grounded in the retrieved context.
π Quick Start
Prerequisites
- Docker & Docker Compose
- Node.js 20+ (for ingestion only)
- [LLM API Key]
1. Clone & Configure
git clone https://github.com/your-username/mcp-pdf-server.git
cd mcp-pdf-server
cp .env.example .env
Edit .env and set your API key:
API_KEY=nvapi-your_key_here
2. Start Qdrant
docker-compose up -d
3. Add Your PDFs & Ingest
Place your PDF documents in the pdfs/ folder, then:
npm install # first time only
npm run ingest
All PDFs in the folder are automatically discovered and ingested.
4. Build the Server Image
docker build -t mcp-pdf-server .
5. Connect to Your AI Assistant
Add to your AI assistant's MCP config (e.g., mcp_config.json):
{
"mcpServers": {
"pdf-docs": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"--network",
"mcp-network",
"-e",
"API_KEY",
"-e",
"QDRANT_URL=http://mcp-qdrant:6333",
"-e",
"COLLECTION_NAME=documents",
"-e",
"EMBED_MODEL=nvidia/nv-embedqa-e5-v5",
"-e",
"GEN_MODEL=qwen/qwen2.5-coder-32b-instruct",
"mcp-pdf-server"
],
"env": {
"API_KEY": "your_nvapi_key_here"
}
}
}
}
Done! Ask your AI assistant any question about your documents.
π§ Available Tools
| Tool | Description |
|---|---|
ask_documents |
Ask any question. The server retrieves relevant context from your ingested PDFs and generates an answer. |
βοΈ Environment Variables
| Variable | Description | Default |
|---|---|---|
API_KEY |
LLM API key | (required) |
EMBED_MODEL |
Embedding model | nvidia/nv-embedqa-e5-v5 |
GEN_MODEL |
Generation model | qwen/qwen2.5-coder-32b-instruct |
COLLECTION_NAME |
Qdrant collection name | documents |
QDRANT_URL |
Qdrant connection URL | http://localhost:6333 |
EMBED_BATCH_SIZE |
Chunks per embedding batch | 15 |
EMBED_MAX_RETRIES |
Max retries on API failure | 3 |
EMBED_COOLOFF_MS |
Cooldown between batches (ms) | 500 |
Note: The
.envfile is used for local ingestion. Themcp_config.jsonpasses env vars via Docker-eflags for the server.
π Project Structure
mcp-pdf-server/
βββ pdfs/ # Place your PDF documents here
βββ src/
β βββ server.ts # MCP server entry point
β βββ llm/
β β βββ provider.ts # LLM API client (embed + generate)
β βββ vector/
β β βββ qdrant.ts # Qdrant client config
β βββ ingest/
β βββ main.ts # Ingestion orchestrator (auto-discovers PDFs)
β βββ extract.ts # PDF text extraction
β βββ chunk.ts # Text chunking
β βββ embed.ts # Batch embedding & Qdrant insertion
βββ docker-compose.yml # Qdrant service
βββ Dockerfile # Server image
βββ .env.example # Env var template (safe to commit)
βββ .gitignore # Keeps secrets & binaries out of git
βββ package.json
π οΈ Development
For local development with hot-reloading:
npm install
docker-compose up -d # Start Qdrant
npm run dev # Server with hot-reload
To use the local dev server with your AI assistant, change mcp_config.json to:
{
"mcpServers": {
"pdf-docs": {
"command": "npx",
"args": ["tsx", "src/server.ts"],
"cwd": "/path/to/mcp-pdf-server",
"env": {
"API_KEY": "your_nvapi_key_here",
"QDRANT_URL": "http://localhost:6333",
"COLLECTION_NAME": "documents",
"EMBED_MODEL": "nvidia/nv-embedqa-e5-v5",
"GEN_MODEL": "qwen/qwen2.5-coder-32b-instruct"
}
}
}
}
π Use Cases
This server works with any PDF knowledge base:
- π Technical books β Architecture, algorithms, system design
- π Company docs β Wikis, runbooks, policies
- π Research papers β Academic papers, whitepapers
- π Legal documents β Contracts, compliance
- π Course material β Textbooks, lecture notes
π Troubleshooting
| Problem | Solution |
|---|---|
| Server can't reach Qdrant | docker ps β Ensure mcp-qdrant is running on mcp-network |
| Embeddings mismatch | Changed EMBED_MODEL? Delete qdrant_storage/ and re-ingest |
| Rebuild server image | docker build -t mcp-pdf-server . after code changes |
| Reset all data | Delete ./qdrant_storage/ and re-run npm run ingest |
| Rate limiting | Increase EMBED_COOLOFF_MS or decrease EMBED_BATCH_SIZE in .env |
| No PDFs found | Ensure .pdf files are placed in the pdfs/ directory |
π License
ISC
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.