Back to MCP Servers

Src To Kb

Convert source code repositories into searchable knowledge bases with AI-powered search using GPT-5, intelligent chunking, and OpenAI embeddings for semantic code understanding.

developer-toolsaiembedding
By vezlo
348Updated 6 months agoJavaScriptNOASSERTION

Installation

npx -y src-to-kb

Configuration

{
  "mcpServers": {
    "src-to-kb": {
      "command": "npx",
      "args": ["-y", "src-to-kb"]
    }
  }
}

How to use

  1. Run the installation command above (if needed)
  2. Open your Claude Code settings file (~/.claude/settings.json)
  3. Add the configuration to the mcpServers section
  4. Restart Claude Code to apply changes

Source Code to Knowledge Base Generator with MCP Server

npm version License: AGPL v3

Convert any source code repository into a searchable knowledge base with automatic chunking, embedding generation, and intelligent search capabilities. Now with MCP (Model Context Protocol) support for Claude Code and Cursor integration!

๐Ÿ“ฆ Now available on npm! Install with: npm install -g @vezlo/src-to-kb

Available Commands

After installation, you'll have access to these commands:

  • src-to-kb - Generate knowledge base from source code
  • src-to-kb-search - Search the knowledge base
  • src-to-kb-upload - Upload local knowledge base to external server
  • src-to-kb-api - Start REST API server with Swagger docs
  • src-to-kb-mcp - Start MCP server for IDE integration
  • src-to-kb-mcp-install - Auto-configure Claude Code/Cursor

Features

  • ๐Ÿ“ Multi-language Support: JavaScript, TypeScript, Python, Java, C++, Go, Rust, and more
  • ๐Ÿ“ Notion Integration: Import pages and databases directly from Notion (NEW!)
  • ๐ŸŽฏ Answer Modes: Three modes for different users - End User (simple), Developer (technical), Copilot (code-focused)
  • ๐ŸŒ REST API: Full-featured API with Swagger documentation for integration with external services
  • ๐Ÿ” Smart Chunking: Intelligent code splitting with configurable overlap
  • ๐Ÿงน Code Cleaning: Optional comment removal and whitespace normalization
  • ๐Ÿ”ข Embeddings: Optional OpenAI embeddings for semantic search
  • ๐Ÿ“Š Statistics: Comprehensive analysis of your codebase
  • ๐Ÿš€ Fast Processing: Efficient file scanning and processing
  • ๐Ÿ’พ Structured Storage: Organized JSON output for easy integration
  • ๐Ÿค– MCP Server: Direct integration with Claude Code, Cursor, and other MCP-compatible tools
  • ๐Ÿ’ก AI-Powered Search: Uses OpenAI GPT-5 (latest reasoning model) for intelligent query understanding and helpful answers
  • ๐Ÿ” API Authentication: Optional API key authentication for secure access
  • ๐ŸŒ External Server Integration: Send code to external servers for processing and search via REST API

Quick Start

๐Ÿš€ For Existing Projects (Next.js, React, etc.)

# Install globally
npm install -g @vezlo/src-to-kb

# Generate KB from your project
src-to-kb ./my-nextjs-app --output ./my-kb

# Start API server
src-to-kb-api

# Search your codebase
src-to-kb-search search "How does routing work?" --mode developer

That's it! Your codebase is now searchable with AI assistance.

Processing Modes & Flags

The following table shows how flags work across different sources and modes:

SourceModeDefault (no flags)--chunks-only--with-embeddings
CodebaseLocalCreates chunksSame (redundant)Creates chunks + embeddings
CodebaseServerSends raw contentCreates chunks โ†’ sendsCreates chunks + embeddings โ†’ sends
NotionLocalCreates chunksSame (redundant)Creates chunks + embeddings
NotionServerSends raw contentCreates chunks โ†’ sendsCreates chunks + embeddings โ†’ sends

Note: Server mode is enabled when EXTERNAL_KB_URL environment variable is set.

External Server Integration ๐ŸŒ

๐Ÿš€ Try It Now with Public Demo Server

