Knowledge Master
by subzone
README.md
# β‘ Knowledge Master
**Your codebase's memory.** A local knowledge graph that gives AI agents real understanding of your architecture β not just text search.
[](LICENSE)


---
## Why
Every time you start a new AI chat, it forgets everything. You re-explain your architecture, conventions, dependencies. Knowledge Master gives your AI **permanent, structured memory** about your entire system.
Unlike flat RAG tools that return "chunks about X", Knowledge Master builds a **graph** β so it can answer "what breaks if I change X?" by traversing actual relationships.
## What it does
- π **Semantic search** across all your code, docs, and configs
- πΈοΈ **Knowledge graph** β relationships between services, people, repos, technologies
- π₯ **Blast radius** β "what depends on this service/file/technology?"
- π **Convention enforcement** β detects and enforces your team's patterns
- π€ **MCP server** β plugs directly into AI agents (Kiro, Claude, Cursor)
- π₯οΈ **Web UI** β search, browse, visualize your knowledge graph
- π **Local-first** β nothing leaves your machine
## Prerequisites
| Dependency | macOS | Ubuntu/Debian | Windows |
|---|---|---|---|
| **Docker** | `brew install colima && colima start` or Docker Desktop | `sudo apt install docker.io docker-compose-plugin` | [Docker Desktop](https://docker.com/products/docker-desktop/) |
| **Ollama** | `brew install ollama && ollama serve` | `curl -fsSL https://ollama.com/install.sh \| sh` | [Ollama installer](https://ollama.com/download) |
| **Python 3.11+** | `brew install python@3.12` | `sudo apt install python3.12 python3.12-venv` | [python.org](https://python.org/downloads/) |
## Quick Start
```bash
# Install (pick one)
pipx install knowledge-master # recommended (isolated, clean)
pip install knowledge-master # or with pip
# Or via Homebrew (macOS)
brew install pipx && pipx install knowledge-master
# Or from source
git clone https://github.com/subzone/knowledge-master.git
cd knowledge-master
python3 -m venv .venv && source .venv/bin/activate
pip install -e .
# One command setup
km start
# Index your first repo
km index ~/path/to/your/project
# Search
km search "authentication flow"
# Check blast radius
km blast-radius postgres
# Start web UI with graph visualization
km serve
```
**Requirements:** Docker, Ollama, Python 3.11+
## Features
### Semantic Search with Graph Context
```bash
$ km search "how does auth work"
ββββββββββ¬βββββββββββββββββββββββ¬ββββββββββββββββββββββ¬βββββββββββββββββββββββ
β Score β Source β Context β Preview β
ββββββββββΌβββββββββββββββββββββββΌββββββββββββββββββββββΌβββββββββββββββββββββββ€
β 0.847 β src/auth/service.py β repo:myapp, by:Alex β JWT token validat... β
β 0.791 β docs/auth.md β repo:myapp β Authentication f... β
ββββββββββ΄βββββββββββββββββββββββ΄ββββββββββββββββββββββ΄βββββββββββββββββββββββ
```
### Blast Radius Analysis
```bash
$ km blast-radius auth-service
π₯ Blast radius: auth-service
βββ βοΈ user-service (Service, via DEPENDS_ON)
βββ βοΈ payment-service (Service, via DEPENDS_ON)
βββ π¦ frontend (Repo, via USES_SERVICE)
βββ π€ Alex (Person, via AUTHORED)
4 entities affected
```
### Convention Enforcement
```bash
$ km check-conventions ~/my-project
β src/ directory (structure)
β separate test directory (testing)
β snake_case files (file-naming)
β Repository pattern (design-pattern)
1 convention(s) violated
```
### Web UI & Graph Visualization
```bash
$ km serve
Knowledge Master UI β http://127.0.0.1:9999
```
Interactive force-directed graph showing your entire knowledge topology:
- π¦ Repos (blue) β π§ Technologies (red)
- βοΈ Services (orange) β Dependencies
- π€ People β Authorship
- π Conventions (purple)
### MCP Integration (AI Agents)
Add to your Kiro/Claude agent config:
```json
{
"mcpServers": {
"knowledge": {
"command": "km-server"
}
}
}
```
Your AI agent gets these tools:
- `search` β semantic search with graph context
- `blast_radius` β dependency analysis
- `check_conventions` β verify code follows team patterns
- `index_repo` β add new repos to the knowledge base
## Architecture
```
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β Your AI Agent β
β (Kiro / Claude / Cursor) β
ββββββββββββββββββββββ¬βββββββββββββββββββββββββββββ
β MCP Protocol
ββββββββββββββββββββββΌβββββββββββββββββββββββββββββ
β Knowledge Master β
β β
β ββββββββββββ ββββββββββββββ ββββββββββββββ β
β β Search β βBlast Radiusβ β Conventionsβ β
β ββββββ¬ββββββ βββββββ¬βββββββ βββββββ¬βββββββ β
β β β β β
β ββββββΌββββββββββββββββΌββββββββββββββββΌβββββββ β
β β FalkorDB (Graph + Vector) β β
β β β β
β β [Repo]ββUSES_TECHβββΆ[Tech] β β
β β β β β
β β βββDEFINES_SERVICEβββΆ[Service] β β
β β β β β β
β β βββFOLLOWSβββΆ[Convention] β β
β β β β β
β β [Person]ββAUTHOREDβββΆ[Document] β β
β β β β β
β β [Chunk + Embedding] β β
β βββββββββββββββββββββββββββββββββββββββββββββ β
β β
β βββββββββββββββββββββββββββββββββββββββββββββ β
β β Ollama (nomic-embed-text) β β
β βββββββββββββββββββββββββββββββββββββββββββββ β
ββββββββββββββββββββββββββββββββββββββββββββββββββββ
```
## Commands
| Command | Description |
|---|---|
| `km start` | Boot Docker + pull embedding model |
| `km stop` | Stop containers |
| `km index <path>` | Index a git repo or docs directory |
| `km search <query>` | Semantic search with re-ranking |
| `km blast-radius <target>` | Multi-layer dependency analysis |
| `km safe-to-change <target>` | Risk assessment (safe/risky/dangerous) |
| `km who-owns <file>` | File ownership (git blame, recency-weighted) |
| `km check-conventions <path>` | Verify code follows detected patterns |
| `km connect <source>` | Pull from external MCP (email, Slack) |
| `km setup <tool>` | Auto-configure MCP for AI tools |
| `km watch <path>` | File watcher with auto re-index |
| `km upgrade` | Migrate graph schema |
| `km prune` | Remove stale/orphaned data |
| `km changelog` | Generate CHANGELOG.md |
| `km list` | Show indexed repos, techs, stats |
| `km remove <name>` | Remove a source |
| `km serve` | Start web UI at http://127.0.0.1:9999 |
| `km status` | Check system health |
## What gets extracted automatically
When you index a repo, Knowledge Master detects:
| Category | Examples |
|---|---|
| **Tech stack** | Languages, frameworks, packages from dependency files |
| **Services** | From docker-compose.yml and K8s manifests |
| **Dependencies** | Service-to-service relationships |
| **Conventions** | File naming (snake_case/kebab-case), folder structure, design patterns |
| **People** | Git commit authors and file ownership |
| **Code structure** | Functions, classes, chunked by AST-aware boundaries |
## Feature Status
| Feature | Status | Notes |
|---|---|---|
| Semantic search + re-ranking | β
Stable | Two-pass retrieval with confidence scoring |
| Knowledge graph (FalkorDB) | β
Stable | Nodes, edges, vector index, schema versioning |
| CLI (14 commands) | β
Stable | start, index, search, blast-radius, safe-to-change, who-owns, etc. |
| MCP server (8 tools) | β
Stable | search, blast_radius, safe_to_change, who_owns, check_conventions, index, status |
| REST API | β
Stable | /api/v1/ with OpenAPI docs |
| Web UI + graph viz | β
Stable | htmx + D3, search, file browser, graph |
| Git repo indexing | β
Stable | Parses code, extracts authors, detects tech stack |
| Multi-language static analysis | β
Stable | Python (ast), TypeScript, Go, Rust (tree-sitter) |
| Blast radius (multi-layer) | β
Stable | Imports β services β people, confidence levels |
| `safe-to-change` risk assessment | β
Stable | Blast radius + test coverage = risk score |
| Git blame ownership | β
Stable | Recency-weighted (3x/2x/1x) |
| Schema migrations | β
Stable | Auto-migrate, km upgrade |
| Deduplication | β
Stable | Content hash, skips unchanged |
| Convention detection | β‘ Basic | Folder structure + file naming patterns |
| Email connector (ms-365) | π§ͺ Experimental | Works, requires external MCP setup |
| `km watch` | π§ͺ Experimental | Polling-based, may change |
**Legend:** β
Stable β β‘ Basic (works, limited scope) β π§ͺ Experimental (may change)
## Comparison
| Feature | Knowledge Master | Generic RAG | GitHub Copilot | Glean |
|---|---|---|---|---|
| Graph relationships | β
| β | β | Partial |
| Blast radius analysis | β
| β | β | β |
| Convention enforcement | β
| β | β | β |
| Local-first (no cloud) | β
| β
| β | β |
| MCP integration | β
| β | β | β |
| Multi-repo intelligence | β
| Partial | β | β
|
| Cost | Free | Free | $19/mo | $15-30/mo |
## Development
```bash
# Run tests
pytest
# Lint
ruff check knowledge_master/
# Run MCP server directly
python -m knowledge_master.server
# Run CLI directly
python -m knowledge_master.cli status
```
## Security
Knowledge Master runs **entirely on your machine**. No data leaves localhost.
- All ports bound to `127.0.0.1` (not accessible from LAN)
- Ollama runs locally β no cloud API calls
- MCP server uses stdio (no network exposure)
- Optional API key auth for REST endpoints
```bash
# Enable API key auth
export KM_API_KEY=$(openssl rand -hex 32)
km serve
```
See [SECURITY.md](SECURITY.md) for full security model, risks, and hardening guide.
## Troubleshooting
| Issue | Fix |
|---|---|
| `km start` fails with "Docker not running" | Start Docker: `colima start` (macOS) or `sudo systemctl start docker` (Linux) |
| `km start` fails with "Ollama not found" | Install Ollama from https://ollama.com and run `ollama serve` |
| `km index` is slow | First run downloads the embedding model (~274MB). Subsequent runs are fast. |
| Web UI shows "Connection refused" | Make sure containers are running: `km start` |
| Search returns poor results | Index more content. Quality improves with more context in the graph. |
| Port 9999 already in use | Use `km serve --port 8888` |
## License
MIT
TDQS
A3.6/5.0
Scored across 8 tools
Disambiguation5/5
Each tool has a clearly distinct purpose: indexing, searching, impact analysis, ownership, conventions checking. Even similar tools like blast_radius and safe_to_change are differentiated by depth of analysis.
Naming Consistency4/5
Tools use snake_case consistently. Most follow verb_noun pattern (index_directory, check_conventions), but some are noun-based (blast_radius, safe_to_change). Still predictable and readable.
Tool Count5/5
8 tools is well-scoped for a knowledge management server. Each tool covers a core function without redundancy or bloat.
Completeness4/5
Covers indexing, search, impact analysis, conventions checking, and ownership. Missing delete or update operations for indexed data, but core read-oriented workflows are complete.
Maintenance
ActivityInactive
ResponsivenessNo issues