Download the complete MCP + Claude Desktop workshop package with all code files, Docker setup, and sample PDF.
⬇️ Download ZIP PackageThis hands-on workshop guides you through setting up a Model Context Protocol (MCP) server locally and connecting it to the Claude Desktop application for vector database searches.
MCP + Claude Desktop/
├── mcp_vector_server.py # Main MCP server
├── generate_vector_db.py # Script to generate FAISS index from PDFs
├── search_vector_db.py # Standalone search script
├── client_vector.py # Test client
├── requirements.txt # Python dependencies
├── data/ # All data files
│ ├── PDF/ # Place your PDF files here
│ │ └── *.pdf # Will be processed automatically
│ ├── knowledge_base.json # Extracted text (auto-generated)
│ └── faiss_index/ # Generated FAISS index
│ ├── faiss.index
│ ├── texts.json
│ └── embeddings.npy
cd /path/to/your/project/MCP\ +\ Claude\ Desktop
# Create virtual environment
python3 -m venv .venv
# Activate (macOS/Linux)
source .venv/bin/activate
# Activate (Windows)
.venv\Scripts\activate
pip install -r requirements.txt
Contents of requirements.txt:
mcp>=0.1.0
fastmcp>=0.1.0
faiss-cpu>=1.7.4
sentence-transformers>=2.2.0
numpy>=1.24.0
PyPDF2>=3.0.0
Place your PDF documents in the data/PDF/ folder:
# Create the folder structure if needed
mkdir -p data/PDF
# Copy your PDFs to the folder
cp /path/to/your/documents/*.pdf data/PDF/
Expected structure:
data/PDF/
├── document1.pdf
├── document2.pdf
└── ...
python generate_vector_db.py
============================================================
🚀 FAISS Vector DB Generator from PDFs
============================================================
📂 Found 1 PDF file(s) in: /path/to/data/PDF
📄 Processing: CTW-2019-PCS-00043-book-of-delivery.pdf
✓ Extracted 27 chunks
💾 Knowledge base saved to: data/knowledge_base.json
📚 27 knowledge chunks to index.
⚙️ Generating embeddings with model: all-MiniLM-L6-v2
✅ FAISS vector DB created successfully!
📁 Location: data/faiss_index
📦 Entries: 27 | Dimensions: 384
============================================================
Open the file (create it if it doesn't exist) and add the MCP server configuration:
{
"mcpServers": {
"vector-db": {
"command": "/ABSOLUTE/PATH/TO/.venv/bin/python3",
"args": ["/ABSOLUTE/PATH/TO/MCP/mcp_vector_server.py"],
"env": {
"PYTHONPATH": "/ABSOLUTE/PATH/TO/MCP"
}
}
}
}
Replace the paths with your actual absolute paths. Relative paths (like ./ or
~/) may not work correctly.
{
"mcpServers": {
"vector-db": {
"command": "/Users/youruser/project/.venv/bin/python3",
"args": ["/Users/youruser/project/MCP + Claude Desktop/mcp_vector_server.py"],
"env": {
"PYTHONPATH": "/Users/youruser/project/MCP + Claude Desktop"
}
}
}
}
# Find Python path
which python3
# Find current directory
pwd
After editing the configuration, you MUST completely restart Claude Desktop:
python client_vector.py mcp_vector_server.py
🔌 Starting MCP client for server: mcp_vector_server.py
✅ MCP Handshake Complete
🛠 Tools detected: ['create_vector_db', 'search_vector_db']
📌 RAW RESPONSE FROM SERVER:
1) score=0.7131
Your relevant text here...
# macOS
cat ~/Library/Logs/Claude/mcp-server-vector-db.log
Look for these messages:
[SERVER_LOG] Server loading...
[SERVER_LOG] Loading SentenceTransformer model...
[SERVER_LOG] Model loaded successfully!
[SERVER_LOG] Starting MCP server...
The server now includes a search tool that uses default paths automatically. No need to
specify file paths anymore!
search (Recommended ⭐)Simple semantic search with no paths required. Uses the default knowledge base automatically.
In Claude Desktop, just ask naturally:
Search for "quality principles" in the knowledge base
or simply:
search delivery process
| Parameter | Type | Description |
|---|---|---|
query |
string | Text to search for |
top_k |
int | Number of results (default: 5) |
search_vector_dbSearch with optional custom path. If index_dir is not provided, uses the default location.
In Claude Desktop, send a message like:
# Simple (uses default path):
Search "quality principles" using search_vector_db
# With custom path:
Search "quality principles" using search_vector_db with
index_dir='/ABSOLUTE/PATH/TO/data/faiss_index'
| Parameter | Type | Description |
|---|---|---|
query |
string | Text to search for |
index_dir |
string (optional) | Path to FAISS index (uses default if empty) |
top_k |
int | Number of results (default: 5) |
Example of searching for "quality principles" in Claude Desktop using the MCP vector database tool
create_vector_dbCreates a new vector database from a JSON file.
Create a vector database from '/path/to/knowledge.json'
in the directory '/path/to/output'
| Parameter | Type | Description |
|---|---|---|
json_path |
string | Path to the JSON file with texts |
output_dir |
string | Directory where to save the index |
Possible Causes:
index_dir pathSolution:
cat ~/Library/Logs/Claude/mcp-server-vector-db.logCause: Claude Desktop closed the connection before the server responded.
Solution: Ensure you're using the latest version of mcp_vector_server.py which
handles this error gracefully.
Solutions:
which python3 # Use this path in config
ls -la /your/path/mcp_vector_server.py
Cause: The FAISS index was not generated or the path is incorrect.
Solution:
python generate_vector_db.py
ls -la faiss_index/
For advanced debugging, monitor logs in real-time:
# Specific vector-db log
tail -f ~/Library/Logs/Claude/mcp-server-vector-db.log
# All MCP logs
tail -f ~/Library/Logs/Claude/mcp.log
/Users/youruser/project/
├── .venv/
│ └── bin/python3
└── MCP + Claude Desktop/
├── mcp_vector_server.py
└── data/
├── PDF/
│ └── your-documents.pdf
├── knowledge_base.json
└── faiss_index/
├── faiss.index
├── texts.json
└── embeddings.npy
{
"mcpServers": {
"vector-db": {
"command": "/Users/youruser/project/.venv/bin/python3",
"args": ["/Users/youruser/project/MCP + Claude Desktop/mcp_vector_server.py"],
"env": {
"PYTHONPATH": "/Users/youruser/project/MCP + Claude Desktop"
}
}
}
}
Search "quality principles" using search_vector_db with
index_dir='/Users/youruser/project/MCP + Claude Desktop/data/faiss_index' and top_k=3
1) score=0.5410
[Source: CTW-2019-PCS-00043-book-of-delivery.pdf]
Critical TechWorks Principles...
2) score=0.4262
[Source: CTW-2019-PCS-00043-book-of-delivery.pdf]
Critical TechWorks Quality...
3) score=0.2408
[Source: CTW-2019-PCS-00043-book-of-delivery.pdf]
Critical TechWorks Visibility...