Skip to main content
Glama
Context-MCP Document Server

Context-MCP Document Server

by lxgbrl

Context-MCP Document Server

A powerful local TypeScript MCP (Model Context Protocol) server that enables Claude Code to index, search, and retrieve documents from your local filesystem. Supports PDF, DOCX, Markdown, HTML, TXT, and JSON files with full-text search capabilities and automatic file watching.

✨ Features

  • šŸ“ Multi-format Support: PDF, DOCX, Markdown, HTML, TXT, and JSON files

  • šŸ” Full-text Search: Fast search with relevance scoring using Lunr.js

  • šŸ’¾ Persistent Storage: Local document storage with metadata

  • šŸ”— MCP Integration: Seamless integration with Claude Code

  • šŸ“„ Content Extraction: Intelligent content parsing for each file type

  • 🌐 Resource Access: Documents accessible via doc:// URIs

  • šŸ‘€ File Watching: Automatically index new files when added to watched directories

  • āš™ļø Configurable: Environment-based configuration for data paths and watch directories

Related MCP server: Claude RAG MCP Pipeline

šŸš€ Quick Start

Prerequisites

  • Node.js 18+

  • npm or yarn

  • Claude Code with MCP support

Installation

  1. Clone the Repository

    git clone https://github.com/lxgbrl/Context-MCP.git
    cd Context-MCP
  2. Install Dependencies

    npm install
  3. Build the Server

    npm run build
  4. Test the Server (Optional)

    # Test with MCP inspector
    npm run inspect

āš™ļø Configuration

Environment Variables

Create a .env file or set these environment variables:

# Directory where documents and indices are stored (optional)
DATA_PATH="/path/to/your/document-storage"

# Comma-separated list of directories to watch for new files (optional)
WATCH_DIRECTORIES="/Users/you/Documents/knowledge-base,/Users/you/Projects/docs"

Claude Code Integration

Add the server to your Claude Code MCP configuration:

macOS

Edit ~/Library/Application Support/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "document-index": {
      "command": "node",
      "args": ["/absolute/path/to/Context-MCP/dist/index.js"],
      "env": {
        "DATA_PATH": "/Users/you/Documents/Context-MCP/data",
        "WATCH_DIRECTORIES": "/Users/you/Documents/knowledge-base,/Users/you/Projects/docs"
      }
    }
  }
}

Windows

Edit %APPDATA%/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "document-index": {
      "command": "node",
      "args": ["C:\\absolute\\path\\to\\Context-MCP\\dist\\index.js"],
      "env": {
        "DATA_PATH": "C:\\Users\\you\\Documents\\Context-MCP\\data",
        "WATCH_DIRECTORIES": "C:\\Users\\you\\Documents\\knowledge-base,C:\\Users\\you\\Projects\\docs"
      }
    }
  }
}

Linux

Edit ~/.config/Claude/claude_desktop_config.json with the same format as macOS.

Important:

  • Replace paths with your actual installation directory

  • Use absolute paths only

  • Restart Claude Code after configuration changes

šŸ“– Usage

The easiest way to use the document server is through automatic file watching:

  1. Configure Watch Directories in your MCP configuration (see above)

  2. Drop Files into your watched directories:

    # Just copy files to watched folders
    cp ~/Downloads/api-documentation.pdf ~/Documents/knowledge-base/
    cp ~/Downloads/user-manual.docx ~/Documents/knowledge-base/manuals/
    
    # Files are automatically indexed within seconds!
  3. Use in Claude Code:

    Search my knowledge base for "authentication implementation"
    
    Using @document-index, find documents about OAuth and explain the setup process

Method 2: Manual Document Management

Use these commands directly in Claude Code:

Add Documents

Add the file /Users/me/documents/research-paper.pdf to the document index with tags ["research", "ai"]

Search Documents

Search for documents about "machine learning algorithms"

List All Documents

Show me all indexed documents

Get Specific Document

Get the content of document with ID abc123

Update Document Metadata

Update document abc123 with title "New Title" and tags ["updated", "important"]

Delete Documents

Delete document with ID abc123

