sigildocs

(sigil nrepl client)

(sigil nrepl client) - nREPL client for connecting to running Sigil apps

A reusable nREPL client that can connect to a Sigil nREPL server over TCP. Used by MCP dev tools and editor plugins.

Wire protocol matches the server in (sigil nrepl): Send/Receive: 4-byte big-endian length + UTF-8 S-expression

Example:

(import (sigil nrepl client))

(define conn (nrepl-connect "127.0.0.1" 7888))
(nrepl-eval conn "(+ 1 2)")  ; => ((status . ok) (value . "3"))
(nrepl-disconnect conn)

Exports

nrepl-connectprocedure

Connect to an nREPL server.

Returns a connection object on success, or #f on failure.

Example:

(nrepl-connect "127.0.0.1" 7888)

Disconnect from an nREPL server.

Check if a connection is still active.

nrepl-sendprocedure

Send a raw request and receive a response.

Takes a request S-expression and returns the parsed response, or #f if the connection failed.

nrepl-evalprocedure

Evaluate code in the nREPL server.

Returns a parsed response alist with status, value, message, and module fields, or #f if the connection failed.

Example:

(nrepl-eval conn "(+ 1 2)")
;; => ((status . ok) (value . "3") (message . #f) (module . "(sigil user)"))

Switch the nREPL session to a different module.

Example:

(nrepl-switch-module conn "(sigil web demo views)")

Get completions for a prefix.

nrepl-docprocedure

Get documentation for a symbol.

nrepl-modulesprocedure

List available modules.

Register a connection under a name (symbol).

If a connection with the same name already exists, it is replaced.

(nrepl-register! 'mcp conn)
nrepl-lookupprocedure

Look up a registered connection by name.

Returns the connection or #f if not found.

(nrepl-lookup 'mcp)  ; => connection or #f

Unregister a named connection.