Skip to main content
Run your FrontMCP server over a Unix domain socket for local-only, persistent access — ideal for Claude Code integrations, background daemons, and local AI agents.
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)

The frontmcp socket command starts a FrontMCP server listening on a Unix socket file.

CLI Flags

When no --socket path is given, the CLI automatically creates the socket at ~/.frontmcp/sockets/{app-name}.sock, where {app-name} is derived from the parent directory of your entry file.

Programmatic API

Use FrontMcpInstance.runUnixSocket() for full control from your own code.
The method signature:
The full HTTP feature set — streamable HTTP, SSE, elicitation, sessions — works unchanged over Unix sockets. The only difference is the transport layer: a .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


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 mode 0o660 (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 for SIGINT and SIGTERM. On either signal:
  1. The socket file is removed
  2. The PID file (if running via CLI) is cleaned up
  3. 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

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.
Let the CLI pick the default path (~/.frontmcp/sockets/) unless you have a specific reason to override. This keeps sockets organized and discoverable.
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.
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:
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.

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