Server Statistics

Show me document server statistics

Using Documents as Resources

Access documents directly as MCP resources:

Using @document-index:doc://abc123 as reference, explain the implementation details

Summarize the key points from @document-index:doc://xyz789

šŸ› ļø Available Tools

Tool

Description

add_document

Index a new document from file path

search_documents

Full-text search with relevance scoring

get_document

Retrieve complete document content

list_documents

List all indexed documents

update_document

Update document metadata (title, tags)

delete_document

Remove document from index

get_server_stats

View server statistics

šŸ“„ Supported File Types

Format

Extensions

Features

PDF

.pdf

Text extraction, metadata, page count

Word Documents

.docx

Plain text extraction

Markdown

.md

Frontmatter parsing, heading analysis

HTML

.html, .htm

Content extraction, metadata tags

Text Files

.txt

Plain text content

JSON

.json

Structured data to searchable text

šŸ—ļø Development

Project Structure

Context-MCP/
ā”œā”€ā”€ src/
│   ā”œā”€ā”€ index.ts              # Main MCP server
│   ā”œā”€ā”€ lib/
│   │   ā”œā”€ā”€ DocumentStore.ts  # Document storage & metadata
│   │   ā”œā”€ā”€ SearchIndex.ts    # Search indexing with Lunr.js
│   │   ā”œā”€ā”€ DocumentProcessor.ts # File content extraction
│   │   └── FileWatcher.ts    # Directory monitoring
│   ā”œā”€ā”€ resources/            # MCP resource handlers
│   ā”œā”€ā”€ tools/               # MCP tool implementations
│   ā”œā”€ā”€ types/               # TypeScript type definitions
│   └── utils/               # Utility functions
ā”œā”€ā”€ data/                    # Generated - document storage
ā”œā”€ā”€ dist/                    # Generated - compiled output
ā”œā”€ā”€ docs/                    # Project documentation
└── tests/                   # Test suites

Development Commands

# Build the project
npm run build

# Development mode with auto-reload
npm run dev

# Test with MCP inspector
npm run inspect

# Clean build files
npm run clean

Adding New File Types

  1. Update DocumentProcessor.ts:

    • Add extension to supportedExtensions set

    • Implement processing method

    • Add to processFile() switch statement

  2. Update type definitions in types/index.ts if needed

  3. Test with various file samples

šŸ’” Best Practices

Directory Organization

~/Documents/knowledge-base/
ā”œā”€ā”€ projects/
│   ā”œā”€ā”€ project-a/
│   │   ā”œā”€ā”€ api-docs.md
│   │   └── specifications.pdf
│   └── project-b/
│       └── user-manual.docx
ā”œā”€ā”€ references/
│   ā”œā”€ā”€ programming-guides/
│   └── api-references/
└── manuals/
    ā”œā”€ā”€ tools/
    └── frameworks/

File Naming

  • Use descriptive filenames: oauth-implementation-guide.md vs guide.md

  • Include version info: api-v2-reference.pdf

  • Use consistent naming patterns

Content Quality

  • Clear headings for better search results

  • Good structure with logical sections

  • Relevant keywords in content

  • Meaningful tags when adding documents

šŸ”§ Data Storage

Documents are stored locally in the configured data directory:

data/
ā”œā”€ā”€ documents/    # Full document content (JSON files)
ā”œā”€ā”€ metadata/     # Document metadata index
└── index/        # Search index files
  • Privacy: All data stays on your local machine

  • Persistence: Data survives server restarts

  • Backup: Simply backup the data directory

  • Migration: Move data directory to transfer documents

šŸ› Troubleshooting

Server Won't Start

Check Node.js Version

node --version  # Should be 18+

Verify Installation

npm install
npm run build
ls -la dist/index.js  # Should exist and be executable

Check Permissions

# Ensure data directory is writable
mkdir -p data
chmod 755 data

Claude Code Can't Connect

  1. Verify Configuration Path

    • Use absolute paths only

    • Check dist/index.js exists

    • Ensure paths match your system

  2. Test Server Independently

    npm run inspect
    # Should show server tools and resources
  3. Check Environment Variables

    # Test server startup with explicit paths
    DATA_PATH="/full/path/to/data" node dist/index.js
  4. Restart Claude Code after configuration changes

