Get the FREE Ultimate OpenClaw Setup Guide →

emacs

Pure ELISP MCP server for Emacs

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio rhblind-emacs-mcp-server socat - UNIX-CONNECT:~/.config/emacs/.local/cache/emacs-mcp-server.sock

How to use

This MCP server exposes Emacs functionality to an LLM, allowing you to read and manipulate buffers, execute Emacs Lisp, navigate files, and run Emacs commands from an external agent like Claude. Once the server is running, you connect to the Unix socket it creates and interact through tools such as eval-elisp to safely evaluate Elisp expressions, and get-diagnostics to fetch Flycheck/Flymake diagnostics across project buffers. The available tools enable you to query buffer contents, modify text, run M-x commands programmatically, inspect and adjust Emacs variables, and obtain information about window layouts and major modes. Claude can be configured with a local mcp wrapper (Python or shell) to call into the socket, or you can directly use socat to bridge to the socket as shown in the Quick Start.

To operate, ensure the client sends properly structured tool calls to the server. For example, eval-elisp calls will evaluate Elisp expressions within Emacs with safeguards, while get-diagnostics will aggregate syntax and linting messages per file. The server respects a permission model and input validation to limit sensitive operations, but the eval-elisp tool remains powerful and should be used with caution. The combination of tools provides a robust bridge between a language model and your Emacs session, enabling complex, automated editor tasks from the LLM.

How to install

Prerequisites:

  • Emacs 27.1 or newer
  • socat installed on the host system
  • Access to your Emacs configuration directory

Installation steps:

  1. Clone or download the MCP server package into your Emacs configuration directory, e.g. ~/.config/emacs-mcp-server/
  2. Ensure the mcp-server Elisp and any helper scripts are present (as documented in the repo). You will typically load the server from your init file or via the recommended package manager blocks.
  3. Start the MCP server which creates a Unix socket for Claude to connect to. For the Quick Start example, run the provided startup hook in Emacs to initialize the Unix socket:
(add-hook 'emacs-startup-hook #'mcp-server-start-unix)
  1. Verify the socket path: ~/.config/emacs/.local/cache/emacs-mcp-server.sock. If needed, adjust your socket naming or directory in your init configuration.
  2. Configure your Claude integration to connect via socat to the Unix socket as shown in the Quick Start section. For example:
{
  "mcpServers": {
    "emacs": {
      "command": "socat",
      "args": ["-", "UNIX-CONNECT:~/.config/emacs/.local/cache/emacs-mcp-server.sock"],
      "transport": "stdio"
    }
  }
}
  1. Install any required dependencies for your chosen wrapper (Python or Bash) to call the mcp server, such as the mcp-wrapper.py or mcp-wrapper.sh scripts if you plan to use Claude mcp tooling.

Additional notes

Tips and considerations:

  • The server uses a permission/security model to protect your Emacs environment. The eval-elisp tool enables arbitrary Elisp evaluation and should be used with extreme caution, ideally gated behind explicit prompts and user approvals where possible.
  • If you enable get-diagnostics, results are grouped by file and show counts per severity; this can help the LLM decide which files to inspect or edit.
  • Socket naming and directories can be customized via Emacs Lisp configuration (e.g., mcp-server-socket-name and mcp-server-socket-directory) if you run multiple sessions or need a distinct socket per user.
  • Ensure socat is installed and accessible in your PATH on the host that runs the client.
  • Network security: this setup communicates over a local Unix socket. For remote access, consider additional access controls or tunneling while preserving the MCP security model.
  • If you encounter issues starting the server, check Emacs startup hooks and ensure the path to the socket directory exists and is writable by the Emacs process.

Related MCP Servers

Sponsor this space

Reach thousands of developers