#pranali
Pranali (प्रणाली) is Sanskrit for "channel, conduit": the channel every agent's stream runs through to reach a tool's daemon.
One tiny stdio pipe from any AI agent's MCP client to a tool's long-running daemon. An agent (Claude Code, Codex, Gemini CLI, anything that speaks MCP over stdio) runs pranali narada; pranali joins its stdin and stdout to narada's daemon at $XDG_RUNTIME_DIR/narada/mcp.sock, and keeps the agent's session alive across the daemon's restarts.
It replaces four per-tool pipes that did the same job (narada's, darshan's, sutradhar's and ekatva's) with one implementation, one hello and one reconnect state machine. Rust, standard library only: a ~400 KB binary that sits at about 170 KB of its own memory and never wakes up while idle.
#Install
From kosha:
kosha install pranali
Or from source (Rust 1.88 or newer):
make install # builds and installs to ~/.local/bin/pranali
make install PREFIX=/usr/local
#Use it in an agent
Point the agent's MCP server at pranali instead of the tool:
# Codex: ~/.codex/config.toml
[mcp_servers.narada]
command = "pranali"
args = ["narada"]
Claude Code (.mcp.json or ~/.claude.json):
{ "mcpServers": { "narada": { "command": "pranali", "args": ["narada"] } } }
pranali <tool> [--agent NAME] [--fallback CMD ARGS...]
<tool>: the tool's name,[a-z][a-z0-9-]{0,31}.--agent NAME: the agent's label for the daemon (default$PRANALI_AGENT, elseagent).--fallback CMD ...: the rest of the arguments; run in pranali's place when no daemon can be reached at startup (only then). A tool's own<tool> mcpuses it:pranali narada --fallback narada mcp --in-process. Without it, pranali saysno daemon at <path> (systemctl --user start <tool>-mcp.socket)and exits 1.
The socket is $PRANALI_SOCKET if set, else $XDG_RUNTIME_DIR/<tool>/mcp.sock, else ${XDG_STATE_HOME:-~/.local/state}/<tool>/run/mcp.sock. A daemon run with a state directory of its own (darshan's DARSHAN_HOME, say) is reached by setting PRANALI_SOCKET in the agent's MCP config env. pranali refuses a socket whose directory isn't yours alone (a real directory owned by you, mode 0700: never a shared /tmp), and paths over 107 bytes.
#How it works
The full contract, daemon side included, is docs/PROTOCOL.md. In short:
- Hello. pranali sends one JSON line before MCP: who it is and where the agent runs (
tool,agent,pid,cwd, andTMUX,TMUX_PANE,DISPLAY,WAYLAND_DISPLAY,XAUTHORITY,PATHwhen set), so the daemon can name the agent in its log, open approval popups in the agent's terminal and run commands with itsPATH. The daemon answers{"pranali":1,"ok":true}(orok:falseand why). Then the connection is plain MCP, one JSON-RPC message per line. - Restarts. systemd owns the socket (
<tool>-mcp.socket), so during a restart connections wait in its backlog. If the daemon goes away anyway, every call it had gets an error saying it may or may not have happened (code-32001); pranali reconnects (100 ms doubling to 2 s, rounds of 60 s), replays the agent'sinitializeunder its own id, waits for its answer (and swallows it), replaysinitialized, and only then sends what queued up meanwhile. The agent never re-initializes. Calls that only queued and never reached a daemon get-32002("not run, retry it") instead. A daemon that accepts and closes, or that crashes right after the handshake, can't make it spin: the backoff only resets once a reconnected session has stayed up for 10 s. - Endings. pranali exits only when the agent closes stdin: it half-closes the socket and still copies the daemon's last answers for up to 5 s. A closed stdout ends it quietly.
#Numbers
Measured on the release build against the test suite's fake daemon (cargo test --release -- --ignored --nocapture measure):
| binary | 410 KB, stripped, std only |
| idle memory | Rss 2.4 MB (mostly shared libc), Pss_Anon 172 KB |
| idle wakeups | 0 over 10 s (every thread blocked in a read) |
start to first initialize answer | 5.0 ms median of 20 |
#Develop
make check # cargo fmt --check, clippy -D warnings, all tests
make build # target/release/pranali
python3 scripts/build-site.py # the website in docs/, after README or CHANGELOG changes
The tests run pranali against a fake daemon in their own directories under target/tmp (via PRANALI_SOCKET): hello, refusals, two pipes at once, a daemon killed mid-call, accept-then-close, a failed round, the stdin drain, the fallback, the directory check, megabyte lines, string and number ids. PRANALI_ROUND_MS and PRANALI_DRAIN_MS shorten the 60 s round and the 5 s drain for them; nothing else should set them.