Get the FREE Ultimate OpenClaw Setup Guide →

emacs

Interact with Emacs in Claude/etc via MCP

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio keegancsmith-emacs-mcp-server npx -y @keegancsmith/emacs-mcp-server

How to use

This MCP server enables an LLM to interact with a running Emacs instance by sending Emacs Lisp expressions and querying Emacs state through three tools: emacs_eval, emacs_get_visible_text, and emacs_get_context. The server uses emacsclient --eval to execute Lisp in the current Emacs session, operating in the context of the currently visible buffer in the active window. You can ask the model to evaluate Lisp expressions, retrieve the visible portion of the buffer, or obtain contextual information about the current buffer (such as the file, mode, and point position). The tools are designed to let you query buffers, modes, variables, and perform Emacs commands while keeping the scope focused to the active window and buffer for safety and relevance.

To use it with Claude for Desktop (or other MCP-enabled clients), configure your MCP server entry to point to the npm package via npx, then start Emacs with the Emacs server running (M-x server-start). From there, you can request operations like listing buffers, retrieving the visible text, or getting the current context, and the model will return results based on Emacs state. Example prompts include: asking for the list of buffers, requesting the text currently visible in the window, or querying the current editing file and buffer context. The tools map to Lisp expressions or Emacs queries that the server translates into emacsclient calls.

How to install

Prerequisites:\n- Node.js and npm (or npx) installed on your system.\n- Emacs installed with a running Emacs server (start it via M-x server-start in Emacs).\n\nInstallation steps:\n1) Install Node.js and npm if not already installed.\n2) No explicit installation is required for the server if you plan to use npx (the package will be fetched on first run).\n3) Run the MCP server using the provided configuration (see mcp_config). For example, you can start the server entry that uses npx to fetch the package:\n\n```bash\n# Ensure Node.js and npm are installed\n# Then start the MCP server as configured (the host tool will invoke npx as needed)\n``\n4) Ensure Emacs is running a server (M-x server-start) so emacsclient --eval can reach Emacs.\n5) In your MCP client (e.g., Claude for Desktop), configure the server entry to use the provided mcpServers configuration.\n\nNotes:\n- The first run will fetch the package from npm. Ensure you have network access and npm permissions.\n- If you prefer a direct install, you can run the package via npm or npx outside of MCP to verify compatibility before wiring it into your MCP workflow.

Additional notes

Security: This MCP server can evaluate arbitrary Emacs Lisp in the running Emacs instance, which can affect files and system state. Use with trusted LLM providers and restrict access to the MCP endpoint. Environment variables are not strictly required, but you may expose EMACS_SERVER and related settings if you want to point to a specific Emacs server or port. If emacsclient fails, verify that Emacs is running a server (M-x server-start) and that there are no firewall rules preventing client connections. If buffers or context queries return empty results, ensure the correct window is focused in Emacs and that the Emacs server has permission to access the current session.

Related MCP Servers

Sponsor this space

Reach thousands of developers