Single tool with severely inadequate definition quality. Tool name is acceptable (verb-first), but description is sparse (~40 chars, below baseline ~194 chars). Input schema is present and typed (string), but parameter description is minimal (~35 chars). No output schema documented. Critical gap: tool performs IRREVERSIBLE operations (executes arbitrary Lisp in Emacs) with zero error handling, confirmation mechanism, or recovery guidance. No validation of input, no guidance for failure modes. Tool accepts a bare 'command' string with no constraints, enums, format validation, or sanitization, dangerous for an irreversible action. No audit trail, no permission checks. Baseline expectation for irreversible operations: dry-run support, confirmation step, detailed error messages with recovery paths. This tool violates multiple critical security patterns (pattern:confirmation-request, pattern:recovery-guide, pattern:tool-gateway).
No error handling or recovery guidance for irreversible operations. Tool executes arbitrary Lisp code with zero confirmation, dry-run, or undo capability. Failures return raw Go errors ('return nil, err') instead of actionable guidance.
Input parameter 'command' lacks validation, constraints, and format guidance. No enum, regex pattern, or example usage. Accepts arbitrary strings with no sanitization against command injection or malicious Lisp.
No documented output schema. Handler returns mcp.CallToolResult with Content as raw text, but structure of Lisp evaluation output is undocumented. LLMs cannot predict or validate response format.
Tool description (40 chars) is well below baseline (194 chars p50). Lacks context: When should this be called vs other approaches? What happens on success vs failure? What are prerequisites (e.g., Emacs must be running with server enabled)?
Recommendations
Add a dry-run parameter (dry_run: boolean, default=false) to preview Lisp execution without side effects. For irreversible operations, make dry-run the default and require explicit confirmation=true to execute.
Expand parameter description: 'the lisp command to run' → 'A valid Emacs Lisp expression (e.g., "(+ 1 2)", "(message \"hello\")"). Commands that modify files or state are IRREVERSIBLE. Use dry_run=true to preview first. Requires Emacs server to be running (emacs --daemon or (server-start) in init.el).'
Expand tool description to ~150 - 250 chars: 'Executes an arbitrary Emacs Lisp expression in a running Emacs instance via emacsclient. Returns the evaluated result. WARNING: This operation is IRREVERSIBLE, destructive commands (delete-file, kill-buffer, etc.) cannot be undone. Always preview with dry_run=true first. Requires Emacs server mode enabled and emacsclient in PATH.'
Document output schema explicitly: 'Returns a structured result with fields: result (string, the printed output of the Lisp evaluation), error (boolean, true if Lisp evaluation raised an exception), error_message (string, exception details if error=true).'
Replace bare error handling with actionable messages. Instead of 'return nil, err', catch exec.Command errors and categorize: timeout → 'Emacs did not respond within 5s. Is the server running? Try: emacs --daemon'; connection failed → 'emacsclient not found or Emacs server not running. Start with: emacs --daemon'; parse error → 'Lisp syntax error: {err.Error()}. Check your expression and try again.'
No permission gates or audit trail. Tool executes arbitrary code in user's Emacs instance with no logging of who called what, when, or with which command. Violates compliance and debugging requirements.
Error responses fail the recovery-guide pattern. Handler returns bare Go errors ('if err != nil { return nil, err }') with no categorization (retryable vs fatal), no actionable next steps, no context about what failed.
execute_lisp
Add optional logging parameter for audit: execute_lisp should log caller identity, timestamp, command (masked for secrets), and result status to stderr or a configured audit log. This enables compliance and incident response.
Implement a confirmation-request pattern for destructive operations. If command contains keywords like 'delete', 'kill', 'remove', 'write-file', return an error with is_error=true and message: 'This command appears destructive ({reason}). Re-call with confirm=true to proceed.' This prevents accidental irreversible damage.
Add input validation: reject commands containing shell metacharacters (|, ;, $(), etc.) unless explicitly escaped, preventing command injection. Validate Lisp syntax with a lightweight parser or sandboxed pre-check.
Include rate limiting and timeout guards: set a 5 - 10 second timeout on emacsclient calls and return a clear error if exceeded. Prevent runaway agents from spawning unbounded processes.
Document prerequisites in tool description: 'Requires: (1) Emacs 24+ with server mode enabled; (2) emacsclient in $PATH; (3) (server-start) or emacs --daemon before first call.' This prevents silent failures when these are not met.