Experience external server integration immediately with our production-ready assistant-server:

# Default: Send raw content (server creates chunks)
EXTERNAL_KB_URL=https://your-assistant-server.com/api/knowledge/items src-to-kb ./your-repo

# Create chunks locally, then send to server
EXTERNAL_KB_URL=https://your-assistant-server.com/api/knowledge/items src-to-kb ./your-repo --chunks-only

# Create chunks + embeddings locally, then send to server
EXTERNAL_KB_URL=https://your-assistant-server.com/api/knowledge/items OPENAI_API_KEY=sk-... src-to-kb ./your-repo --with-embeddings

# With API key authentication
EXTERNAL_KB_URL=https://your-assistant-server.com/api/knowledge/items EXTERNAL_KB_API_KEY=your-api-key src-to-kb ./your-repo

# Search using assistant-server
EXTERNAL_KB_URL=https://your-assistant-server.com/api/knowledge/items \
EXTERNAL_KB_SEARCH_URL=https://your-assistant-server.com/api/search \
src-to-kb-search search "how does authentication work?"

Assistant Server: vezlo/assistant-server - Production-ready Node.js/TypeScript API server with vector search and Docker deployment

๐Ÿ“ค Upload Local Knowledge Base

Upload an existing local knowledge base to an external server:

# Default: Upload raw content (reconstructs from chunks)
EXTERNAL_KB_URL=https://your-assistant-server.com/api/knowledge/items \
src-to-kb-upload --kb ./knowledge-base

# Upload chunks only (server generates embeddings)
EXTERNAL_KB_URL=https://your-assistant-server.com/api/knowledge/items \
src-to-kb-upload --kb ./knowledge-base --chunks-only

# Upload chunks with embeddings
EXTERNAL_KB_URL=https://your-assistant-server.com/api/knowledge/items \
src-to-kb-upload --kb ./knowledge-base --with-embeddings

Requirements:

  • EXTERNAL_KB_URL environment variable must be set
  • Knowledge base must have documents/ and chunks/ directories
  • For --with-embeddings: embeddings/ directory must exist

๐Ÿข Enterprise Setup

For production deployments or custom servers:

๐Ÿ“– Complete Guide: External Server Setup Guide

Notion Integration ๐Ÿ“

NEW! Import your Notion pages and databases directly into your knowledge base! Perfect for combining documentation, project plans, and code knowledge in one searchable system.

Quick Start with Notion

# 1. Get your Notion API key (see full guide below)
export NOTION_API_KEY=secret_xxx

# 2. Generate KB from a Notion page
src-to-kb --source=notion --notion-url=https://notion.so/Your-Page-abc123

# 3. Or fetch all pages from a Notion database
src-to-kb --source=notion --notion-url=https://notion.so/Database-xyz789

# 4. Search your Notion content
src-to-kb-search search "your query" --kb ./knowledge-base/notion

With External Server

Send Notion content directly to your assistant-server:

# Set external server URL
export EXTERNAL_KB_URL=http://localhost:3002/api/knowledge/items
export EXTERNAL_KB_API_KEY=your-api-key

# Send raw content from Notion to server (default)
src-to-kb --source=notion --notion-url=https://notion.so/Your-Page-abc123

# Send chunks from Notion to server
src-to-kb --source=notion --notion-url=https://notion.so/Your-Page-abc123 --chunks-only

# Send chunks + embeddings from Notion to server
OPENAI_API_KEY=sk-... src-to-kb --source=notion --notion-url=https://notion.so/Your-Page-abc123 --with-embeddings

# Search via external server
export EXTERNAL_KB_URL=http://localhost:3002/api/knowledge/items
export EXTERNAL_KB_SEARCH_URL=http://localhost:3002/api/search
src-to-kb-search search "your query"

Features

  • โœ… Auto-detection: Automatically detects if URL is a page or database
  • โœ… Single Page: Fetch individual Notion pages
  • โœ… Database Support: Fetch all pages from a Notion database
  • โœ… Rich Content: Preserves formatting, headings, lists, code blocks, and more
  • โœ… Separate KB: Notion content saved to ./knowledge-base/notion by default
  • โœ… External Server: Send directly to assistant-server for production use

