Skip to main content
Glama

execute_emacs_lisp_code

Send Emacs Lisp code to the Emacs process for execution and retrieve results, enabling AI assistants to control and interact with Emacs programmatically.

Instructions

Execute Emacs Lisp code by sending it to the Emacs process and return the result.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYes

Implementation Reference

  • The handler function decorated with @mcp.tool() for registration, implements execution of Emacs Lisp code via subprocess call to emacsclient.
    @log_execution @mcp.tool() def execute_emacs_lisp_code(code: str) -> str: """Execute Emacs Lisp code by sending it to the Emacs process and return the result.""" try: # Properly escape the Emacs Lisp code and pass it to emacsclient # The -e or --eval flag is used to evaluate the expression emacsclient_path = os.environ.get("EMACSCLIENT", "emacsclient") result = subprocess.check_output( [emacsclient_path, "--eval", code], text=True, stderr=subprocess.PIPE ).strip() return result except subprocess.CalledProcessError as e: return f"Error executing Emacs Lisp code: {e.stderr}"

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/vivekhaldar/emacs-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server