feat(mcp): add fj mcp service install/uninstall for systemd user unit #62
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/FJCLI-48-mcp-service-systemd"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Add a
Servicesubcommand tofj mcpthat manages the MCP HTTP server as a per-user systemd unit (~/.config/systemd/user/fj-mcp.service), so a user can stand up (or tear down) an always-on Forgejo MCP endpoint with one command instead of hand-writing a unit and wiring env vars.installresolves the host (global--host, thenFORGEJO_HOST, then the built-in default), the bind address (--http-addr, default127.0.0.1:8080), the write policy (--allow-edit/--allow-delete/--allow-global-write, baked intoExecStart), and the bearer token. When--http-tokenis omitted a 256-bit CSPRNG token is generated and printed once to stderr; supplied verbatim otherwise and never echoed. The token is written to~/.config/fj/mcp.env(mode 0600, parent dir 0700) and pulled into the unit viaEnvironmentFile=%h/.config/fj/mcp.envso the secret never lands in the world-readable unit file.ExecStartpoints at the absolute path of the runningfjbinary (current_exe). Without--no-startit runsdaemon-reloadthenenable --now;--no-startwrites the unit and reloads only.uninstalldisables+stops the unit (idempotent when absent), removes the unit file, and reloads the daemon;mcp.envis left in place unless--purgeis passed.systemctlnon-zero exits (outside the idempotent uninstall case) surface the captured stderr.The systemd/unit logic lives entirely in the binary crate;
fj-coreandfj-mcpgain no systemd dependency, preserving the MCP-reuse contract. systemd user services are Linux-only, soinstall/uninstallreturn a clear error on other targets (the pure helpers stay platform-agnostic and unit-tested). README documents the commands, the token file location, and theloginctl enable-lingerhint.#FJCLI-48
fj mcp service install/uninstallfor systemd user unit