Examples

# Single page (local KB)
src-to-kb --source=notion --notion-url=https://notion.so/Project-Docs-abc123

# Database with all pages (local KB)
src-to-kb --source=notion --notion-url=https://notion.so/Team-Wiki-xyz789

# With API key as parameter
src-to-kb --source=notion --notion-key=secret_xxx --notion-url=https://notion.so/Page-abc123

# Send to external server (raw content by default)
EXTERNAL_KB_URL=http://localhost:3002/api/knowledge/items \
EXTERNAL_KB_API_KEY=your-key \
src-to-kb --source=notion --notion-url=https://notion.so/Page-abc123

# Search local Notion KB
src-to-kb-search search "project timeline" --kb ./knowledge-base/notion

# Search via external server
EXTERNAL_KB_URL=http://localhost:3002/api/knowledge/items \
EXTERNAL_KB_SEARCH_URL=http://localhost:3002/api/search \
src-to-kb-search search "project timeline"

๐Ÿ“– Complete Notion Guide: Notion Integration Documentation - Includes setup instructions, API key creation, sharing pages/databases, and troubleshooting

1. Basic Usage

Process your repository with default settings:

# If installed globally via npm
src-to-kb /path/to/your/repo

# Or using the script directly
node kb-generator.js /path/to/your/repo

2. With Custom Output Directory

src-to-kb /path/to/your/repo --output ./my-knowledge-base

3. With OpenAI Embeddings

# Set your OpenAI API key
export OPENAI_API_KEY=your-api-key-here

# Generate with embeddings
src-to-kb /path/to/your/repo --with-embeddings

4. Search with Answer Modes

Choose the right answer mode for your needs:

# First generate a knowledge base
src-to-kb ./your-project --output ./project-kb

# Search with different modes:

# End User Mode - Simple, non-technical answers
src-to-kb-search search "how do I reset password?" --kb ./project-kb --mode enduser

# Developer Mode - Technical details and architecture (default)
src-to-kb-search search "authentication flow" --kb ./project-kb --mode developer

# Copilot Mode - Code examples and implementation patterns
src-to-kb-search search "implement user login" --kb ./project-kb --mode copilot

# View available modes
src-to-kb-search modes

Answer Modes ๐ŸŽฏ

The search tool adapts its responses based on who's asking:

ModeForDescriptionExample Use Case
enduserNon-technical usersSimple explanations without technical jargon, focuses on features and capabilitiesProduct managers, business stakeholders asking about features
developerSoftware developersFull technical details including architecture, dependencies, and implementation detailsEngineers understanding codebase structure and design patterns
copilotCoding assistanceCode examples, snippets, and implementation patterns ready to useDevelopers looking for code to copy/adapt for their implementation

Mode Examples

# CEO asks: "What payment methods do we support?"
src-to-kb-search search "payment methods" --mode enduser
# Returns: Simple list of supported payment options

# Developer asks: "How is payment processing implemented?"
src-to-kb-search search "payment processing" --mode developer
# Returns: Technical details about payment gateway integration, API endpoints, error handling

# Developer needs: "Show me payment integration code"
src-to-kb-search search "payment integration" --mode copilot
# Returns: Actual code snippets for payment implementation

How Modes Work

  • Filtering: Each mode filters results differently (e.g., end users don't see test files)
  • AI Prompts: Custom prompts guide AI to give appropriate responses
  • Formatting: Answers are formatted based on the audience (code blocks for developers, plain text for end users)
  • Context: Technical depth is adjusted (high for developers, low for end users)

Installation

Option 1: Install from npm (Recommended) โœ…

# Install globally from npm registry
npm install -g @vezlo/src-to-kb

# Now use the commands anywhere on your system
src-to-kb /path/to/repo                    # Generate knowledge base
src-to-kb-search search "your query"       # Search knowledge base
src-to-

โ€ฆ
View source on GitHub