The Shared Project Brain for AI Coding Agents
KontextMind is a CLI tool and HTTP API server that provides AI coding agents with a centralized knowledge base about your project. It indexes code, generates summaries, builds knowledge graphs, and enables Q&A functionalityβall designed to help AI assistants understand and work with your codebase more effectively.
- Code Indexing β Scans project files and builds a comprehensive file index with change detection
- Symbol Extraction β Parses code to extract functions, classes, interfaces, and their relationships
- AI Summaries β Generates natural language summaries for files, functions, and modules using LLM providers
- Knowledge Graph β Builds a graph of project entities and their dependencies
- Chatbot KB β A knowledge base that answers questions about your project without revealing code
- Session Management β Multi-turn conversations with persistent context
- Dataset Preparation β Export training-ready datasets from Q&A interactions
- No Code Exposure β The chatbot never reveals source code, file paths, or directory structures
- Secret Scanning β Detects secrets and credentials committed to the repository
- Privacy-First β Designed to protect sensitive project information
- CLI β Full-featured command-line interface
- HTTP API β REST API server for frontend applications
- MCP Server β Model Context Protocol server for AI agent integration
# Clone the repository
git clone https://github.com/your-org/kontextmind.git
cd kontextmind
# Install dependencies
pnpm install
# Build all packages
pnpm build
# Link CLI globally (optional)
pnpm link -g- Node.js 18+
- pnpm 8+
- For AI features: An LLM provider (OpenAI, Anthropic, Ollama, or custom)
cd your-project
kontextmind initThis creates:
.kontextmind/config.jsonβ Project configurationCLAUDE.mdβ Context for AI assistantsAGENTS.mdβ Agent-specific instructions.roo/mcp.json,.mcp.json,.codex/config.toml,.cursor/mcp.jsonβ Agent IDE MCP configs- Policy and instruction files
# Scan files and build index
kontextmind scan
# Extract symbols and build knowledge graph
kontextmind index
# Generate AI summaries (requires LLM provider)
kontextmind summarize --mock # Use mock provider
kontextmind summarize # Use configured provider# Build chatbot knowledge base
kontextmind kb build# Simple Q&A
kontextmind ask "What is this project about?"
# With JSON output
kontextmind ask "How does authentication work?" --json
# Session-based chat
kontextmind session create
kontextmind session chat <session-id> "What files handle user authentication?"# Start HTTP API server
kontextmind serve --port 7331
# Or with custom settings
kontextmind serve --port 8080 --host 0.0.0.0βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β User Interface Layer β
β βββββββββββ ββββββββββββ βββββββββββ βββββββββββββββββββββββββββ β
β β CLI β β HTTP API β β MCP CLI β β Frontend / AI Agent β β
β ββββββ¬βββββ ββββββ¬ββββββ ββββββ¬βββββ βββββββββββββ¬ββββββββββββ β
βββββββββΌββββββββββββΌββββββββββββββΌββββββββββββββββββββββΌββββββββββββββ
β β β β
βΌ βΌ βΌ βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Core Package (@kontextmind/core) β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ βββββββββββ β
β β Scanner β β Parser β β Summaries β β Chatbot β β
β β Index β β Symbols β β Knowledge β β KB β β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ ββββββββββ β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ βββββββββββ β
β β Session β β Dataset β β Security β β Init β β
β β Manager β β Pipeline β β Audit β β Config β β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ βββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
| Package | Description |
|---|---|
@kontextmind/core |
Core functionality: scanner, parser, summaries, chatbot KB |
@kontextmind/cli |
Command-line interface |
@kontextmind/server |
HTTP API server |
@kontextmind/mcp |
MCP (Model Context Protocol) server |
@kontextmind/client |
JavaScript client library |
kontextmind/
βββ apps/
β βββ cli/ # Command-line interface
βββ packages/
β βββ core/ # Core functionality
β β βββ src/
β β βββ chatbot/ # Chatbot knowledge base
β β β βββ session-manager.ts # Session management
β β β βββ context-builder.ts # Context building
β β β βββ kb-builder.ts # Knowledge base builder
β β βββ dataset/ # Dataset preparation
β β β βββ collector.ts # Data collection
β β β βββ quality-filter.ts # Quality filtering
β β β βββ versioning.ts # Version control
β β β βββ formats/ # Export formats
β β βββ config/ # Configuration schemas
β β βββ filesystem/ # File utilities
β β βββ init/ # Project initialization
β β βββ obsidian/ # Obsidian export
β β βββ parser/ # Code parsing
β β βββ providers/ # LLM providers
β β βββ scanner/ # File scanning
β β βββ security/ # Security audit
β β βββ summaries/ # AI summaries
β β βββ templates/ # Template rendering
β βββ server/ # HTTP API server
β β βββ src/
β β βββ routes/ # API routes
β β β βββ ask.ts # Ask endpoints
β β β βββ sessions.ts # Session endpoints
β β β βββ feedback.ts # Feedback endpoints
β β β βββ dataset.ts # Dataset endpoints
β β βββ services/ # Business logic
β β βββ ask-service.ts
β β βββ session-service.ts
β β βββ feedback-service.ts
β β βββ dataset-service.ts
β βββ mcp/ # MCP server
β βββ adapters/ # Provider adapters
β βββ client/ # Client library
βββ docs/ # Documentation
β βββ cli-reference.md # CLI commands reference
β βββ api-reference.md # API endpoints reference
βββ templates/ # Project templates
{
"project": {
"name": "my-project",
"description": "Description of what this project does"
},
"mode": "readonly",
"phase": 1,
"agents": ["claude", "codex", "roo", "cursor"],
"git": {
"enabled": true,
"mode": "auto"
}
}{
"selected_provider": "openai",
"providers": {
"openai": {
"type": "openai",
"api_key_env": "OPENAI_API_KEY",
"model": "gpt-4"
},
"ollama": {
"type": "ollama",
"base_url": "http://localhost:11434",
"model": "llama3"
}
}
}| Variable | Description | Default |
|---|---|---|
DATA_DIR |
Directory for project data | /kontextmind/projects |
LOG_LEVEL |
Logging level | info |
KontextMind operates in four modes:
| Mode | File Modifications | Description |
|---|---|---|
readonly |
Prohibited | Summaries and context only |
suggest |
Prohibited | Suggestions without implementation |
edit-with-approval |
Requires approval | Implement with explicit approval |
full-agent |
Allowed | Act autonomously within policy |
KontextMind supports multi-turn conversations with persistent context.
- Create a Session β Each conversation gets a unique ID
- Build Context β The system tracks topics, entities, and conversation history
- Enhanced Responses β Questions are answered with conversation context
- Link to Dataset β Session data enriches the training dataset
- No Context Repeating β Users don't need to re-explain the project
- Better Answers β The LLM has conversation history
- Rich Dataset β Follow-up questions show engagement patterns
- Topic Tracking β Sessions track what topics were discussed
# Create session
kontextmind session create
# Session created: abc-123-xyz
# Ask first question
kontextmind session chat abc-123-xyz "How does auth work?"
# Returns answer with conversationTurn: 1
# Ask follow-up
kontextmind session chat abc-123-xyz "Show me the relevant files"
# Returns answer with conversationTurn: 2
# List all sessions
kontextmind session list
# View session details
kontextmind session show abc-123-xyzKontextMind collects Q&A interactions for training AI models.
The system automatically collects:
- Q&A Events β Questions and answers with metadata
- Feedback β Like/dislike signals from users
- Session Data β Multi-turn conversation context
- Quality Scores β Computed from confidence and feedback
Records are filtered by:
- Confidence Threshold β Minimum confidence score (default: 0.5)
- Source Priority β API > MCP > CLI (better feedback quality)
- Code Request Detection β Auto-negative for code requests
- Deduplication β Remove duplicate questions
- Age Filter β Records older than 90 days excluded by default
| Format | Use Case |
|---|---|
jsonl |
Line-oriented training (Llama, Mistral) |
json |
Batch processing |
chatml |
Chat-based models |
sharegpt |
ShareGPT compatible |
Datasets are versioned for tracking changes:
# Export dataset
kontextmind dataset export --format jsonl --output dataset.jsonl
# View statistics
kontextmind dataset stats
# Validate quality
kontextmind dataset validate --min-quality 0.6
# List versions
kontextmind dataset version listThe chatbot is configured with strict policies:
- No source code in responses
- No file paths or directory structures
- No code formatting in output
# Scan for secrets
kontextmind secrets --fail-on-critical
# Output as JSON
kontextmind secrets --json# View audit summary
kontextmind audit --since 24h
# Export audit log
kontextmind audit --jsonKontextMind includes an MCP server for AI agent integration.
# STDIO transport (default)
kontextmind mcp
# HTTP transport
kontextmind mcp --transport http --port 7332# Build all packages
pnpm build
# Build specific package
pnpm --filter @kontextmind/core build# Run tests
pnpm test
# Run specific package tests
pnpm --filter @kontextmind/core test- CLI Reference β All CLI commands with examples
- API Reference β All API endpoints with examples
MIT