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}"
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions sending code to the Emacs process and returning results, but lacks details on permissions, side effects, error handling, or execution environment. This is a significant gap for a code execution tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core functionality with zero waste. Every word earns its place, making it appropriately sized and well-structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of code execution, lack of annotations, no output schema, and low schema coverage, the description is incomplete. It doesn't cover return values, error cases, or execution nuances, leaving the agent with insufficient context for safe and effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 0%, so the description must compensate. It implies the 'code' parameter is Emacs Lisp code to execute, adding basic meaning beyond the schema. However, it doesn't detail syntax, constraints, or examples, leaving gaps in parameter understanding.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Execute Emacs Lisp code') and the resource ('Emacs process'), specifying that it sends code and returns results. However, it doesn't explicitly differentiate from its sibling tool 'generate_emacs_lisp_code', which likely generates code rather than executing it.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives, such as its sibling 'generate_emacs_lisp_code'. The description implies usage for executing code but lacks explicit context, prerequisites, or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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