Local Knowledge MCP
A security-first, read-only MCP server that lets clients browse and read text, PDF, and XLSX files from an explicit allowlist of local folders, with strict path and secret protections.
README
Local Knowledge MCP
A security-first, read-only Model Context Protocol (MCP) server for local folders.
Local Knowledge MCP lets an MCP client browse an explicit root allowlist, inspect metadata, read bounded text, and receive supported images and documents as MCP content. It is intentionally not a general-purpose filesystem write server.
Features
- Read-only by design and default-deny.
- Client paths use
root_alias + relative path; clients never send local absolute paths. - Blocks unknown roots, parent traversal, symlink escape, hidden paths, and common secret-bearing files.
- Atomically updates the persistent root configuration.
- Reloads the security policy on every tool call, so
lk-add,lk-remove, andlk-cleartake effect without a project-specific runtime manager. - Ships as a normal Python package with portable console commands.
- Provides guided ChatGPT setup through OpenAI Secure MCP Tunnel without bundling shared tunnel identities or credentials.
Requirements
- Python 3.11 or newer.
uvis recommended;pipxalso works.- For local stdio usage: an MCP client that can launch a local process.
- For ChatGPT usage: OpenAI tunnel permissions and ChatGPT developer-mode access.
lk-chatgpt-setupguides this optional flow.
Install
Directly from GitHub
With uv:
uv tool install "git+https://github.com/TuanLe-bk18/local-knowledge-mcp.git"
Or with pipx:
pipx install "git+https://github.com/TuanLe-bk18/local-knowledge-mcp.git"
From a clone
git clone https://github.com/TuanLe-bk18/local-knowledge-mcp.git
cd local-knowledge-mcp
uv tool install .
The installation provides:
local-knowledge-mcp
lk-init
lk-set
lk-add
lk-list
lk-remove
lk-clear
lk-chatgpt-setup
Update
If installed directly from GitHub with uv, refresh and reinstall the tool from the latest commit:
uv tool upgrade local-knowledge-mcp --reinstall
If installed with pipx:
pipx install --force "git+https://github.com/TuanLe-bk18/local-knowledge-mcp.git@main"
For an installation made from a local clone:
git pull --ff-only origin main
uv tool install --force --reinstall .
Restart or reconnect local MCP clients after upgrading. For a managed ChatGPT tunnel runtime, recreate it with the updated executable:
lk-chatgpt-setup --no-browser
The existing root configuration, tunnel ID, and runtime key file are reused.
Quick start
Initialize a secure empty configuration:
lk-init
Add one or more allowed folders:
lk-add project "~/Code/my-project"
lk-add notes "~/Documents/notes"
lk-list
Connect a local stdio MCP client
lk-init prints an MCP client configuration using the installed executable. A typical configuration is:
{
"mcpServers": {
"local-knowledge": {
"command": "local-knowledge-mcp"
}
}
}
Some desktop applications do not inherit your shell PATH. In that case, use the absolute command path printed by lk-init.
Restart or reconnect the MCP client after first adding the server. Root allowlist changes made while the server is running are loaded automatically on the next tool call.
See docs/client-setup.md for local stdio setup details and troubleshooting.
Connect ChatGPT with Secure MCP Tunnel
After configuring at least one root, run:
lk-chatgpt-setup
The command:
- discovers
tunnel-client, or offers to download the latest officialopenai/tunnel-clientrelease; - verifies the downloaded archive against the official
SHA256SUMS.txtasset; - opens OpenAI Platform tunnel and runtime-key setup pages;
- asks for the user's own
tunnel_idand hidden runtime API key; - stores the runtime key outside the repository in a user-private
0600file; - starts a managed tunnel runtime and waits until it reports
ready; - opens ChatGPT connector settings and prints the tunnel ID to select or paste.
The runtime key must have Tunnels Read + Use. An admin key is not accepted, stored, or passed to the long-lived runtime. Tunnel creation remains in the authenticated OpenAI Platform UI, so every installation uses the user's own tunnel identity and permissions.
See docs/chatgpt-setup.md for prerequisites, non-interactive options, credential storage, and troubleshooting.
Root commands
Replace every configured root with one workspace root:
lk-set "/path/to/folder"
Add or update an alias while preserving other roots:
lk-add project "/path/to/project"
List roots without touching the MCP process:
lk-list
Remove one alias:
lk-remove project
Remove all roots while keeping read-only/default-deny policy enabled:
lk-clear
Folder inputs are expanded, required to exist, required to be directories, and saved as canonical absolute paths. Aliases must begin with a lowercase letter and may contain lowercase letters, numbers, hyphens, and underscores.
The persistent configuration is stored outside the repository at:
~/.config/local-knowledge-mcp/security.yaml
No personal root configuration is bundled in the package.
MCP tools
browse(root_alias, path="")
get_info(root_alias, path)
read_text(root_alias, path, max_chars=None)
read_document_resource(root_alias, path)
read_file_resource(root_alias, path)
Example tool arguments:
{
"root_alias": "project",
"path": "docs/architecture.md"
}
read_file_resource returns PNG, JPEG, and GIF files as concise text metadata plus MCP ImageContent, with structured output disabled so clients can pass them to a model's image input without duplicating base64 as text. It returns allowed PDF, DOCX, PPTX, XLSX, and XLS files as EmbeddedResource values. It does not parse, OCR, index, or modify files. The existing read_document_resource tool remains available for PDF/XLSX compatibility.
Security model
Every filesystem access reaches SecurityPolicy.resolve() before touching a client-selected path. The default generated policy enforces:
mode:
read_only: true
default_deny: true
path_policy:
allow_absolute_paths_from_client: false
allow_parent_traversal: false
allow_symlinks: false
allow_hidden_files: false
Additional deny patterns block common credential, token, key, environment, build, and VCS paths. Direct text reads are UTF-8 only, extension-limited, binary-checked, file-size limited, and character-limited.
An empty root mapping is valid and denies every root alias. See SECURITY.md before changing policy defaults.
Scope
Included:
- directory browsing;
- file/directory metadata;
- bounded text/source reading;
- PNG/JPEG/GIF image content and PDF/DOCX/PPTX/XLSX/XLS embedded resources;
- local root allowlist management.
Not included:
- write, edit, delete, move, or create operations;
- arbitrary absolute-path access;
- OCR or document parsing;
- embeddings, vector databases, or RAG;
- a shared hosted tunnel, shared runtime credential, or shared cloud runtime.
For ChatGPT, lk-chatgpt-setup configures the official outbound Secure MCP Tunnel client on the user's machine. This repository never bundles tunnel credentials, identifiers, API keys, or machine-specific runtime state.
Development
git clone https://github.com/TuanLe-bk18/local-knowledge-mcp.git
cd local-knowledge-mcp
uv sync --all-groups
uv run pytest -q
uv build
See CONTRIBUTING.md for contribution guidelines.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.