Keyhole – Local files for ChatGPT
This MCP server lets ChatGPT safely inspect and edit only local folders you explicitly open, with hash-checked writes and recoverable history.
Discover open workspaces, their read-only/read-write mode, exclusions, and limits.
List permitted directory entries and search file names or plain text with pagination.
Read text ranges, PDFs, DOCX, PPTX, XLSX, images, metadata, or just a file SHA-256.
Create or replace UTF-8 text files and apply exact literal text patches in read-write workspaces.
Create directories, copy, move/rename, and recoverably delete single regular files up to 8 MiB.
List recent changes, including interrupted ones, and restore/undo changes when paths still match.
Enforce workspace boundaries: no shell, no public endpoint, no recursive directory operations, no Office/PDF/image writes, and no code execution.
Provides a secure bridge for ChatGPT to read and edit local folders via OpenAI's Secure MCP Tunnel, with granular read-only or read-write access and an undoable change history.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Keyhole – Local files for ChatGPT Read README.md in my open project folder and summarize it."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Keyhole — local files for ChatGPT
Let ChatGPT read, and carefully edit, only the local folders you choose. No shell, no public port.
Example: turn a note on your computer into a TODO list, without uploading the file by hand.
1. In your terminal, allow the sample folder to be edited. One-time setup creates
~/KeyholeDemo with a fictional notes.md and shares it read-only as demo. Editing needs an explicit
local command:
keyhole access demo rw2. In ChatGPT, select your Keyhole app and ask:
Read
notes.mdindemo, turn its three ideas into TODO checkboxes, and save the file.
This is the real response from a session with the same fictional note, shared there as KeyholeDemo:

