You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs(README): Reorganize and improve formatting consistency
- Reformat long lines for better readability
- Standardize whitespace and indentation throughout
- Remove redundant example interactions section
- Condense security mode headings
- Convert troubleshooting section to use consistent bullet points
- Replace ASCII architecture diagram with mermaid flowchart
- Clean up extra blank lines and trailing whitespace
Connect Large Language Models directly to your Emacs environment! This MCP (Model Context Protocol) server exposes Emacs functionality through standardized tools, allowing LLMs like Claude to read and modify your buffers, execute elisp code, navigate files, and much more.
7
+
Connect Large Language Models directly to your Emacs environment! This MCP (Model Context Protocol) server exposes Emacs functionality through standardized tools,
8
+
allowing LLMs like Claude to read and modify your buffers, execute elisp code, navigate files, and much more.
**Start the server:** Run `M-x mcp-server-start-unix` in Emacs. The server creates a Unix socket at `~/.config/emacs/.local/cache/emacs-mcp-server.sock` (or similar based on your Emacs configuration).
47
+
**Start the server:** Run `M-x mcp-server-start-unix` in Emacs. The server creates a Unix socket at `~/.config/emacs/.local/cache/emacs-mcp-server.sock`.
47
48
48
49
**Connect Claude Desktop:** Add this to your Claude Desktop configuration:
49
50
@@ -91,30 +92,11 @@ Once connected, LLMs can perform powerful operations in your Emacs environment:
91
92
- Window management - get layout information, manage splits
92
93
- Major mode operations - work with mode-specific functionality
93
94
94
-
**Example Interactions:**
95
-
-*"Add a docstring to this function"* → Claude reads your buffer, analyzes the function, and adds proper documentation
96
-
-*"Refactor this code to use modern Python"* → Claude reads the code, suggests improvements, and can apply changes directly
97
-
-*"Create a new React component file"* → Claude creates the file, adds boilerplate code, and opens it in a buffer
98
-
-*"Fix the indentation in this buffer"* → Claude reads the content and applies proper formatting
99
-
100
95
## Available Tools
101
96
102
97
**Current Tool:**
103
98
-`eval-elisp` - Execute arbitrary elisp expressions safely and return the result
104
99
105
-
**What you can do now:** With the `eval-elisp` tool, you can already accomplish a lot! LLMs can:
106
-
- Read any buffer: `(buffer-string)` or `(with-current-buffer "filename.txt" (buffer-string))`
107
-
- Write to buffers: `(insert "text")` or `(with-current-buffer "filename.txt" (insert "text"))`
108
-
- Navigate files: `(find-file "path/to/file")` or `(switch-to-buffer "buffer-name")`
109
-
- Get cursor position: `(point)` or `(line-number-at-pos)`
110
-
- Move cursor: `(goto-char 100)` or `(goto-line 50)`
111
-
- Get selections: `(if (region-active-p) (buffer-substring (region-beginning) (region-end)) "No selection")`
112
-
- List buffers: `(mapcar #'buffer-name (buffer-list))`
113
-
- Execute commands: `(call-interactively 'command-name)` or `(command-name)`
114
-
- Access variables: `variable-name` or `(setq variable-name value)`
115
-
116
-
**Planned tools** for future implementation include dedicated functions for buffer management (`get-buffer-content`, `set-buffer-content`, `get-buffer-list`), navigation (`get-point`, `goto-point`, `insert-at-point`), variable access (`get-variable`, `set-variable`), and window operations (`get-window-configuration`).
117
-
118
100
## Configuration
119
101
120
102
**Socket naming strategies:** Choose how sockets are named based on your setup:
@@ -123,7 +105,7 @@ Once connected, LLMs can perform powerful operations in your Emacs environment:
@@ -334,7 +314,6 @@ Operations requiring explicit permission include file system operations (`delete
334
314
}
335
315
```
336
316
337
-
338
317
### Wrapper Scripts
339
318
340
319
**Shell wrapper (`mcp-wrapper.sh`)** - Lightweight, uses socat, good for simple integrations:
@@ -389,7 +368,6 @@ print(response)
389
368
**Quick test:** Run `./test/scripts/test-runner.sh` or test a specific socket with `./test/integration/test-unix-socket-fixed.sh ~/.emacs.d/.local/cache/emacs-mcp-server.sock`
390
369
391
370
**Adding custom tools:**
392
-
393
371
```elisp
394
372
(mcp-server-tools-register
395
373
"my-tool"
@@ -405,25 +383,28 @@ print(response)
405
383
406
384
## Troubleshooting
407
385
408
-
**Server won't start:** Check if socket directory exists and is writable, verify no other server is using the same socket path, check Emacs *Messages* buffer for error details.
386
+
**Server won't start:**
387
+
- Check if socket directory exists and is writable, verify no other server is using the same socket path, check Emacs *Messages* buffer for error details.
409
388
410
389
**Socket not found:**
411
-
1. Check if Emacs MCP Server is running: `M-x mcp-server-status`
- Test socket connectivity: `echo '{"jsonrpc":"2.0","id":1,"method":"tools/list"}' | socat - UNIX-CONNECT:~/.emacs.d/.local/cache/emacs-mcp-server.sock`
418
397
419
398
**MCP client issues:**
420
-
1. Verify client configuration: Check JSON syntax and file paths
421
-
2. Check client logs: Most MCP clients provide debug logging
422
-
3. Test wrapper independently: Run wrapper script manually to verify connection
399
+
- Verify client configuration: Check JSON syntax and file paths
400
+
- Check client logs: Most MCP clients provide debug logging
401
+
- Test wrapper independently: Run wrapper script manually to verify connection
423
402
424
-
**Permission errors:** View audit log with `M-x mcp-server-security-show-audit-log`, grant specific permissions with `(mcp-server-security-grant-permission 'function-name)`, or disable prompting with `(mcp-server-security-set-prompting nil)`.
403
+
**Permission errors:**
404
+
- View audit log with `M-x mcp-server-security-show-audit-log`, grant specific permissions with `(mcp-server-security-grant-permission 'function-name)`, or disable prompting with `(mcp-server-security-set-prompting nil)`.
425
405
426
-
**Debug mode:** Enable with `(setq mcp-server-debug t)` or toggle with `M-x mcp-server-toggle-debug`.
406
+
**Debug mode:**
407
+
- Enable with `(setq mcp-server-debug t)` or toggle with `M-x mcp-server-toggle-debug`.
427
408
428
409
## Advanced Configuration
429
410
@@ -453,18 +434,39 @@ print(response)
453
434
454
435
## Architecture
455
436
456
-
The server uses a modular design with a transport layer (Unix domain sockets, TCP planned), protocol layer (JSON-RPC 2.0 message handling), tool registry (Elisp functions exposed as MCP tools), and security layer (permission management and validation).
The server uses a modular design with a transport layer (Unix domain sockets), protocol layer (JSON-RPC 2.0 message handling), tool registry (Elisp functions exposed as MCP tools), and security layer (permission management and validation).
0 commit comments