Document Q&A MCP Server

Local setup required. This server has to be cloned and prepared on your machine before you register it in Claude Code.
1

Set the server up locally

Run this once to clone and prepare the server before adding it to Claude Code.

Run in terminal
pip install -r requirements.txt
2

Register it in Claude Code

After the local setup is done, run this command to point Claude Code at the built server.

Run in terminal
claude mcp add -e "OPENAI_API_KEY=${OPENAI_API_KEY}" document-qa -- python "<FULL_PATH_TO_MCPDOCUMENTCHAT_MAIN>/dist/index.js"

Replace <FULL_PATH_TO_MCPDOCUMENTCHAT_MAIN>/dist/index.js with the actual folder you prepared in step 1.

Required:OPENAI_API_KEY
README.md

Document-based question answering using OpenAI's API.

πŸš€ 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

Document Q&A Demo

⚑ 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:

  1. DocumentLoader: Handles PDF, TXT, and Markdown file parsing
  2. DocumentChunker: Intelligently splits documents into semantic chunks
  3. EmbeddingStore: Manages vector embeddings for similarity search
  4. QueryHandler: Processes questions and generates context-aware answers
  5. 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

Environment Variables

OPENAI_API_KEYrequiredAPI key for accessing OpenAI's GPT-4 and embedding services

Configuration

claude_desktop_config.json
{"mcpServers": {"document-qa": {"command": "python", "args": ["/path/to/web_server.py"], "env": {"OPENAI_API_KEY": "your-api-key-here"}}}}

Try it

β†’Analyze the uploaded PDF document and summarize the key findings.
β†’Based on the provided text files, what are the main arguments presented?
β†’Find the section in the markdown documentation that explains the installation process.
β†’Answer my question about the document content without using any outside information.

Frequently Asked Questions

What are the key features of Document Q&A MCP Server?

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.

What can I use Document Q&A MCP Server for?

Extracting specific technical details from long PDF manuals. Summarizing multiple markdown project files for quick context. Verifying information against a set of provided text documents. Providing source-attributed answers for research or compliance tasks.

How do I install Document Q&A MCP Server?

Install Document Q&A MCP Server by running: pip install -r requirements.txt

What MCP clients work with Document Q&A MCP Server?

Document Q&A MCP Server works with any MCP-compatible client including Claude Desktop, Claude Code, Cursor, and other editors with MCP support.

Turn this server into reusable context

Keep Document Q&A MCP Server docs, env vars, and workflow notes in Conare so your agent carries them across sessions.

Need the old visual installer? Open Conare IDE.
Open Conare