Conversation
Add `alacritree mcp`, a stdio Model Context Protocol server that bridges tool calls to the running app over a new IPC socket, so agents can browse projects/worktrees, open shells, type into terminals, read screens, and inspect git state. The socket mirrors alacritty's polling/ipc.rs design: unix-only, one newline-delimited JSON request per connection, bound at $XDG_RUNTIME_DIR/alacritree/alacritree-<pid>.sock and advertised to child PTYs via ALACRITREE_SOCKET — an agent running inside a session targets the instance hosting it. Requests touching app state hop to the UI thread through an mpsc channel drained once per frame (woken by request_repaint); git-status walks and worktree creation run on the connection thread so they never stall a frame. Tools: list_projects, list_sessions, select_workspace, create_session, close_session, send_text, read_screen, git_status, create_worktree, refresh_project. Worktree deletion is deliberately not exposed. The MCP side is hand-rolled newline-delimited JSON-RPC (tools only) to keep the crate synchronous instead of pulling in an SDK plus tokio. `[general] ipc_socket = false` disables the socket, matching alacritty's option of the same name. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
alacritree mcp— a stdio Model Context Protocol server that bridges tool calls to the running app, so LLM agents can browse projects/worktrees, open shells in them, type into terminals, read their output, and inspect git state.How
Two pieces, mirroring upstream alacritty's IPC design (
polling/ipc.rs):ipc.rs— the app listens on a unix socket at$XDG_RUNTIME_DIR/alacritree/alacritree-<pid>.sock, advertised to child PTYs viaALACRITREE_SOCKET(same trick asALACRITTY_SOCKET), so an agent running inside an alacritree session automatically targets the instance hosting it. One newline-delimited JSON request per connection with an{"ok"}/{"error"}reply. Requests touching app state hop to the UI thread over an mpsc channel drained once per frame (woken byrequest_repaint, per theEventProxycontract); slow operations (git-status walks, worktree creation with itsgit fetch) run on the connection thread so they never stall a frame.mcp.rs— hand-rolled newline-delimited JSON-RPC (tools only), no SDK/tokio so the crate stays fully synchronous. Tool names + arguments map 1:1 ontoIpcRequestserde tags. Socket discovery: env var → runtime-dir scan,--socket <path>to override.Tools
list_projectslist_sessionsselect_workspacecreate_session/close_sessionsend_text\rsubmits)read_screengit_statuscreate_worktree+button (fetch, branch, LLM-config copy)refresh_projectWorktree deletion is deliberately not exposed — destructive, and the UI gates it behind a confirm dialog for good reason.
Config / platform
[general] ipc_socket = falsedisables the socket — same option name and location as alacritty's.alacritree mcpfails fast with a clear message and the app simply doesn't bind a socket.Testing
Verified end-to-end against the live app on sway: registered the bridge, listed real projects/sessions, spawned a session, sent
echo hello-from-mcp $((6*7))\r, readhello-from-mcp 42back viaread_screen, pulledgit_status(correctly reported this branch's own then-uncommitted files), exercised the unknown-worktree error path, and closed the session. Protocol edge cases (unknown tool →-32602, unknown method →-32601, notifications unanswered,ping) covered against a mock socket.cargo fmt+cargo checkclean.🤖 Generated with Claude Code