- Home
- MCP servers
- Emacs
Emacs
- other
8
GitHub Stars
other
Language
6 months ago
First Indexed
2 months ago
Catalog Refreshed
Documentation & install
Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.
Installation
Add the following to your MCP client configuration file.
Configuration
View docs{
"mcpServers": {
"mpontus-emacs-mcp": {
"command": "npx",
"args": [
"@modelcontextprotocol/inspector",
"emacs",
"--batch",
"--load",
"'<path to your init file>'",
"--eval",
"'(emacs-mcp-run-stdio)'"
]
}
}
}You can extend Emacs with model context by running a dedicated MCP server inside your Emacs environment. This server exposes information about your Emacs setup to the language model, such as loaded packages, available functions, keybindings, and documentation, enabling you to tailor configurations and author new packages more efficiently.
How to use
You use an MCP client to connect to the Emacs MCP server. Start the server in either of the supported ways and point your MCP client to it. When the server is running, your LLM can query Emacs state, request context about your configuration, and perform actions that modify your setup through the MCP channel. If you are using the Doom Emacs workflow, you can bootstrap the environment so the MCP server shares the same modules and user config as your interactive session.
How to install
Prerequisites: You need Node.js and Emacs installed on your system. You may also want Doom Emacs if you use that workflow.
# Prerequisites
# Install Node.js from your package manager or from nodejs.org
node -v
npm -v
# Ensure Emacs is installed
emacs --version
You can run the MCP server in two equivalent ways. Choose the one you prefer and adapt the path placeholders to your environment.
{ "mcpServers": { "emacs": { "command": "emacs", "args": [ "--batch", "--load", "<path to your init file>", "--eval", "(emacs-mcp-run-stdio)" ] } } }
If you prefer the Doom Emacs workflow, you can bootstrap the environment so the MCP server uses the same modules and user config as your interactive session.
{
"mcpServers": {
"emacs": {
"command": "/.config/emacs/bin/doomscript",
"args": ["/.config/doom/bin/emacs-mcp"]
}
}
}
Test your setup with the inspector tool to verify the MCP server can connect and run in batch mode.
npx @modelcontextprotocol/inspector emacs --batch --load '<path to your init file>' --eval '(emacs-mcp-run-stdio)'
## Additional configuration and tips
If you are using Doom Emacs, you can choose between a direct Emacs invocation or a Doom script wrapper to ensure the same environment is available to the MCP server as in your interactive session. Use the configuration shown to keep the MCP server in sync with your active setup.
## Notes and troubleshooting
- Ensure that the path placeholders in your config are replaced with actual paths to your init file or Doom Emacs scripts. - If you run into environment differences between the MCP server and your interactive session, verify that the same modules and user config are loaded before starting the MCP server. - When testing, confirm that the MCP inspector command completes successfully and returns expected context information.
## Security and usage considerations
Treat the MCP server as a bridge that exposes internal Emacs state to an external model. Limit access to trusted clients, review the information exposed, and avoid sharing sensitive paths or configuration details with untrusted agents.
## Examples
Two explicit ways to start the Emacs MCP server are shown below. Pick the one that matches your workflow. The first runs Emacs in batch mode and starts the MCP server directly. The second uses a Doom script wrapper to align the environment with your interactive session.
## Appendix: MCP server configurations shown in practice
Direct Emacs invocation over npm/yarn proxy (stdio) and inline loader for the MCP server within Emacs.