Get the FREE Ultimate OpenClaw Setup Guide →

claude-code-emacs

This package provides seamless integration with Claude Code, allowing you to run AI-powered coding sessions directly in your Emacs environment.

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio yuya373-claude-code-emacs claude-code-mcp

How to use

Claude Code Emacs integrates Claude Code into your Emacs workflow via MCP. The server exposes an MCP interface that lets Emacs communicate with Claude Code for buffer operations, LSP diagnostics, diffs, and real-time events. With the provided MCP setup, Emacs can start a session, send prompts, read diagnostics, and apply actions within a per-project context. The workflow centers on launching the MCP server (claude-code-mcp) and connecting Emacs through the stdio MCP channel, enabling seamless command and control from within your editor.

How to install

Prerequisites:

  • Node.js 16+ (for MCP)
  • npm (or any Node.js package manager)
  • Optional: Emacs 28.1+ with required packages (projectile, vterm, transient, markdown-mode)

Installation steps:

  1. Install the MCP server globally: npm install -g claude-code-mcp-server

  2. Configure Claude Code to use MCP (Emacs side): claude mcp add-json emacs '{ "type": "stdio", "command": "claude-code-mcp" }'

  3. Start a Claude Code MCP session from Emacs (via M-x claude-code-run) or use the provided transient menu to initiate chats and commands. If you prefer to run without installation, you can also use NPX: claude mcp add-json emacs '{ "type": "stdio", "command": "npx", "args": ["claude-code-mcp-server"] }'

  4. Optional: Build from source and point the MCP config to the built index.js as described in the MCP setup docs.

Note: The MCP server communicates over stdio; ensure the command configured matches the installation method you choose (global npm install, npx, or built from source).

Additional notes

Tips:

  • The server provides per-project WebSocket connections and automatic reconnection logic for robustness.
  • Ensure Node.js is available in your environment if using the Node-based MCP server. If you run into WebSocket-related issues, verify optional dependencies like lsp-mode and websocket are installed as needed.
  • The Emacs integration expects the Claude Code CLI to be installed (or accessible via NPX) for full functionality.
  • When updating versions, follow the release notes to adjust MCP configuration as necessary (e.g., path changes or new flags).
  • If you encounter environment variable needs, common ones include paths to the Claude Code CLI, project root, and per-project prompt files.

Related MCP Servers

Sponsor this space

Reach thousands of developers