Skip to content

Commit c25e4ba

Browse files
committed
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
1 parent f1c6dec commit c25e4ba

File tree

1 file changed

+54
-52
lines changed

1 file changed

+54
-52
lines changed

README.md

Lines changed: 54 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
55
[![Emacs](https://img.shields.io/badge/Emacs-28.1%20|%2028.2%20|%2029.1%20|%2030.1%20|%2030.2-purple)](https://www.gnu.org/software/emacs/)
66

7-
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.
89

910
<div align="center">
1011
<img src="./demo/change-theme-demo.gif" alt="Change Theme Demo" width="80%" />
@@ -43,7 +44,7 @@ Alternatively, use package managers:
4344
:files ("*.el" "mcp-wrapper.py" "mcp-wrapper.sh")))
4445
```
4546

46-
**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`.
4748

4849
**Connect Claude Desktop:** Add this to your Claude Desktop configuration:
4950

@@ -91,30 +92,11 @@ Once connected, LLMs can perform powerful operations in your Emacs environment:
9192
- Window management - get layout information, manage splits
9293
- Major mode operations - work with mode-specific functionality
9394

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-
10095
## Available Tools
10196

10297
**Current Tool:**
10398
- `eval-elisp` - Execute arbitrary elisp expressions safely and return the result
10499

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-
118100
## Configuration
119101

120102
**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:
123105
(setq mcp-server-socket-name nil) ; Default: emacs-mcp-server.sock
124106
(setq mcp-server-socket-name 'user) ; User-based: emacs-mcp-server-{username}.sock
125107
(setq mcp-server-socket-name 'session) ; Session-based: emacs-mcp-server-{username}-{pid}.sock
126-
(setq mcp-server-socket-name "custom") ; Custom: emacs-mcp-server-custom.sock
108+
(setq mcp-server-socket-name "custom") ; Custom: emacs-mcp-server-custom.sock
127109
```
128110

129111
**Other configuration options:**
@@ -230,7 +212,7 @@ M-x customize-group RET mcp-server RET
230212

231213
### Security Modes
232214

233-
**Paranoid Mode (Maximum Security):**
215+
**Paranoid Mode:**
234216
```elisp
235217
;; Very restrictive - prompts for everything
236218
(setq mcp-server-security-dangerous-functions
@@ -239,7 +221,7 @@ M-x customize-group RET mcp-server RET
239221
(setq mcp-server-security-prompt-for-permissions t)
240222
```
241223

242-
**Permissive Mode (Development):**
224+
**Permissive Mode:**
243225
```elisp
244226
;; More relaxed for trusted development scenarios
245227
(setq mcp-server-security-allowed-dangerous-functions
@@ -249,7 +231,7 @@ M-x customize-group RET mcp-server RET
249231
'("~/.authinfo*" "~/.netrc*" "~/.ssh/" "~/.gnupg/"))
250232
```
251233

252-
**Whitelist-Only Mode (Ultra Secure):**
234+
**Whitelist-Only Mode:**
253235
```elisp
254236
;; Only allow explicitly whitelisted operations
255237
(setq mcp-server-security-prompt-for-permissions nil) ; No prompts - just deny
@@ -286,9 +268,7 @@ Operations requiring explicit permission include file system operations (`delete
286268
## Management Commands
287269

288270
**Server control:** `M-x mcp-server-start-unix` (start), `M-x mcp-server-stop` (stop), `M-x mcp-server-restart` (restart), `M-x mcp-server-status` (show status)
289-
290271
**Debugging and monitoring:** `M-x mcp-server-toggle-debug` (toggle debug logging), `M-x mcp-server-list-clients` (show connected clients), `M-x mcp-server-get-socket-path` (show socket path)
291-
292272
**Security management:** `M-x mcp-server-security-show-audit-log` (view security log), `M-x mcp-server-security-show-permissions` (view cached permissions)
293273

294274
## Client Integration
@@ -334,7 +314,6 @@ Operations requiring explicit permission include file system operations (`delete
334314
}
335315
```
336316

337-
338317
### Wrapper Scripts
339318

340319
**Shell wrapper (`mcp-wrapper.sh`)** - Lightweight, uses socat, good for simple integrations:
@@ -389,7 +368,6 @@ print(response)
389368
**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`
390369

391370
**Adding custom tools:**
392-
393371
```elisp
394372
(mcp-server-tools-register
395373
"my-tool"
@@ -405,25 +383,28 @@ print(response)
405383

406384
## Troubleshooting
407385

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.
409388

410389
**Socket not found:**
411-
1. Check if Emacs MCP Server is running: `M-x mcp-server-status`
412-
2. Verify socket path: `M-x mcp-server-get-socket-path`
413-
3. List available sockets: `./mcp-wrapper.sh --list-sockets`
390+
- Check if Emacs MCP Server is running: `M-x mcp-server-status`
391+
- Verify socket path: `M-x mcp-server-get-socket-path`
392+
- List available sockets: `./mcp-wrapper.sh --list-sockets`
414393

415394
**Connection refused:**
416-
1. Check socket permissions: `ls -la ~/.emacs.d/.local/cache/emacs-mcp-server*.sock`
417-
2. Test socket connectivity: `echo '{"jsonrpc":"2.0","id":1,"method":"tools/list"}' | socat - UNIX-CONNECT:~/.emacs.d/.local/cache/emacs-mcp-server.sock`
395+
- Check socket permissions: `ls -la ~/.emacs.d/.local/cache/emacs-mcp-server*.sock`
396+
- Test socket connectivity: `echo '{"jsonrpc":"2.0","id":1,"method":"tools/list"}' | socat - UNIX-CONNECT:~/.emacs.d/.local/cache/emacs-mcp-server.sock`
418397

419398
**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
423402

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)`.
425405

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`.
427408

428409
## Advanced Configuration
429410

@@ -453,18 +434,39 @@ print(response)
453434

454435
## Architecture
455436

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).
457-
458-
```
459-
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
460-
│ LLM Client │────│ Unix Socket │────│ Emacs MCP │
461-
│ (Claude/Python) │ │ Transport │ │ Server │
462-
└─────────────────┘ └──────────────────┘ └─────────────────┘
463-
464-
┌──────────────────┐
465-
│ MCP Tools │
466-
│ (Elisp Funcs) │
467-
└──────────────────┘
437+
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).
438+
439+
```mermaid
440+
flowchart LR
441+
subgraph Client
442+
LLM[LLM Client<br/>Claude Desktop/CLI]
443+
end
444+
445+
subgraph Bridge
446+
Wrapper[mcp-wrapper<br/>stdio ↔ socket]
447+
end
448+
449+
subgraph Emacs
450+
subgraph Transport
451+
Socket[Unix Socket<br/>Transport]
452+
end
453+
454+
subgraph MCP["MCP Server"]
455+
Protocol[Protocol Layer<br/>JSON-RPC 2.0]
456+
Security[Security Layer<br/>Permissions]
457+
Tools[Tool Registry]
458+
end
459+
460+
Elisp[Emacs Lisp<br/>Runtime]
461+
end
462+
463+
LLM <-->|stdio| Wrapper
464+
Wrapper <-->|Unix Socket| Socket
465+
Socket <-->|Messages| Protocol
466+
Protocol --> Security
467+
Security --> Tools
468+
Tools --> Elisp
469+
Elisp -->|Result| Protocol
468470
```
469471

470472
## License

0 commit comments

Comments
 (0)