RAG and Knowledge Graphs on a directory of Markdown files. Parses YAML frontmatter, builds a search index, auto-constructs a knowledge graph, and exposes everything through five interfaces.
00 — Quick Start
$ pip install mdaifs $ cd /path/to/your/markdown-repo $ mdaifs status # stats: files, chunks, graph $ mdaifs search "onboarding process" # full-text search $ mdaifs search "budget" --mode semantic # vector similarity $ mdaifs ls --department hr # list with filters $ mdaifs validate # check frontmatter schema $ mdaifs freshness # find stale documents $ mdaifs graph nina.scholz # knowledge graph query $ mdaifs impact hr # what breaks if HR changes?
01 — Features
BM25 lexical, semantic (sentence-transformers), and hybrid (RRF fusion) with frontmatter filtering.
Automatically constructed from frontmatter fields and Markdown links. Query neighbors, run impact analysis.
Detect documents not reviewed in >6 months based on last-reviewed frontmatter field.
Validate all files against a JSON Schema for frontmatter. Catch errors before they spread.
CLI, Python API, MCP server (for AI agents), REST API (for dashboards), FUSE mount (transparent to any tool).
Auto-reindex on file changes. Keep your search index and knowledge graph always up to date.
02 — Install
$ pip install mdaifs # core: CLI, BM25 search, graph, validation, freshness
| Extra | Command | Adds |
|---|---|---|
| semantic | pip install mdaifs[semantic] | Vector embeddings (sentence-transformers) |
| mcp | pip install mdaifs[mcp] | MCP server for AI agents |
| api | pip install mdaifs[api] | REST API (FastAPI) |
| fuse | pip install mdaifs[fuse] | FUSE virtual filesystem |
| watch | pip install mdaifs[watch] | File watcher daemon |
| all | pip install mdaifs[all] | Everything |
03 — CLI Commands
| Command | Description |
|---|---|
| status | Show repository statistics |
| search | Search (BM25/semantic/hybrid) with frontmatter filters |
| ls | List files with --department, --type, --status, --owner |
| validate | Validate all frontmatter against JSON Schema |
| freshness | Find documents not reviewed in >6 months |
| graph | Query knowledge graph neighbors of an entity |
| impact | Impact analysis: what is affected if an entity changes? |
| watch | Watch for changes and auto-reindex |
| serve | Start REST API (http://localhost:8900) |
| mcp-serve | Start MCP server for AI agents |
| mount | Mount as FUSE filesystem |
04 — Knowledge Graph
The graph is automatically constructed from your existing Markdown files — no manual configuration needed.
Deterministic: owner → has_owner, department → belongs_to, tags → has_tag
Deterministic: [text](path.md) → references
owner + department → works_in
$ mdaifs graph nina.scholz # nina.scholz --[works_in]--> hr # departments/hr/processes/recruiting.md --[has_owner]--> nina.scholz # departments/hr/processes/recruiting.md --[has_tag]--> recruiting
$ mdaifs impact lisa.weber # Affected documents (4): # departments/hr/processes/performance-review.md # departments/hr/policies/remote-work.md # ... # Affected departments: hr # Affected people: nina.scholz, markus.berger
05 — Python API
from mdaifs import MdaifsRepo repo = MdaifsRepo("/path/to/repo") # Search results = repo.search("onboarding", department="hr", top_k=5) for r in results: print(f"[{r.score:.2f}] {r.file_path}: {r.heading}") # Knowledge graph for t in repo.graph_neighbors("nina.scholz", depth=2): print(f" {t.subject} --[{t.predicate}]--> {t.obj}") # Impact analysis impact = repo.graph_impact("hr") print(impact.affected_documents) print(impact.affected_people) # Freshness for e in repo.freshness(): if e.category == "overdue": print(f" OVERDUE: {e.file_path} ({e.months_since:.0f} months)") # List with filters files = repo.list(department="hr", doc_type="process", status="active") # Validate errors = repo.validate() assert len(errors) == 0, f"{len(errors)} validation errors"
06 — MCP Server
For AI agents like Claude Code, Kivanto, and others.
$ mdaifs mcp-serve --repo /path/to/repo
{
"mcpServers": {
"mdaifs": {
"command": "mdaifs",
"args": ["mcp-serve", "--repo", "/path/to/repo"]
}
}
}
| Tool | Description |
|---|---|
| mdaifs_status | Repository statistics |
| mdaifs_search | Search with filters |
| mdaifs_list | List files with filters |
| mdaifs_graph_neighbors | Query knowledge graph |
| mdaifs_impact | Impact analysis |
| mdaifs_freshness | Freshness report |
| mdaifs_validate | Schema validation |
07 — REST API
$ mdaifs serve --port 8900 # API docs: http://localhost:8900/docs
| Method | Endpoint | Description |
|---|---|---|
| GET | /status | Repository statistics |
| GET | /search?q=... | Search with filters |
| GET | /files?department=hr | List files |
| GET | /frontmatter/{path} | File frontmatter |
| GET | /graph/stats | Graph statistics |
| GET | /graph/neighbors/{entity} | Graph query |
| GET | /graph/impact/{entity} | Impact analysis |
| GET | /freshness | Freshness report |
| GET | /validate | Schema validation |
| POST | /reload | Reload index + graph |
08 — FUSE Filesystem
$ mkdir /mnt/company $ mdaifs mount /path/to/repo /mnt/company # Regular files pass through $ cat /mnt/company/departments/hr/processes/recruiting.md # Virtual .mdaifs/ directory for queries $ cat /mnt/company/.mdaifs/status $ cat /mnt/company/.mdaifs/freshness $ cat /mnt/company/.mdaifs/search/budget+limits $ cat /mnt/company/.mdaifs/graph/neighbors/nina.scholz $ cat /mnt/company/.mdaifs/graph/impact/hr # Extended attributes expose frontmatter $ xattr -p user.mdaifs.owner recruiting.md # nina.scholz $ xattr -p user.mdaifs.department recruiting.md # hr $ xattr -p user.mdaifs.freshness recruiting.md # 0.87
09 — Frontmatter Schema
--- title: Recruiting Process # required, string owner: nina.scholz # required, firstname.lastname type: process # required, enum status: active # required, enum created: 2024-08-10 # required, YYYY-MM-DD department: hr # optional, enum last-reviewed: 2026-03-25 # optional, used for freshness tags: [recruiting, hiring] # optional, array of strings created-by: claude-code # optional, marks AI-generated content ---
| Field | Valid values |
|---|---|
| type | process, template, policy, decision, minutes, result, concept |
| status | draft, review, active, archived |
| department | hr, finance, product, marketing, engineering, company |
10 — Architecture
core.py — the single unified API. It lazy-loads on first access, so startup is instant.
11 — Roadmap
Core, CLI (11 commands), MCP (7 tools), REST, FUSE, search, graph.
Persistent index, incremental updates, plugins, PyPI.
Parser, index, graph, FUSE, CLI — single ~5MB binary.
Homebrew, APT, Docker, WASM, editor plugins.
CRDT collaboration, multi-modal, federated graphs.
12 — Ecosystem
mdaifs is the filesystem layer of the mdaios project — a framework for structuring enterprise knowledge in Markdown so that every AI agent can work with it.
13 — Papers
The conceptual paper. 4-layer model, RAG on Markdown, automatic knowledge graph construction from frontmatter, freshness scoring, progressive disclosure for agents.
The technical architecture paper. 5 implementation paths: FUSE virtual filesystem, system library (libmdaifs), MCP server, CLI, and REST API. Rust crate structure, migration strategy.