- Explore MCP Servers
- emacs-mcp
Emacs Mcp
What is Emacs Mcp
Emacs MCP is a package that implements the Model Context Protocol (MCP) for Emacs, allowing large language models (LLMs) to access information about the Emacs environment and configuration.
Use cases
Use cases for Emacs MCP include automating Emacs configuration, creating new Emacs packages, and enhancing the development experience by leveraging LLMs to provide contextual assistance.
How to use
To use Emacs MCP, clone the repository and add the provided code to your Emacs init file. You can test your configuration using the model context protocol inspector command.
Key features
Key features of Emacs MCP include access to loaded packages, available functions, keybindings, and documentation, enabling LLMs to extend Emacs configurations and create new packages without manual context specification.
Where to use
Emacs MCP can be used in software development, particularly in environments where Emacs is utilized for coding, configuration management, and package development.
Overview
What is Emacs Mcp
Emacs MCP is a package that implements the Model Context Protocol (MCP) for Emacs, allowing large language models (LLMs) to access information about the Emacs environment and configuration.
Use cases
Use cases for Emacs MCP include automating Emacs configuration, creating new Emacs packages, and enhancing the development experience by leveraging LLMs to provide contextual assistance.
How to use
To use Emacs MCP, clone the repository and add the provided code to your Emacs init file. You can test your configuration using the model context protocol inspector command.
Key features
Key features of Emacs MCP include access to loaded packages, available functions, keybindings, and documentation, enabling LLMs to extend Emacs configurations and create new packages without manual context specification.
Where to use
Emacs MCP can be used in software development, particularly in environments where Emacs is utilized for coding, configuration management, and package development.
Content
Emacs MCP - Model Context Protocol for Emacs
This package implements the Model Context Protocol (MCP) for Emacs, extending the capabilities of LLMs to access information about Emacs environment and configration. Emacs MCP provides tools with information about loaded packages, available functions, keybindings, documentation, and more. This enables LLMs to be used to extend Emacs configuration and author new packages without requiring user to manually specify contextually relevant files.
Installation
Clone this repository and include the following code in your user init file (e.g., ~/.emacs.d/init.el or equivalent):
(add-to-list 'load-path "/path/to/emacs-mcp") (require 'emacs-mcp)
Test your configuration using model context protocol inspector:
npx @modelcontextprotocol/inspector emacs --batch --load '<path to your init file>' --eval '(emacs-mcp-run-stdio)'
Doom Emacs Configuration
Doom Emacs does not have an init file. To load user configuration before running in batch mode, you need to create a doomscript file which bootstraps doom emacs environment and loads your configuration files.
You can create a file called ~/.config/doom/bin/emacs-mcp
with the following content:
#!/usr/bin/env doomscript (defcli! emacs-mcp () (doom-modules-initialize) ; initialize the module system (doom-initialize t) ; bootstrap Doom as if this were an interactive session (doom-startup) ; load your modules and user config (emacs-mcp-run-stdio)) ; run the MCP server (run! "emacs-mcp")
This will ensure that the emacs instance running MCP server will access the same environment and modules as your interactive Doom Emacs instance.
You can then test your configuration using the following command:
npx @modelcontextprotocol/inspector ~/.config/emacs/bin/doomscript ~/.config/doom/bin/emacs-mcp
Usage
Configure MCP server for your LLM client, by changing the mcp.json
file as prescribed by your LLM client’s documentation, such as Claude Code or Amazon Q Developer CLI.
{
"mcpServers": {
"emacs": {
"command": "emacs",
"args": [
"--batch",
"--load",
"<path to your init file>",
"--eval",
"(emacs-mcp-run-stdio)"
]
}
}
}
Or if you are using Doom Emacs, you can use the following configuration:
{
"mcpServers": {
"emacs": {
"command": "~/.config/emacs/bin/doomscript",
"args": [
"~/.config/doom/bin/emacs-mcp"
]
}
}
}
License
MIT