[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-3508":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":14,"contributorsCount":15,"subscribersCount":15,"size":15,"stars1d":15,"stars7d":15,"stars30d":16,"stars90d":15,"forks30d":15,"starsTrendScore":15,"compositeScore":17,"rankGlobal":10,"rankLanguage":10,"license":18,"archived":19,"fork":19,"defaultBranch":20,"hasWiki":21,"hasPages":19,"topics":22,"createdAt":10,"pushedAt":10,"updatedAt":23,"readmeContent":24,"aiSummary":25,"trendingCount":15,"starSnapshotCount":15,"syncStatus":16,"lastSyncTime":26,"discoverSource":27},3508,"mcp-cli","madeye\u002Fmcp-cli","madeye","a prototype to save fork\u002Fexec overhead of ai code agent","",null,"Rust",118,9,1,0,2,3,"MIT License",false,"main",true,[],"2026-06-12 02:00:51","# mcp-cli\n\nA sidecar-daemon + MCP bridge designed to give CLI\u002FIDE-based AI agents\n(Claude Code, Codex, etc.) deep access to a project's filesystem, git state,\nand source code **without paying the per-call fork\u002Fexec tax** of traditional\nshell-tool wrappers.\n\n## Headline Numbers\n\nSignificant wins across both major agents measured on 2026-04-21 (analysis of `openai\u002Fcodex@rust-v0.122.0`).\n\n### [Codex](bench\u002Fcodex-forkexec\u002Fresults\u002F2026-04-21-rust-v0.122.0-sandbox-ablation.md)\n* **−44 %** Wall-clock (209s → 117s)\n* **−66 %** `execve` calls (64 → 22)\n* **−64 %** Input tokens (1.9M → 0.7M)\n\n### [Claude Code](bench\u002Fclaudecode-forkexec\u002Fresults\u002F2026-04-21-rust-v0.122.0.md)\n* **−5 %** Wall-clock (even on cold pass)\n* **−82 %** `execve` calls (85 → 15)\n* **−14 %** Output tokens\n\n**Warm-cache bonus:** Re-running tasks on a resident daemon saves an additional **650k–950k tokens** per pass via tree-sitter parse and grep result caching.\n\nThere is now a matching Claude Code twin benchmark under\n[`bench\u002Fclaudecode-forkexec\u002F`](.\u002Fbench\u002Fclaudecode-forkexec\u002F): same\ntarget workload, but three passes (`baseline`, `cold mcp-cli`, `warm\nmcp-cli`) so the daemon's cross-session cache payoff is visible too.\nThe Codex run above is still the headline result in the README; the\nClaude Code twin broadens the measurement surface beyond a single\nagent and is the next place to fold into the top-level story.\n\n## Architecture\n\n```\n+---------------------+         stdio (MCP)         +----------------------+\n|  Claude Code \u002F      | \u003C-------------------------> | mcp-cli-bridge       |\n|  Codex \u002F IDE        |                             | (MCP stdio server)   |\n+---------------------+                             +----------+-----------+\n                                                               |\n                                              UDS + length-prefixed JSON-RPC\n                                                               |\n                                                    +----------v-----------+\n                                                    | mcp-cli-daemon       |\n                                                    |  - mmap VFS          |\n                                                    |  - libgit2           |\n                                                    |  - grep-searcher     |\n                                                    |  - (future) tree-    |\n                                                    |    sitter, LSP       |\n                                                    +----------------------+\n```\n\n* **`crates\u002Fprotocol`** - shared JSON-RPC request\u002Fresponse types between bridge\n  and daemon.\n* **`crates\u002Fdaemon`** - long-lived `mcp-cli-daemon` process that owns the\n  project. Listens on a Unix Domain Socket and exposes in-process tools:\n  * `fs.read` - mmap-backed file read (no `read(2)` per call).\n  * `fs.snapshot` \u002F `fs.changes` - incremental sync. The daemon runs an\n    inotify (Linux) \u002F FSEvent (macOS) watcher with a gitignore-aware filter,\n    maintains a monotonic version cursor, and returns coalesced\n    created\u002Fmodified\u002Fremoved events since a client-supplied version. If the\n    client falls too far behind, the response sets `overflowed: true` so the\n    client can re-scan instead of silently missing events.\n  * `git.status` - libgit2 status (no `git` fork\u002Fexec).\n  * `search.grep` - ripgrep's `grep-searcher` library over the project tree.\n* **`crates\u002Fmcp-bridge`** - small `mcp-cli-bridge` stdio binary that the agent\n  spawns. Translates MCP `tools\u002Fcall` requests into UDS calls. Cheap to spawn,\n  but the heavy state stays in the daemon.\n\n## Why this shape\n\nEvery traditional shell-wrapped tool call (`cat`, `git status`, `rg ...`) costs\na `fork` + `exec` + page-table setup + library loading + syscall stream + tear\ndown. For an agent that issues hundreds of small reads per task, that's\ndominated by kernel overhead, not useful work. By keeping a single hot daemon:\n\n* File reads come from an `mmap` already in the page cache - the kernel only\n  pages in on misses; no per-call `read` syscall stream.\n* Git, search, and (planned) parse operations stay in-process, so the kernel\n  sees one long-lived process instead of thousands of short-lived ones.\n* The bridge stays tiny and the per-call cost is a UDS round-trip on a single\n  pre-warmed socket.\n\nThis is the foundation for later layers (incremental inotify diffs, tree-sitter\nindexing, language-specific backends like clangd \u002F rust-analyzer reuse).\n\n## Build\n\n```sh\ncargo build --release\n```\n\nArtifacts under `target\u002Frelease\u002F`: `mcp-cli-daemon`, `mcp-cli-bridge`,\nand the `mcp-cli` installer.\n\n## Install\n\nOne-command registration for the agents the installer knows about:\n\n```sh\n# Claude Code + Codex at once (auto-spawns the daemon on first tool\n# call; no always-on process needed).\ntarget\u002Frelease\u002Fmcp-cli install\n```\n\nFor **codex specifically**, also pass `--prefer-mcp` so codex\nactually routes through the daemon instead of preferring its own\nbuilt-in Bash (this is the configuration the headline numbers were\nmeasured under):\n\n```sh\ntarget\u002Frelease\u002Fmcp-cli install --target codex --prefer-mcp\n```\n\n`--prefer-mcp` writes `[features] shell_tool = false` to\n`~\u002F.codex\u002Fconfig.toml` (so codex stops emitting Bash tool calls for\n`cat` \u002F `rg` \u002F `git` \u002F etc.) and sets per-tool\n`approval_mode = \"approve\"` for every mcp-cli tool (so codex doesn't\nprompt for approval in non-interactive `codex exec`).\n\nWithout `--prefer-mcp`, codex still *mounts* mcp-cli but keeps\nreaching for Bash — see the v1 benchmark writeup for evidence.\n\nThe daemon auto-spawns per project root on the bridge's first\nconnect and idle-exits after 30 min of inactivity; you don't need\nto run anything by hand. To always keep one resident, see\n[`doc\u002Fservices\u002F`](.\u002Fdoc\u002Fservices\u002F).\n\n## Status\n\nSee [`doc\u002FROADMAP.md`](.\u002Fdoc\u002FROADMAP.md) and [`doc\u002FTODO.md`](.\u002Fdoc\u002FTODO.md).\n\n* **Done (M0–M6 + parts of M7)** — Daemon\u002FBridge skeleton, incremental watch sync, tree-sitter indexing (`rust`, `python`, `c`, `cpp`, `ts`, `go`), drop-in `mcp-cli install`, per-cwd auto-spawn, reconnect-on-dead, `mimalloc` + buffer pooling, full M5 performance benchmarks, and `git.log` \u002F `git.diff` RPCs.\n* **In Progress (M7)** — Token-killer compaction (`?compact` on `git.status`, `search.grep`, `fs.scan`; `?strip_noise` on `fs.read`), metrics telemetry, and the generic `tool.run` wrapper.\n* **Open (M8–M10)** — Write-path with optimistic concurrency (`fs.apply_patch`), advanced structural tools (dependency graphs, dynamic folding), and deep git\u002Fprocess management.\n","mcp-cli 是一个旨在减少AI代码代理执行开销的原型项目。它通过一个守护进程和MCP桥接器，使基于CLI\u002FIDE的AI代理（如Claude Code、Codex等）能够深入访问项目的文件系统、Git状态及源代码，而无需为每次调用支付传统的fork\u002Fexec开销。项目采用Rust语言编写，具有显著减少执行时间、系统调用次数以及输入输出令牌数的技术特点。适用于需要频繁与AI代码助手交互以提高开发效率的场景，特别是在大型代码库中进行操作时能大幅节省时间和资源。","2026-06-11 02:54:40","CREATED_QUERY"]