Unix socket mode is best suited for:
- Local-only servers that don’t need network exposure
- Claude Code / Claude Desktop integration via
socketPath - Background daemons that persist across sessions
- Avoiding TCP port conflicts on developer machines
Quick Start (CLI)
Thefrontmcp socket command starts a FrontMCP server listening on a Unix socket file.
CLI Flags
| Flag | Alias | Description |
|---|---|---|
--socket <path> | -s | Custom socket file path. Defaults to ~/.frontmcp/sockets/{app-name}.sock |
--db <path> | SQLite database path for persistent sessions and events | |
--background | -b | Detach and run as a background daemon |
Programmatic API
UseFrontMcpInstance.runUnixSocket() for full control from your own code.
.sock file instead of a TCP port.
SQLite Storage
By default, Unix socket mode uses in-memory storage for sessions and events. For persistence across server restarts, configure SQLite.Basic Configuration
With Encryption
Enable at-rest encryption for stored values using AES-256-GCM:SQLite Options
| Option | Type | Default | Description |
|---|---|---|---|
path | string | required | Path to the .sqlite database file |
encryption.secret | string | — | Secret key for AES-256-GCM encryption via HKDF-SHA256 |
walMode | boolean | true | Enable WAL mode for better read concurrency |
ttlCleanupIntervalMs | number | 60000 | Interval in ms for purging expired keys |
Connecting to the Socket
curl
Node.js (node:http)
Claude Desktop / Claude Code
Point your MCP client config at the socket file:Socket Lifecycle
Permissions
When the server starts listening, the socket file is set to permission mode0o660 (owner and group read/write). This prevents other users on the machine from connecting.
Stale Socket Cleanup
If a.sock file already exists when the server starts (e.g., from a previous crash), it is automatically removed before binding. This avoids EADDRINUSE errors.
Graceful Shutdown
The server registers handlers forSIGINT and SIGTERM. On either signal:
- The socket file is removed
- The PID file (if running via CLI) is cleaned up
- The process exits cleanly
PID File (CLI Background Mode)
When launched with--background, the CLI writes a PID file at {socketPath}.pid so you can manage the daemon:
Best Practices
Watch macOS path length limits
Watch macOS path length limits
macOS limits Unix socket paths to 104 bytes. Keep your socket paths short. The default location
~/.frontmcp/sockets/{app}.sock is designed to stay within this limit.Use the default socket directory
Use the default socket directory
Let the CLI pick the default path (
~/.frontmcp/sockets/) unless you have a specific reason to override. This keeps sockets organized and discoverable.Prefer Unix sockets over localhost TCP for local-only servers
Prefer Unix sockets over localhost TCP for local-only servers
Unix sockets provide natural access control via file permissions — no firewall rules needed. They also avoid port conflicts and have slightly lower latency than loopback TCP.
Clean up on crash
Clean up on crash
The stale socket cleanup handles normal cases, but if your process is killed with
SIGKILL (kill -9), the socket file may linger. Use the CLI’s built-in cleanup or manually remove the file before restarting:Use SQLite for persistence
Use SQLite for persistence
Without SQLite, all session data lives in memory and is lost on restart. If your use case requires sessions to survive restarts (e.g., a background daemon), enable SQLite storage with the
--db flag or the sqlite config option.Related Documentation
Runtime Modes
Compare SDK, Server, and Handler deployment modes
DirectClient
Programmatic in-process access without any transport
Redis Setup
Configure Redis for distributed session storage
Production Build
Build and optimize for production deployment