File Processing Issues

PDF Files Not Processing

  • Ensure PDF files are not password-protected

  • Check file permissions are readable

  • Large PDFs may take time to process

File Watching Not Working

  • Verify WATCH_DIRECTORIES paths exist

  • Check directory permissions

  • Restart server after changing watch directories

Search Not Finding Documents

# Check if documents are indexed
# Use list_documents tool in Claude Code

# Verify search index
# Use get_server_stats tool

Common Error Solutions

Error

Solution

ENOENT: no such file or directory

Use absolute file paths

pdf-parse test file not found

Already fixed in this version

DocumentStore initialization failed

Check DATA_PATH directory permissions

Permission denied

Ensure directories are readable/writable

šŸ”„ Migration & Backup

Backup Your Documents

# Backup document data
tar -czf document-backup.tar.gz data/

# Restore from backup
tar -xzf document-backup.tar.gz

Moving to New Machine

  1. Copy the data/ directory

  2. Install Context-MCP on new machine

  3. Configure Claude Code with new paths

  4. Documents and search index will be preserved

šŸ¤ Contributing

  1. Fork the Repository

  2. Create Feature Branch: git checkout -b feature/amazing-feature

  3. Commit Changes: git commit -m 'Add amazing feature'

  4. Push to Branch: git push origin feature/amazing-feature

  5. Open Pull Request

Development Setup

git clone https://github.com/lxgbrl/Context-MCP.git
cd Context-MCP
npm install
npm run dev  # Start development server

šŸ“š Documentation

šŸ“„ License

MIT License - see LICENSE file for details.

šŸ™ Acknowledgments


Made with ā¤ļø for the Claude Code community

Transform your local documents into an intelligent, searchable knowledge base accessible directly in Claude Code conversations.

Available Tools

7 tools
add_documentB

Add a document to the index from a file path. Supports PDF, DOCX, Markdown, HTML, TXT, and JSON files.

Inputs: path (required), tags, title.

delete_documentB

Remove a document from the index permanently

Inputs: id (required).

get_documentA

Get the full content and metadata of a specific document by ID

Inputs: id (required).

get_server_statsA

Get statistics about the document server (total documents, types, index size)

Inputs: no named parameters.

list_documentsA

List all indexed documents with basic metadata (summaries without full content)

Inputs: no named parameters.

search_documentsC

Search for documents using full-text search with relevance scoring

Inputs: query (required), limit.

update_documentA

Update document metadata (title, tags) without changing content

Inputs: id (required), tags, title.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.7/5.0

    Scored across 7 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose: add, search, get, list, update, delete, and stats target separate operations and resources. The descriptions also clarify the distinction between full-content retrieval (get_document) and metadata listing (list_documents).

    Naming Consistency5/5

    All tool names follow a consistent snake_case verb_noun pattern (add_document, search_documents, get_document, etc.). No mixed conventions or ambiguous verbs are present.

    Tool Count5/5

    Seven tools are well-scoped for a document indexing server. The set covers core operations without unnecessary bloat or missing basic utilities.

    Completeness4/5

    The surface covers create/read/list/search/update-metadata/delete plus stats, which is solid lifecycle coverage. A minor gap exists because document content cannot be updated directly or reindexed without deleting and re-adding, but this is workable.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables real-time indexing and semantic search of local documents (PDF, Word, text, Markdown, RTF) using vector embeddings and local LLMs. Monitors folders for changes and provides natural language search capabilities through Claude Desktop integration.
      22
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables Claude Desktop to search and query personal document collections (PDF, Word, Markdown, text) using semantic search and conversational AI with full context preservation across exchanges.
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables Claude to search and read the user's local document collection (PDF, Word, Excel, Markdown, plain text) during a conversation by subject, by file name/path, or by exact word, and to retrieve file contents page by page. It also supports finding folders relevant to a topic and checking indexing status, with everything running locally on the user's machine.
      MIT