mcp-local-knowledge
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
mcp-local-knowledge
A local MCP server (stdio) that indexes your
Markdown and TXT notes under one authorized folder and answers searches with the
file and the line numbers of the match. Python, SQLite FTS5, the official mcp SDK.
Nothing leaves your machine.
Problem
An AI assistant that can read your notes usually gets either the whole folder or
nothing. This server sits in between: the assistant gets search and line-range
reading over one folder you choose, results point at file:line so you can verify
them, and anything that resolves outside that folder (.., absolute paths, symlinks)
is refused.
Related MCP server: brain-mcp
Install
Requires Python 3.10+. Dependencies are locked in uv.lock.
git clone <this repo> && cd mcp-local-knowledge
uv sync --frozen --extra dev # with uv
# or: python3 -m venv .venv && .venv/bin/pip install -e ".[dev]"Run
Try it from a terminal first (bundled sample data in examples/sample_docs):
mcp-local-knowledge --root examples/sample_docs --db ./knowledge.sqlite index
mcp-local-knowledge --root examples/sample_docs --db ./knowledge.sqlite search "restore drill" --limit 2Real output (index, first run):
{
"added": ["guides/backups.txt", "guides/incident-response.md", "onboarding.md"],
"updated": [],
"removed": [],
"unchanged": 0,
"refused": [],
"files": 3,
"chunks": 13
}(The CLI prints the lists one item per line; shortened here.) Real output of the search:
[
{
"file": "guides/backups.txt",
"start_line": 6,
"end_line": 8,
"matched_lines": [
{ "line": 6, "text": "Restore drill" },
{ "line": 7, "text": "Run a restore drill once per quarter." }
],
"score": 4.671
}
]Serve over stdio for an MCP client:
mcp-local-knowledge --root /path/to/your/notes serve--root can also come from MCP_LOCAL_KNOWLEDGE_ROOT, and --db from
MCP_LOCAL_KNOWLEDGE_DB. Without --db the index lives in
$XDG_CACHE_HOME/mcp-local-knowledge/ (default ~/.cache/...), one file per root.
See .env.example.
Typical client entry (JSON, same shape most MCP hosts use; not tested with a real host, see below):
{
"mcpServers": {
"local-knowledge": {
"command": "mcp-local-knowledge",
"args": ["--root", "/path/to/your/notes", "serve"]
}
}
}Tools
Tool | What it does |
| Full-text search. Returns |
| Rescans the folder. Adds new files, updates changed ones, drops deleted ones. Reports files it refused. |
| Reads a line range of a file inside the folder. At most 200 lines per call. |
| Number of indexed files and chunks. |
The server also reindexes once at startup. There is no file watcher: call reindex
after files change.
Demo: search, edit a file, reindex, try to escape
python examples/demo.py # temporary copy of the sample docs, nothing is modified
python examples/stdio_client.py # spawns the real server and calls the tools over stdioReal output of examples/demo.py, abridged to the parts that matter:
== 3. search 'kubernetes' (no hits yet)
[]
== 4. reindex after editing onboarding.md
{ "added": [], "updated": ["onboarding.md"], "removed": [], "unchanged": 2, "refused": [] }
== 5. search 'kubernetes' again
[ { "file": "onboarding.md", "start_line": 16, "end_line": 16,
"matched_lines": [ { "line": 16, "text": "We now deploy to kubernetes clusters." } ], "score": 2.6845 } ]
== 6. reindex with an escaping symlink
{ ..., "unchanged": 3, "refused": [ { "path": "evil-link.md", "reason": "symlink escapes the authorized folder" } ] }
read '../outside-secret.md' -> refused: path resolves outside the authorized folder
read 'evil-link.md' -> refused: path resolves outside the authorized folder
read '<absolute path outside root>' -> refused: path resolves outside the authorized folderReal output of examples/stdio_client.py for a path outside the folder:
read_lines {"path": "../../README.md"}
{ "error": "refused: path resolves outside the authorized folder" }How it works
Files with
.md,.markdownor.txtare split into chunks of consecutive non-blank lines (at most 20 lines each). Each chunk keeps its start and end line.Chunks go into SQLite with an FTS5 index (BM25 ranking, case and accent insensitive). A query first requires all terms (AND), and falls back to any term (OR) when nothing matches. Query text is quoted term by term, so FTS syntax in a query cannot break the search.
Reindex compares size and mtime, then a SHA-256 of the content, so a
touchdoes not rewrite the index.Confinement (
paths.py): every path is fully resolved (symlinks followed) and must land inside the resolved root, be a regular file, and have an allowed extension. The indexer does not follow directory symlinks, and skips file symlinks whose target is outside the root, broken links, hidden files and folders,node_modules,__pycache__,venv,env, and files over 1 MB. Skipped symlinks are listed underrefusedin the reindex report.
Tests and checks
uv run ruff check .
uv run mypy
uv run pytest -q33 tests, no network, keys or accounts. They cover: line numbers in results, nested
paths, accent folding, CRLF and empty files, FTS syntax in queries, OR fallback,
reindex after edit/add/delete, touch without content change, .. and absolute
paths, null bytes, wrong extensions, directories, symlinks to files and directories
outside the root (refused), symlinks inside the root (allowed), a symlink swapped in
after indexing, the CLI, and the real server spawned over stdio and driven by the MCP
client.
Checked on this machine (macOS, Python 3.12.13, mcp 2.3.0 from uv.lock): ruff,
mypy (strict) and all 33 tests pass from a clean install.
What was and was not verified
Verified: everything above, with the official
mcpclient talking to the real server over stdio.Integrations tested only with mocks: none. The project has no external service integrations. Everything runs locally against SQLite and the filesystem.
PENDING, not run: the CI workflow (
.github/workflows/ci.yml) has not run on GitHub; Python 3.10 and 3.13 from its matrix were not run locally; no real MCP host (Claude Desktop, an IDE) was connected, so the client config above is the standard shape, not a tested one; Windows was not tested.
Limitations
Keyword search only. No semantic search, no synonyms, no stemming.
Only
.md,.markdownand.txt. No PDF.Changes are picked up at startup and on
reindex, not live. An edit that keeps the same size and the same mtime (nanosecond) is not detected.A symlink to a directory is never followed, even when it points inside the root. File symlinks pointing inside the root are indexed.
read_lineschecks the path and then reads it; a file swapped for a symlink in that gap is not guarded against. Run it on a folder you control.Files are decoded as UTF-8 with replacement characters for invalid bytes.
Each root gets its own SQLite file; two server processes on the same index file are not coordinated beyond SQLite's own locking.
Roadmap
PDF text extraction (page numbers instead of line numbers).
Optional semantic search (local embeddings), kept off by default.
File watching so
reindexis automatic.
License
MIT, see LICENSE.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Read and search folders on your own computer with explicit consent. Files are never uploaded.
Search and read your own notes: insights, drafts, book and podcast notes. Read-only, OAuth.
Recall authorized Vault notes with keyword and hybrid search, original excerpts, and source paths.
Search, read, and safely update Markdown notes in your connected Phasoric knowledge vaults.
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceEnables secure, read-only access to text and code files inside user-configured local folders on Windows, with directory listing, file reading, and text search capabilities.Apache 2.0
- AlicenseAqualityBmaintenanceEnables searching, listing, and reading local notes with security constraints like path traversal protection and configurable limits.3MIT
- AlicenseNot gradedqualityCmaintenanceEnables ChatGPT to search and fetch approved local Markdown notes through a private, read-only connection, returning results with file names, line numbers, and source context.MIT
- AlicenseAqualityBmaintenanceProvides read-only access to a local Markdown notes directory for AI assistants, enabling full-text search, note reading, recent-note listing, statistics, indexed resources, and weekly-review prompts while enforcing path safety and output budgets.4MIT