Skip to content

dubbinglabs/docs-mcp-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Docs MCP Server

Production-ready MCP (Model Context Protocol) server for intelligent documentation search and discovery. Built to help Claude Code efficiently navigate large documentation repositories using semantic search, categorization, and relationship mapping.

Features

6 Powerful Tools

  1. search_docs - Search by keywords with optional category/tag filtering
  2. get_document - Retrieve full document content
  3. get_related_docs - Find related documentation based on relationships
  4. list_categories - Browse all documentation categories
  5. list_tags - Explore all available tags
  6. reindex_docs - Rebuild the documentation index to pick up changes

Advanced Capabilities

  • TF-IDF Ranking - Intelligent relevance scoring using Term Frequency-Inverse Document Frequency
  • Frontmatter Parsing - Automatic extraction of metadata (title, tags, category, summary, related docs)
  • Relationship Mapping - Discovers connections through:
    • Explicit frontmatter relationships
    • Shared categories and tags
    • Markdown links between documents
  • Smart Categorization - Automatic category inference from directory structure
  • Fast Indexing - Builds searchable index on startup

Installation

cd docs-mcp-server
npm install
npm run build

Configuration

For Claude Code

Add to your Claude Code MCP settings (~/.config/claude-code/mcp_settings.json):

{
  "mcpServers": {
    "docs": {
      "command": "node",
      "args": ["/absolute/path/to/docs-mcp-server/dist/index.js"],
      "env": {
        "DOCS_PATH": "/absolute/path/to/your/project/docs"
      }
    }
  }
}

For Claude Desktop

Add to Claude Desktop MCP settings:

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json Windows: %APPDATA%\Claude\claude_desktop_config.json Linux: ~/.config/claude-desktop/claude_desktop_config.json

{
  "mcpServers": {
    "docs": {
      "command": "node",
      "args": ["/absolute/path/to/docs-mcp-server/dist/index.js"],
      "env": {
        "DOCS_PATH": "/absolute/path/to/your/project/docs"
      }
    }
  }
}

Environment Variables

  • DOCS_PATH - Required: Absolute path to your documentation directory
    • Default: ../video-dubbing/docs (relative to server location)

Enhancing Your Documentation

Add frontmatter to your markdown files for better organization:

---
title: Authentication Implementation
tags: [authentication, oauth, security]
category: features
related: [docs/api/auth-endpoints.md, docs/database/users.md]
summary: OAuth 2.0 implementation with Google and GitHub providers
---

# Authentication

Your content here...

Frontmatter Fields

Field Type Description
title string Document title (auto-extracted from filename if missing)
tags array Tags for categorization and filtering
category string Primary category (auto-extracted from directory if missing)
related array Paths to related documents
summary string Brief description (auto-extracted from first paragraph if missing)

Note: All fields are optional. The server will automatically infer missing metadata.

Usage Examples

Example 1: Search for Documentation

User: "Fix the authentication bug in login.ts"

Claude Code calls:

search_docs({
  query: "authentication login",
  category: "features",
  limit: 5
})

Returns:

{
  "query": "authentication login",
  "total_results": 3,
  "results": [
    {
      "path": "features/auth.md",
      "title": "Authentication Implementation",
      "summary": "OAuth 2.0 implementation with Google and GitHub providers",
      "category": "features",
      "tags": ["authentication", "oauth", "security"],
      "relevance": 1.0,
      "excerpt": "...authentication system handles login..."
    }
  ]
}

Example 2: Get Full Document

get_document({
  path: "features/auth.md"
})

Returns complete document with metadata and full content.

Example 3: Find Related Documentation

get_related_docs({
  path: "features/auth.md",
  limit: 5
})

Returns documents related through categories, tags, or explicit relationships.

Example 4: Browse by Category

// First, list all categories
list_categories()

// Then search within a specific category
search_docs({
  query: "api endpoints",
  category: "api"
})

Example 5: Filter by Tags

search_docs({
  query: "security",
  tags: ["authentication", "encryption"]
})

Returns only documents with ALL specified tags.

Example 6: Rebuild Index

reindex_docs()

Returns:

{
  "status": "success",
  "message": "Documentation index rebuilt successfully",
  "stats": {
    "documents": 42,
    "categories": 5,
    "tags": 18
  }
}

Use this after adding or modifying markdown files to refresh the index.

How It Works

Phase 1: Indexing (Startup)

  1. Recursively scans DOCS_PATH for all .md files
  2. Parses frontmatter using gray-matter
  3. Extracts and indexes:
    • Keywords from title, summary, and content
    • Categories (from frontmatter or directory structure)
    • Tags (from frontmatter)
    • Relationships (explicit and implicit)

Phase 2: TF-IDF Calculation

  • Calculates Term Frequency-Inverse Document Frequency for all terms
  • Creates relevance scores for intelligent ranking
  • Enables semantic search beyond simple keyword matching

Phase 3: Relationship Mapping

Builds relationship graph through:

  • Explicit: Frontmatter related field
  • Implicit: Shared categories (same category = related)
  • Implicit: Shared tags (2+ shared tags = related)
  • Links: Markdown links to other docs

Phase 4: Query Processing

When Claude searches:

  1. Tokenizes query
  2. Matches against keyword index
  3. Calculates TF-IDF relevance scores
  4. Applies filters (category, tags)
  5. Ranks and returns top results

Architecture

docs-mcp-server/
├── src/
│   ├── index.ts          # MCP server implementation
│   ├── indexer.ts        # Document indexing and search
│   └── types.ts          # TypeScript type definitions
├── dist/                 # Compiled JavaScript (generated)
├── package.json
├── tsconfig.json
└── README.md

Performance

  • Index Build Time: ~100ms per 100 markdown files
  • Search Latency: <10ms for most queries
  • Memory Usage: ~1MB per 100 documents

Troubleshooting

Server not appearing in Claude

  1. Check your MCP settings file syntax (valid JSON)
  2. Verify absolute paths are correct
  3. Restart Claude Code/Desktop after configuration changes
  4. Check server logs for errors

No search results

  1. Verify DOCS_PATH points to correct directory
  2. Check that directory contains .md files
  3. Look for index build errors in server logs
  4. Try broader search terms

Related docs not showing

  1. Add frontmatter to your markdown files
  2. Ensure related paths are correct (relative to docs root)
  3. Add tags and categories for implicit relationships
  4. Check that linked documents exist

Development

# Install dependencies
npm install

# Build
npm run build

# Watch mode for development
npm run watch

Extending the Server

Adding New Tools

Edit src/index.ts and add to getTools():

{
  name: 'your_tool',
  description: 'Tool description',
  inputSchema: { /* ... */ }
}

Then add handler in setupHandlers().

Custom Ranking

Modify search() in src/indexer.ts to adjust scoring:

// Boost recent docs
if (doc.lastModified > Date.now() - 7 * 24 * 60 * 60 * 1000) {
  score += 2;
}

Additional Metadata

Add fields to DocumentMetadata in src/types.ts:

export interface DocumentMetadata {
  // ... existing fields
  author?: string;
  lastUpdated?: string;
}

License

MIT

Contributing

Contributions welcome! Areas for improvement:

  • Embeddings-based semantic search (OpenAI/local models)
  • Usage analytics (track most-accessed docs)
  • Automatic frontmatter generation
  • Support for non-markdown formats (PDF, HTML)
  • Real-time index updates (file watching)
  • Multi-language support

About

MCP server for intelligent documentation search and discovery

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •