DEV Community

Cover image for Show DEV: I Built a Zero-Knowledge MCP Bridge to Let Claude.ai Edit My Local Codebase Safely
QuantumTechCoder for Necoz

Posted on Edited on

Show DEV: I Built a Zero-Knowledge MCP Bridge to Let Claude.ai Edit My Local Codebase Safely

Bypasses paid tiers securely

If you use claude.ai in the browser for coding, you already know the workflow tax: ask Claude for a refactor, wait for the artifact, copy the file, paste it locally, realize Claude missed an import in another file, copy that file back into the chat, repeat.

Claude Desktop has local MCP servers, and Claude Code exists in the terminal - The catch? They are almost always PAID. But if you want to use claude.ai on the web (including on the free tier, or from any browser) and let it actually read, diff, and patch files on your machine without handing your codebase to a cloud server, there wasn't a clean way to do it.

So I built LocalWriteAgent-MCP — a single npx command that bridges claude.ai's Remote MCP (Streamable HTTP) to your local working directory over a zero-knowledge WebSocket tunnel, with interactive terminal diff review enabled by default.

LocalWriteAgent-MCP Landing Page


The Core Problem: Web AI vs. Local Disk

claude.ai's Custom Connectors speak Remote MCP over Streamable HTTP. That means claude.ai needs a public https://.../mcp endpoint it can POST JSON-RPC 2.0 requests to. Your laptop behind NAT doesn't have one, and you shouldn't have to punch holes in your router or run ngrok every time you open a repo.

At the same time, if you put a relay in the cloud, the relay becomes a trust boundary. If the relay logs payloads, caches directory trees, or stores your session keys in plaintext, you've just leaked your codebase.

Here is how LocalWriteAgent splits the responsibilities:

claude.ai (Browser)
   │  POST /mcp (Streamable HTTP / JSON-RPC 2.0)
   ▼
Hosted Relay (FastAPI + WebSocket Hub)
   │  Routes in-memory by session key. Logs only SHA-256 key prefixes & tool names.
   │  Never stores file contents, diffs, paths, or arguments.
   ▼
npx localwriteagent (Your Terminal)
   │  Canonical realpath sandbox + Sensitive File Guard + Color Diff Review
   ▼
Local Filesystem
Enter fullscreen mode Exit fullscreen mode

Setting It Up (Takes ~30 Seconds)

1. Add the Remote MCP Connector in claude.ai

In claude.ai -> Settings -> Connectors -> Add custom connector, point it to the public relay endpoint:

  • Server URL: https://quantumtechcoder-claudelocalwrite-mcp.hf.space/mcp
  • Name: LocalWriteAgent-MCP

claude.ai detects No sign-in automatically because authentication happens per-session with an ephemeral key you control locally.

Adding LocalWriteAgent-MCP as a custom connector in claude.ai

2. Start the Local Listener

In whatever project directory you want Claude to work in, run:

npx localwriteagent
Enter fullscreen mode Exit fullscreen mode

It generates a 10-character session key (enforcing >= 8 distinct characters so weak keys like AAAAAAAAAA are rejected) and opens a WebSocket tunnel to the relay using Authorization: Bearer <KEY> headers — never putting the credential in the URL query string.

Terminal running npx localwriteagent with active session key

3. Give Claude the Session Key

Open a chat on claude.ai and give it the key from your terminal. To stress-test all the safety rails at once, I gave Claude a deliberately risky prompt:

"Create dummy.txt, create and read .env, delete dummy.txt, and try to inspect the parent directory."

Prompting Claude in claude.ai with the session key


Watching the Safety Rails Fire in Real Time

As soon as Claude receives the key, it starts with list_tree to map the working directory (skipping node_modules, .git, dist, and build artifacts automatically).

Local CLI executing list_tree

In the claude.ai UI, each local filesystem action shows up as a standard MCP tool call:

Claude.ai UI showing Remote MCP tool calls

1. Safe Edit Review Is On By Default

Claude cannot silently write or overwrite files. By default, every write_file and patch_file pauses execution and prints a unified color diff directly in your terminal. You choose [Y]es once, [A]lways this file (session), or [N]o (defaulting to N if you hit Enter).

Interactive diff preview for creating dummy.txt

(If you're working in a scratch repo and want auto-approval for CWD writes/patches, you can opt in with npx localwriteagent --yes — though deletions still prompt.)

2. Sensitive File Guard (.env, Keys, Credentials)

Next, Claude tried to write .env. Even though I had just pressed A for dummy.txt, sensitive files bypass session caching. LocalWriteAgent inspects canonical paths against patterns for .env*, *.pem, *.key, id_rsa*, .git-credentials, .npmrc, .pypirc, .docker/config.json, kubeconfig, *.tfstate, and shell histories.

Writing .env triggered a red SECURITY ALERT:

Security alert when Claude attempts to write .env

And when Claude immediately tried to read_file on .env, it triggered a second SECURITY ALERT — because read access inside CWD is only auto-approved for non-sensitive files:

Security alert when Claude attempts to read .env

3. Deletions Can Never Be Auto-Approved

When Claude called delete_file on dummy.txt, the terminal threw a red deletion warning showing the file size and line count, requiring explicit confirmation. Even if you launch the agent with --yes, delete_file always asks.

Delete confirmation warning in terminal

4. Canonical Sandbox & External Folder Access

Finally, Claude tried to inspect the parent directory (D:\Arduino Rockz\QuantumTechCoder) — outside the active working directory.

Before list_tree enumerates anything, the path is resolved via fs.realpathSync (closing symlink and ../ traversal escapes) and checked against CWD. Because it's outside CWD, the agent blocks and asks whether you want to grant [R]ead, [B]oth, or [N]o, and whether that grant is [O]nce or for the [S]ession:

External folder access prompt for parent directory

Back in claude.ai, Claude summarizes every step cleanly:

Claude.ai final summary of completed local operations

When you're done, Ctrl+C tears down the WebSocket tunnel and clears the session from relay memory immediately:

Clean shutdown of LocalWriteAgent-MCP listener


Architecture Details Worth Knowing

A few things I had to get right while hardening the relay and agent:

  • Fail-closed timeouts: The relay enforces a 45-second timeout per tool call so claude.ai doesn't hang forever if you walk away from a terminal prompt. On timeout, the relay sends a tools/cancel JSON-RPC notification down the tunnel, and the agent aborts the active readline prompt so a stale write can never be approved late.
  • Atomic writes: write_file and patch_file write to a sibling .tmp.<timestamp>.<rand> file and fs.renameSync into place, so a mid-write crash won't leave half-written source files.
  • Token-efficient patch_file: Instead of burning output tokens rewriting an entire 500-line file, patch_file requires a unique target_text match and swaps only that block.
  • Zero-knowledge relay hygiene: Operational logs at /logs only keep a bounded 100-entry ring buffer of tool names, durations, and 8-char SHA-256 session hashes. When active tunnels hit zero and idle time passes, the buffer is wiped and gc.collect() runs. Sessions also expire automatically after 8 hours.

Try It Out

If you want to self-host the Python FastAPI relay instead of using the public one, the entire relay/ service is MIT-licensed in the repo and takes one command (python relay/app.py). Pull requests and security reviews are welcome.

Note: This works for any AI chatbot that supports Streamable / Direct HTTP MCP servers. Not just Claude. I mentioned Claude because, one of my friend is an AI assisted coder and he always uses Claude, never wanted to spend a penny. So I researched the problems, and thats how I came to this idea

Top comments (17)

Collapse
 
quantumtechcoder profile image
QuantumTechCoder Necoz •

Whats the next update we should add to this? Adding command execution?
Let me know in the comments!

P.S: @effessdev Bro, I know this feels like I'm copying your ReptClip, but uh the reality is that I saw your ReptClip project after I was halfway done through LocalWriteAgent-MCP.

Collapse
 
effessdev profile image
EffessDev Necoz •

No no no hehe this is completely fine 😊 Its purpose is quite different from ReptClip. We are deliberately not adding these kinds of features to it because we need it to be compatible with any chatbot with zero setup! Continue building!!! 🔥

Collapse
 
quantumtechcoder profile image
QuantumTechCoder Necoz •

Ha ha, I just aimed for frontier models - those always have MCP server linking configurations in settings 😁

Thread Thread
 
effessdev profile image
EffessDev Necoz •

Yeah yeah I understand! This project is different from ReptClip! It's made for clipboard only! ⚡ Zero setup, just install and use!

Thread Thread
 
quantumtechcoder profile image
QuantumTechCoder Necoz •

Zero setup? ReptClip definitely
Autonomy + Frontier model? LocalWriteAgent
🤣
P.S: star the project on github, im kinda star-less 🤣

Thread Thread
 
effessdev profile image
EffessDev Necoz •

Ok I'll star the project 😄 Please start ReptClip as well if you haven't already :)

Thread Thread
 
quantumtechcoder profile image
QuantumTechCoder Necoz •

Done 👍

Thread Thread
 
effessdev profile image
EffessDev Necoz •

Ok you got yours I got mine 🤝🤣 (🤫)

Collapse
 
quantumtechcoder profile image
QuantumTechCoder Necoz •

Note: CONTRIBUTIONS ARE WELCOME!
WE WOULD LOVE TO SEE YOUR CONTRIBUTIONS!
Even if its just a single line UI tweak, large scal optimization, bring it on!
If its good, it WILL be merged. :D

P.S: Even if you dont contribute, or even if you didnt even dare read the entire README.md of the repo, drop a star on the repo, its free :>

Collapse
 
quantumtechcoder profile image
QuantumTechCoder Necoz •

@effessdev , Don't consider this project as something to downgrade yours. Mine is a different architecture, and yours is a very unique one. Both of our projects are equally good :D

Collapse
 
effessdev profile image
EffessDev Necoz •

BROOOOOOO 🤦‍♂️🤦‍♂️🤦‍♂️

I do not consider this to downgrade ReptClip at all why keep saying this? 🤣 (I am linking ReptClip everywhere it's ok right hehe) Your project is good! Mine is just built for a different purpose!

Thread Thread
 
quantumtechcoder profile image
QuantumTechCoder Necoz •

Alright ill stop the spam lol 🤣

Thread Thread
 
effessdev profile image
EffessDev Necoz •

👍🤣 BTW this works only with Claude.ai or other AIs as well? 🤔

Thread Thread
 
quantumtechcoder profile image
QuantumTechCoder Necoz •

Can be used in any AI chatbot web interface or desktop interface where you can stuff this mcp server into its brain :D

Thread Thread
 
effessdev profile image
EffessDev Necoz •

So it works on whatever chatbot supports that? Which chatbots are supported? (Examples?) 🤔

Collapse
 
nyaomaru profile image
nyaomaru Necoz •

Interesting approach! 😸💚

I like the idea of keeping developers in control through interactive diff reviews and explicit permissions.

I'm curious to see how this architecture evolves! 👍

Collapse
 
maxbuildsdev profile image
Max Kaya •

realpathSync closes the ../ and symlink escapes, but not hardlinks: ln .env notes.txt gives a path that canonicalizes to itself while the inode is still your credentials file, and your pattern list only ever sees the name. Comparing dev+ino of each write target against the guarded set (plain fs.statSync, no realpath) closes it, and it also catches the cp -l case for free.

The bigger hole is the entry point. npx localwriteagent resolves latest from npm on every run, so the thing getting read/write in my working directory is whatever was published most recently — I'd pin [email protected] in the README and have the CLI refuse to start when its own version doesn't match a configured one. Related: when the 45s relay timeout fires and the readline prompt aborts, what happens to a keypress that was already buffered in the tty? I'd want the pending approval record deleted before the abort, otherwise a late Y lands in the next prompt and approves something the model already gave up on.