Emacs MCP

v1.0.0Developer Toolsstable

A Model Context Protocol server that enables generating and executing Elisp code in a running Emacs process, allowing AI assistants to control and interact with Emacs.

emacs-mcp-servermcpai-integration
Share:
36
Stars
0
Downloads
0
Weekly
0/5

What is Emacs MCP?

Emacs MCP is a Model Context Protocol (MCP) server that allows AI assistants like Claude, Cursor, and VS Code to model context protocol server that enables generating and executing elisp code in a running emacs process, allowing ai assistants to control and interact with emacs.

A Model Context Protocol server that enables generating and executing Elisp code in a running Emacs process, allowing AI assistants to control and interact with Emacs.

This server falls under the Developer Tools and File Systems categories on MCPgee, the world's largest MCP server directory with 33,000+ servers.

Features

  • A Model Context Protocol server that enables generating and

Use Cases

Generate and execute Elisp code in running Emacs processes.
Control Emacs editor functionality from AI assistants.
Interact with Emacs buffers and perform editor operations via MCP.
vivekhaldar

Maintainer

LicenseMIT
Languagepython
Versionv1.0.0
UpdatedFeb 4, 2026
Statushealthy
Maintenanceactive

Works with

ClaudeOpenAIwindowsmacoslinux

Installation

Manual Installation

npx emacs-mcp-server

Configuration

Configuration Details

Config File

claude_desktop_config.json

Performance

Response Metrics

Response Time< 200ms
ThroughputMedium

Resource Usage

Memory UsageLow
CPU UsageLow

How to Set Up and Use Emacs MCP

Emacs MCP Server is a Python-based MCP server that connects AI assistants to a running Emacs editor process by generating and executing Emacs Lisp (Elisp) code via emacsclient. It exposes two tools: one that generates Elisp code for a given task, and one that evaluates that code inside the live Emacs process. Emacs power users and developers use it to control Emacs through natural language — manipulating buffers, running commands, configuring packages, or automating repetitive editor operations — without writing Elisp manually.

Prerequisites

  • Emacs installed with the emacsclient binary available (Emacs 26+ recommended)
  • Emacs server mode enabled in your Emacs session (add '(server-start)' to your init.el, or run M-x server-start)
  • Python 3.10 or higher and uv package manager installed
  • An OpenAI API key (the server uses OpenAI for Elisp code generation)
  • An MCP client such as Claude Desktop
1

Clone the repository and install dependencies

Download the server and use uv to install all Python dependencies into a local virtual environment.

git clone https://github.com/vivekhaldar/emacs-mcp-server.git
cd emacs-mcp-server
uv sync
2

Enable Emacs server mode

The MCP server communicates with Emacs via emacsclient, which requires Emacs to be running in server mode. Add this line to your Emacs init.el (or run M-x server-start each session).

;; In your ~/.emacs or ~/.emacs.d/init.el
(server-start)
3

Find the paths to uv and emacsclient

Note the full absolute paths to both binaries — they are required in the Claude Desktop config.

which uv
which emacsclient
4

Configure Claude Desktop

Edit claude_desktop_config.json and add the Emacs MCP Server entry. Use absolute paths for uv, the server script, and emacsclient. The OPENAI_API_KEY is used by the server to generate Elisp code.

{
  "mcpServers": {
    "Emacs-MCP-Server": {
      "command": "/Users/yourname/.local/bin/uv",
      "args": [
        "run",
        "--with", "mcp[cli]",
        "--with", "smartfunc",
        "mcp",
        "run",
        "/Users/yourname/repos/emacs-mcp-server/emacs_mcp_server.py"
      ],
      "env": {
        "OPENAI_API_KEY": "sk-your-openai-key",
        "EMACSCLIENT": "/usr/local/bin/emacsclient"
      }
    }
  }
}
5

Restart Claude Desktop

Save the config, ensure Emacs is running with server mode active, and restart Claude Desktop. The generate_emacs_lisp_code and execute_emacs_lisp_code tools will be available.

Emacs MCP Examples

Client configuration

Full claude_desktop_config.json entry for Emacs MCP Server with uv and emacsclient paths.

{
  "mcpServers": {
    "Emacs-MCP-Server": {
      "command": "/Users/haldar/.local/bin/uv",
      "args": [
        "run",
        "--with", "mcp[cli]",
        "--with", "smartfunc",
        "mcp",
        "run",
        "/Users/haldar/repos/emacs-mcp-server/emacs_mcp_server.py"
      ],
      "env": {
        "OPENAI_API_KEY": "sk-your-openai-key-here",
        "EMACSCLIENT": "/usr/local/bin/emacsclient"
      }
    }
  }
}

Prompts to try

Natural language commands you can give Claude to control your Emacs instance.

- "Open the file ~/projects/main.py in Emacs."
- "In Emacs, go to line 42 in the current buffer."
- "Install the magit package in Emacs using package-install."
- "Show me a list of all currently open Emacs buffers."
- "In Emacs, run M-x org-agenda to open the agenda view."
- "Replace all occurrences of 'foo' with 'bar' in the current Emacs buffer."

Troubleshooting Emacs MCP

'Connection refused' or 'No such server' error from emacsclient

Emacs server mode is not running. In Emacs, run M-x server-start, or add (server-start) to your init.el and restart Emacs. Also verify the EMACSCLIENT path in the config points to the correct binary (run 'which emacsclient' to confirm).

Elisp execution returns unexpected results or errors

The generate_emacs_lisp_code tool uses OpenAI to write Elisp, which may produce incorrect code for unusual requests. Review the generated Elisp before allowing execution on critical buffers. For sensitive operations, ask Claude to show you the Elisp first before executing.

Server fails to start: 'module not found' or import errors

Run 'uv sync' in the repo directory to ensure all dependencies are installed. The config must use the same uv binary that has access to the project's virtual environment. Use the absolute path from 'which uv' in the command field.

Frequently Asked Questions about Emacs MCP

What is Emacs MCP?

Emacs MCP is a Model Context Protocol (MCP) server that model context protocol server that enables generating and executing elisp code in a running emacs process, allowing ai assistants to control and interact with emacs. It connects AI assistants to external tools and data sources through a standardized interface.

How do I install Emacs MCP?

Follow the installation instructions on the Emacs MCP GitHub repository. Clone the repo, install dependencies, and add the server config to your AI client.

Which AI clients work with Emacs MCP?

Emacs MCP works with all major MCP-compatible AI clients including Claude Desktop, Claude Code, Cursor, VS Code (GitHub Copilot), Windsurf, and Cline.

Is Emacs MCP free to use?

Yes, Emacs MCP is open source and available under the MIT license. You can use it freely in both personal and commercial projects.

Browse More Developer Tools MCP Servers

Explore all developer tools servers available in the MCPgee directory. Each server includes setup guides for Claude, Cursor, and VS Code.

Quick Config Preview

{ "mcpServers": { "emacs-mcp-server": { "command": "npx", "args": ["-y", "emacs-mcp-server"] } } }

Add this to your claude_desktop_config.json or .cursor/mcp.json

Read the full setup guide →

Ready to use Emacs MCP?

Browse our complete directory of 33,000+ MCP servers, read setup guides for your editor, and start building with the Model Context Protocol.

33,000+ ServersFree & Open SourceStep-by-Step Guides