3. Back in your terminal, inspect the same file.
cat ~/KeyholeDemo/notes.mdIts three ideas now contain checkboxes. These lines were checked on disk after the edit:
- [ ] Read the field guide on Saturday.
- [ ] Summarize the chapter about night skies.
- [ ] Pack a notebook for Sunday's walk.You can ask ChatGPT to restore the returned change id. When finished, run keyhole close demo to stop
sharing the folder. See the complete read → edit → restore → close example, with real screenshots.
Keyhole is a small MCP server that runs on your Mac, Linux or Windows computer, plus a command-line
tool, keyhole. You open a folder with keyhole open; ChatGPT on the web can then read it through OpenAI's
official Secure MCP Tunnel. Give a folder
rw, and ChatGPT can also create and edit text files in it. Every edit is checked against the file's current
hash and recorded before it is applied. Individual file replacements are atomic; retained changes can be restored without overwriting later edits.
Unofficial project; not affiliated with OpenAI.
What you get
Read-only by default. ChatGPT sees a folder only after you open it, and cannot change a file until you say
--access rw. Nothing ChatGPT does can widen its own access: grants are managed by the local CLI only.Careful edits you can undo. Writes require the file's current SHA-256; updates based on a stale hash are refused. The previous content is kept in a private local history, and
restore_changerolls it back.Several folders, useful file formats. Open folders independently with their own ro/rw permissions. Text, PDF, Word, PowerPoint, Excel and images come back with hashes and ranges, so answers can cite what was read. Document parsers have CPU, time and input-size limits, but run with your OS permissions; they are not an OS sandbox.
The connection uses OpenAI's official client. It exposes no public endpoint and no remote shell. Close the last folder and the tunnel stops. Compare related projects.
Related MCP server: ChatGPT MCP Bridge
Start here
Follow the complete setup guide →
uv tool install keyhole-mcp
keyhole setupThe setup wizard can download the verified official client, resume incomplete configuration and open a read-only example. If PyPI is unavailable, use the exact wheel URL from GitHub Releases.
On Windows, follow the PowerShell guide instead. Its install command requests the x64 Python that Keyhole's dependencies need, on both x64 and ARM PCs.
That is the complete first-time path: check your account access, install the tools, connect your own tunnel, create a private ChatGPT app, and read a real demo file. Follow it once, from top to bottom. No Python, Git, Node, Docker or tmux installation is required. You need macOS, Ubuntu Linux or Windows 11, ChatGPT Developer mode and permission to create an OpenAI Platform tunnel and restricted runtime key. Budget about 15 minutes after account access is ready.
The GitHub repository supplies the software. You create your own tunnel and private ChatGPT app; there is no public Keyhole app to add in one click. OpenAI's Secure MCP Tunnel is for private connections, not public plugin-store distribution.
What makes it useful
Open several folders independently, keep some read-only, and allow recoverable text edits in others. Read documents as well as source code, then close a folder when the task is finished. Folder access always stays under your local control.
Compatibility
Surface | Verified / limitation |
macOS | Apple silicon, macOS 15.6 and 15.7.7. Intel and older macOS remain untested. |
Python | 3.11–3.14 in CI; |
Linux | Supported on Ubuntu x86_64. Real ChatGPT read/edit/restore/close verified on Ubuntu 24.04; Ubuntu 22.04/24.04 have Python 3.11–3.14 CI and artifact coverage. Other distributions and Linux ARM are untested. Evidence and limits. |
Windows | Windows 11 with x64 Python and local NTFS folders, from 0.5.0. Real ChatGPT read/edit/restore/close verified on a hosted Windows 11 ARM machine; Windows Server 2025 x64 has automated coverage. No physical consumer PC has been tested. Setup guide, evidence and limits. |
OpenAI client |
|
ChatGPT | Pro, web, Chat mode. Other eligible plans and fresh-account onboarding have not been tested here. |
Clean install | Release wheel tested with Git/Python developer-tool commands unavailable in a simulated environment; not a freshly erased Mac. |
How it works
flowchart LR
C[ChatGPT web] -->|tool call| T[OpenAI tunnel endpoint]
T <-->|outbound long-poll only| TC[tunnel-client on your computer]
TC -->|stdio JSON-RPC| K[keyhole MCP server]
K -->|opened folders only| F[(Your files)]
CLI[keyhole CLI] -.->|grants, ro / rw| Ktunnel-client is OpenAI's open-source client. It opens an outbound connection and forwards each request to
the Keyhole server over stdio; no port on your computer is exposed. The server reads and writes only inside folders
you opened, and refuses anything else.
Daily use
keyhole open ~/Documents/notes # read-only
keyhole open ~/code/app --access rw --name app # editable, shown to ChatGPT as "app"
keyhole open ~/code/app --exclude Private --exclude 'Secret/*'
keyhole access app ro # back to read-only
keyhole status # configuration, checks, runtime state
keyhole close --all # stop sharing; the tunnel stops too
keyhole resume notes # after a reboot, resume only an intended folder
keyhole history --limit 20 # recent recoverable changesNothing is shared after a reboot until you run keyhole resume. Closing or forgetting a folder never touches
its files.
Example requests in ChatGPT:
Read
app/src/config.py, fix the typo in the error message, and read the file back to confirm.
Search
notesfor "invoice", then quote the matching lines with their file paths.
For an edit, ChatGPT reads the file and its hash, proposes the change, and calls apply_text_patch or
write_file. Whether ChatGPT asks you before a write is ChatGPT's own setting for the app (it asks by
default and can remember your answer for a conversation); check the app's details if you never see a prompt.
What ChatGPT can do with each file type
File type | Read | Create, replace, patch | Copy, move, rename, delete, restore |
UTF-8 text: code, Markdown, JSON, YAML, TOML, shell, HTML, CSS, plain text, any other extension not listed below | by line range | yes ( | yes ( |
UTF-16 / UTF-32 text with a BOM | by line range | no, convert to UTF-8 first | yes ( |
text per page, one page as an image; no OCR | no | yes ( | |
Word | body paragraphs and tables | no | yes ( |
PowerPoint | slide and table text | no | yes ( |
Excel | cells, formulas and cached values; no recalculation | no | yes ( |
PNG, JPEG, WebP | the image, downscaled if large | no | yes ( |
Archives, executables, databases, media, legacy Office ( | metadata only | no | yes ( |
Copy, move, delete and restore treat every regular file up to 8 MiB as opaque bytes, so they work for binaries too. Keyhole cannot write Office documents, PDFs or images, and does not run code, macros or formulas.
Limits: text files up to 8 MiB; documents and images up to 64 MiB; 400 lines or 64 KiB per read; 1 MiB per
write_file; single files only, no recursive directory operations. Every response says when it was truncated.
Recovery history
Every change ChatGPT makes is written to ~/.config/keyhole/changes.sqlite3 (readable by you only) before
the file is touched: the paths, hashes and, by default, the previous content. That is what restore_change
and keyhole history use. ChatGPT can see paths, hashes and change ids, never the stored content.
History is bounded to 1000 records or 450 MiB. When it is full, the oldest completed records are dropped automatically; an interrupted operation is never dropped. Recovery can temporarily reserve one extra record and 48 MiB so a full history does not prevent repair. Retry an interrupted restore with the same request id; successful recovery returns history to the normal limits.
Closing or forgetting a folder keeps its history.
keyhole purge-history --before 2026-01-01 --confirmdeletes completed records before the start of that UTC calendar date: recordedcreated_atvalues use UTC, and the existing query compares them with the date string. The CLI also rejects a cutoff later than the host's local current date; near a timezone boundary that guard can differ from the UTC day. This describes the current implementation without changing the purge operation. Eviction or purge removes both recovery and replay protection for those records; history is not a permanent audit log.Prefer your own version control?
keyhole open <dir> --access rw --recovery offkeeps paths and hashes only. Edits are still hash-checked and interrupted operations can still be repaired, butrestore_changerefuses committed edits for that folder.
Safety on one screen
Grants live in
~/.config/keyhole/grants.jsonand change only throughkeyhole. There is no remote tool to add folders, run commands, use Git, or fetch URLs.Names such as
.git,.ssh,.env*,*.key,*.pem,credentials.json,node_modulesand agent state directories are hidden at any depth, in any letter case.keyhole openprints the full list.Your own
--excluderules: a pattern without a slash hides matching names at any depth (Private,*.log); a pattern with a slash is anchored at the folder root and hides that subtree (Secret/*,docs/*.md). Matching ignores case and Unicode normalization.ChatGPT can never modify Keyhole's own code or environment, the state directory, or shell startup files such as
.zshrcand.envrc, whatever spelling of the path it uses.Symbolic links, hard-linked files and special files are refused. Paths are opened component by component with
O_NOFOLLOWon macOS/Linux or parent directory handles on Windows, and re-checked before and after each operation.Hiding by file name is not secret detection: a token inside a shared source file is readable while the folder is open, and anything already sent to ChatGPT cannot be recalled by closing the folder.
Threat model, what is out of scope, and how to report a vulnerability: SECURITY.md.
Commands and tools
Command | What it does |
| Resumable wizard; optional verified client installation and read-only sample; |
| Update only a Keyhole-managed client to the version verified by this release |
| Accept a reviewed external-client update / replace the stored runtime key |
| Share a folder and start the runtime; new folders are |
| Change a saved folder's mode |
| Stop sharing; saved paths and history stay |
| Re-verify saved folders and share them again |
| Stop sharing and remove the saved configuration |
| Configuration, environment checks, runtime state, open folders |
| Readable next steps / issue-safe JSON without ids, private paths or names |
| Recent recoverable changes, including interrupted ones |
| Permanently delete completed history before a date |
Commands print JSON by default; "ok": false comes with an error.code you can act on.
status --human prints readable text. The setup/status options above require Keyhole 0.4.0 or later.
Tool ChatGPT calls | Effect |
| Open folders, their |
| Paged listing; literal search over names or plain text |
| Text ranges, document pages, images, or just the SHA-256 |
| Create or replace a UTF-8 file; apply exact literal replacements |
| Single-item file operations, each recoverable |
| Recent changes and undo |
The five read tools are marked read-only and the seven write tools destructive, which is what ChatGPT's write confirmation keys on. Full parameters, error codes and limits: docs/reference.md. Upgrades, custom paths and uninstall: maintenance.
Troubleshooting
Symptom | What to do |
| Run |
Missing or interrupted client download | Rerun |
Setup was interrupted or already ran | Rerun setup to reuse complete values and finish missing steps. Do not delete the state directory. |
|
|
| The folder, the state directory, or one of their parents is behind a symbolic link. Use the physical path ( |
| macOS is protecting the folder. Allow your terminal app under System Settings → Privacy & Security → Files and Folders, then retry. |
|
|
Tools missing in ChatGPT after an upgrade | Open the app's details in ChatGPT and press Refresh, then start a new chat. New folders never need a refresh. |
Glossary
Workspace: one opened folder, shown to ChatGPT under its name. Not a ChatGPT workspace (the team account).
ro / rw: read-only / read-write. New folders are
ro.Runtime: the
tunnel-clientprocess that keeps your tunnel connected and runs the Keyhole server.Chat vs Work: ChatGPT composer modes. Keyhole was tested in plain Chat; Work is not required.
Non-goals, and when to use something else
Keyhole will not run shell commands, tests or Git, drive your screen, expose a public endpoint, or let the remote side manage grants. If you use the ChatGPT desktop app, its local Work mode may already cover your needs on that machine. If you want ChatGPT to run commands in a repository, use a coding-oriented tool. Keyhole is for ChatGPT on the web, documents as evidence, and careful edits.
Optional: Codex companion
skills/keyhole/ is a skill for OpenAI Codex that lets it run keyhole on your explicit instruction and
explains the boundaries. Link that directory into ~/.codex/skills/ (the layout Codex discovers);
.codex-plugin/plugin.json describes the same skill for Codex's plugin installer. Not needed for ChatGPT.
Repository
Tracked: the server and CLI (
src/keyhole/), tests, docs, the Codex skill. Runtime state, keys, grants and recovery history live in~/.config/keyhole/and are never part of the repository.Maintained by Jovi; best-effort, single maintainer. Bugs and ideas: issues. How to work on it: CONTRIBUTING.md. Changes: CHANGELOG.md.
Platform evidence: validation. Release maintainers: Trusted Publishing.
License
MIT.
Available Tools
12 toolsapply_text_patchADestructiveIdempotent
Apply 1-64 literal replacements to an existing UTF-8 file <=8 MiB. Each edit has old/new text and exact match count (default 1); ambiguous matches are refused. Requires rw, observed SHA-256 and unique request_id. Preserves untouched content, BOM/newlines and permissions. Returns change_id for recovery.
Inputs: path (required), edits (required), workspace (required), request_id (required), +1 more.
copy_fileADestructiveIdempotent
Copy one regular file <=8 MiB within an rw workspace. Require source SHA-256 and an absent destination with an existing parent. No recursive trees, links or overwrite. Returns a recoverable change_id.
Inputs: path (required), workspace (required), request_id (required), destination (required), +1 more.
create_directoryADestructiveIdempotent
Create one absent directory in an rw space; parent must exist. Returns a change_id; restore removes it only if empty and unchanged. Cannot modify the workspace root.
Inputs: path (required), workspace (required), request_id (required).
delete_fileADestructiveIdempotent
Recoverably delete one regular file <=8 MiB from an rw space after checking its SHA-256. Stores original bytes in private local recovery history; use restore_change to undo. No directory or permanent deletion tool.
Inputs: path (required), workspace (required), request_id (required), expected_sha256 (required).
list_changesARead-onlyIdempotent
List 1-100 recent changes and interrupted commits for the current physical workspace. Returns paths, hashes, state and change_id, never backup contents. History persists offline; changing root identity does not inherit its history.
Inputs: workspace (required), limit.
list_directoryARead-onlyIdempotent
List 1-200 permitted entries at a workspace-relative directory. Follow next_cursor; changed content invalidates pagination.
Inputs: workspace (required), path, limit, cursor.
list_workspacesARead-onlyIdempotent
Discover current open workspace names, availability, exclusions and read limits. Local absolute paths are never required remotely.
Inputs: no named parameters.
move_fileADestructiveIdempotent
Move or rename one regular file <=8 MiB within an rw workspace, requiring source SHA-256 and an absent destination. Destination is verified before source removal; interruption is recoverable, not a multi-file atomic transaction. No recursive directory moves.
Inputs: path (required), workspace (required), request_id (required), destination (required), +1 more.
read_fileARead-onlyIdempotent
Read source with SHA-256 and ranges. Text: start/limit lines <=400, newline metadata for edits. PDF: pages <=5, mode=image renders one page, no OCR. DOCX: body blocks <=400. PPTX: slides <=20. XLSX: sheet and A1 cell_range <=2000 cells, formulas/caches without recalculation. Images return image content. mode=hash returns only SHA-256 for any permitted file <=64 MiB; mode=metadata avoids hashing/parsing. Never infer complete text from a truncated result.
Inputs: path (required), workspace (required), mode, limit, +4 more.
restore_changeADestructiveIdempotent
Undo one committed or interrupted change in an rw space, only if every affected path still matches that operation. Refuses to overwrite later edits. Removes created files, restores deleted/edited files, reverses moves, and removes created directories only if empty. Returns a new recovery record.
Inputs: change_id (required), workspace (required), request_id (required).
search_filesARead-onlyIdempotent
Literal name or plain-text search. Bounded scan reports omissions, incomplete scopes and next_cursor. PDF/Office/OCR content is not indexed.
Inputs: query (required), workspace (required), kind, path, +3 more.
write_fileADestructiveIdempotent
Create or replace a UTF-8 text/code/Markdown/config file in an rw space. Supply full text <=1 MiB, observed SHA-256 (or 'absent' for create), and unique request_id. Preserve existing UTF-8 BOM, CRLF and permissions by default; line_ending can be preserve/lf/crlf. Returns recoverable change_id. Prefer apply_text_patch for partial reads. No document binaries or code execution.
Inputs: path (required), text (required), workspace (required), request_id (required), +2 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 12 tools
Every tool has a unique, well-defined purpose with no overlap. For example, list_directory enumerates entries, search_files performs content searches, and read_file retrieves file contents with hashing options. Even similar operations like write_file (full replace) and apply_text_patch (partial edits) are clearly separated.
All tool names follow a consistent verb_noun pattern in snake_case: list_workspaces, search_files, read_file, apply_text_patch, create_directory, copy_file, etc. There are no deviations in style or grammar, making the API predictable and easy to navigate.
12 tools is ideal for a file management server. The count is sufficient to cover the full lifecycle of file operations—listing, searching, reading, writing, patching, copying, moving, deleting, and undoing changes—without redundancy or bloat.
The tool surface covers the entire file management domain: discovery (list_workspaces, list_directory), search (search_files), read (read_file with multiple formats), write (write_file, apply_text_patch), directory operations (create_directory), file manipulation (copy_file, move_file, delete_file), and change management (list_changes, restore_change). No critical operations are missing for the stated purpose.
Maintenance
Related MCP Connectors
Safe folder access for ChatGPT and Claude: read, write and search files, risky tools opt-in.
Your own computer's files from ChatGPT or Claude: folder rules, confirmations and undo.
Use your own Windows, Mac or Linux computer from ChatGPT, Claude, Cursor or Gemini CLI: run commands, read, write and search files, run long processes. Your computer only makes an outgoing connection (no open ports or VPN). Read-only mode, allowed folders, blocked commands and an action log keep you in control. Free plan available.
Use your Mac, Windows or Linux computer from ChatGPT, Claude or Codex: files, commands, documents.
Related MCP Servers
AlicenseNot gradedqualityBmaintenanceEnables ChatGPT, Codex, and compatible MCP clients to read bounded UTF-8 text and create files or directories in operator-selected folders, with strict protections against overwrites, deletes, and path escapes.Apache 2.0- AlicenseNot gradedqualityBmaintenanceEnables ChatGPT to read and edit local project files, inspect Git changes, and run approved development scripts through a secure MCP tunnel, with optional Codex Desktop integration.8Apache 2.0
- AlicenseAqualityCmaintenanceEnables ChatGPT to read and edit local text files, apply precise string replacements, and run Bash commands on a user's own macOS or Linux machine through a secure local tunnel without exposing public ports.4MIT
- AlicenseNot gradedqualityCmaintenanceEnables ChatGPT to browse, read, search, create, and edit files, run commands and Python, and use Git within configured local workspaces, with permission controls, background job management, and tunnel-based access.4MIT