Prepare the server locally
Run this once before adding it to Claude Code.
pip install -r requirements.txtRegister it in Claude Code
claude mcp add -e "OPENAI_API_KEY=${OPENAI_API_KEY}" document-qa -- python /path/to/web_server.pyReplace any placeholder paths in the command with the real path on your machine.
OPENAI_API_KEYMake your agent remember this setup
document-qa's config, env vars, and the gotchas you hit — recalled in every future Claude Code, Cursor, and Codex session.
npx conare@latestFree · one command · indexes the sessions already on disk. Set up in the browser instead →
What it does
- Web-based file upload for PDF, TXT, and Markdown files
- GPT-4 powered question answering with strict document adherence
- Semantic search using OpenAI embeddings and cosine similarity
- Real-time dashboard with confidence scores and source attribution
- Hallucination-free responses based strictly on provided content
Environment Variables
OPENAI_API_KEYrequiredAPI key for accessing OpenAI's GPT-4 and embedding servicesTry it
Original README from SY-MR-CODER/MCPDocumentChat-main
🚀 Document Q&A MCP Server
A Python-based Model Context Protocol (MCP) server that provides document-based question answering using OpenAI's API. Upload documents, ask questions, and get answers based strictly on document content with zero hallucinations.
🌟 Live Demo
Web Interface: Start the server and visit http://localhost:8000
⚡ Quick Start
# 1. Install dependencies
pip install -r requirements.txt
# 2. Set your OpenAI API key
export OPENAI_API_KEY="your-api-key-here"
# 3. Start the web server
python web_server.py
# 4. Open http://localhost:8000 in your browser
# 5. Upload a document and start asking questions!
🎯 Features
- 📤 Web File Upload: Drag & drop PDF, TXT, Markdown files
- 🤖 Smart Q&A: GPT-4 powered answers based strictly on your documents
- 🔍 Semantic Search: OpenAI embeddings with cosine similarity
- 🚫 Zero Hallucinations: Only answers from document content
- 📊 Real-time Dashboard: Live status, confidence scores, source attribution
- 🏗️ MCP Compliant: Standard protocol for AI integration
- ⚡ Production Ready: Error handling, logging, async support
🏛️ Architecture
- Multi-format Support: PDF, TXT, and Markdown files
- Intelligent Chunking: Semantic document splitting with overlap
- Vector Search: OpenAI embeddings with cosine similarity
- Hallucination Prevention: Strict adherence to document content
- MCP Compliant: Standard protocol endpoints
- Production Ready: Clean architecture with error handling
Architecture
┌─────────────────┐ HTTP/Upload ┌─────────────────┐ MCP Protocol ┌─────────────────┐
│ Web Browser │ ◄────────────────► │ Web Server │ ◄─────────────────► │ Document Q&A │
│ │ │ │ │ MCP Server │
│ • File Upload │ │ • File Handling│ │ │
│ • Q&A Interface│ │ • HTTP Endpoints│ │ ┌───────────┐ │
│ • Results │ │ • JSON API │ │ │DocumentLoader│ │
└─────────────────┘ └─────────────────┘ │ └───────────┘ │
│ ┌───────────┐ │
│ │ Chunker │ │
│ └───────────┘ │
│ ┌───────────┐ │
│ │Embedding │ │
│ │ Store │ │
│ └───────────┘ │
│ ┌───────────┐ │
│ │ Query │ │
│ │ Handler │ │
│ └───────────┘ │
└─────────────────┘
The server consists of five main components:
- DocumentLoader: Handles PDF, TXT, and Markdown file parsing
- DocumentChunker: Intelligently splits documents into semantic chunks
- EmbeddingStore: Manages vector embeddings for similarity search
- QueryHandler: Processes questions and generates context-aware answers
- MCPServer: Exposes MCP-compliant endpoints
🚀 Usage Options
Option 1: Web Interface (Recommended)
python web_server.py
# Visit http://localhost:8000
Option 2: Interactive CLI
python interactive_client.py
Option 3: Simple Version (No MCP)
python simple_document_qa.py
# Visit http://localhost:8001
Option 4: Run Tests
python test_server.py
📱 Web Interface Features
- 📤 File Upload: Click "Choose File" or drag & drop documents
- ❓ Question Input: Type questions in the text area
- 📊 Live Dashboard: Real-time status and document info
- 🎯 Confidence Scores: See how confident the AI is in each answer
- 📚 Source Attribution: Know exactly which document parts were used
- ⚡ Real-time Processing: Instan