elisp-dev-mcp is an Emacs package that provides an MCP (Machine Code Protocol) server designed to support LLM-based agentic Elisp development. It enables AI agents to interact with Emacs and manipulate Elisp code through a structured API, thereby assisting with Elisp coding tasks. The package relies on the MCP infrastructure provided by mcp-server-lib.el.
Installation and Configuration
Users can install it from MELPA or MELPA Stable:
M-x package-install RET elisp-dev-mcp RET
After installation, ensure that mcp-server-lib is correctly installed (including running M-x mcp-server-lib-install), then register elisp-dev-mcp with the MCP client. Before using the MCP server, it must be started in Emacs via M-x mcp-server-lib-start , and once done, M-x mcp-server-lib-stop can be used to stop it.
Main Capabilities (MCP Handlers)
1. Elisp Function Documentation
- Name:
elisp-describe-function - Description: Retrieves the complete documentation of an Emacs Lisp function.
- Parameters:
function(string): the name of the function to describe. - Returns:
description(string): the function documentation; orerror(string): the error message on failure.
2. Elisp Function Definition
- Name:
elisp-get-function-definition - Description: Retrieves the source code definition of an Emacs Lisp function.
- Parameters:
function(string): the name of the function to retrieve. - Returns:
- For Elisp functions:
source(string, source code including header comments),file-path(string, path of the file where it is defined),start-line(integer, starting line number of the definition, including header comments, 1-based),end-line(integer, ending line number of the definition, 1-based). - For functions implemented in C:
is-c-function(boolean, always true),function-name(string),message(string, indicating that the function is implemented in C source code).
- For Elisp functions:
3. Elisp Variable Description
- Name:
elisp-describe-variable - Description: Retrieves information about an Emacs Lisp variable without exposing its value.
- Parameters:
variable(string): the name of the variable to describe. - Returns: includes
name(variable name),bound(whether it is bound),value-type(value type, such as "cons", "string", "integer"),documentation(documentation or null),source-file(path of the defining file),is-custom(whether it is customizable),custom-group(customization group, only for customizable variables),custom-type(customization type specification, only for customizable variables),is-obsolete(whether obsolete),obsolete-since(obsolete version, only present for obsolete variables),obsolete-replacement(suggested replacement, only present for obsolete variables),is-alias(whether it is an alias),alias-target(alias target, only present for aliases),is-special(whether it is a special dynamically scoped variable); orerror(error message).
4. Elisp Info documentation lookup
- Name:
elisp-info-lookup-symbol - Description: Looks up an Elisp symbol in Info documentation and returns the complete documentation node.
- Parameters:
symbol(string): the Elisp symbol to look up. - Returns:
found(boolean, whether found),symbol(the symbol looked up),node(name of the Info node containing the documentation, when found),manual(Info manual name, usually 'elisp', when found),content(complete Info node content, including examples, cross-references, etc., when found),info-ref(reference such as '(elisp)Node Name', when found),message(error or not-found information, when not found).
5. Elisp source file reading
- Name:
elisp-read-source-file - Description: Reads an Elisp source file from the Emacs system directories or ELPA packages. Accepts a library name or an absolute file path.
- Parameters:
library-or-path(string): library name (such as "subr", "org") or the absolute path of a .el file. - Returns: the complete file content string; or
error(error message, such as library not found, file not found, invalid format, or access denied). - Input modes:
- Library name (recommended for built-in and installed packages): a simple name without path separators, such as "subr", "files", "org", resolved via Emacs's
locate-libraryfunction inload-path. - Absolute path (compatible with other elisp-dev tools): a full path ending in .el, which can be returned by
elisp-get-function-definition.
- Library name (recommended for built-in and installed packages): a simple name without path separators, such as "subr", "files", "org", resolved via Emacs's
- Security restrictions: reads only from the Emacs system lisp directories and ELPA directories; rejects paths containing
..traversal; resolves symbolic links to prevent escaping the allowed directories; library names must resolve to a path within the allowed directories. - Features: transparently handles .el.gz compressed files; works with built-in Emacs libraries and installed packages; returns the complete file content string.
Configuration for alternative package managers
By default,elisp-read-source-file can only access the Emacs system directories and standard ELPA packages. For users using straight.el, elpaca, or custom package setups, additional allowed directories can be configured. Security note: only add trusted directories, as this allows the MCP server to read any .el file in those locations.
Use cases and limitations
This tool is suitable for Elisp development using LLMs, helping AI agents obtain function documentation, source code, variable information, Info documentation, and source file contents, thereby assisting with coding tasks. Limitations include: source file reading is subject to directory security restrictions; variable descriptions do not expose values; the MCP server and client registration must be correctly installed and started.
License
This project is licensed under the GNU General Public License v3.0 (GPLv3); see the LICENSE file for details.