emacs-mcp
An MCP server that bridges Claude Code with Emacs via emacsclient, enabling buffer, file, org-mode, git, and diff operations.
README
emacs-mcp
An MCP (Model Context Protocol) server that bridges Claude Code with Emacs via emacsclient.
Features
Phase 1: Core (Buffer & Eval)
| Tool | Description |
|---|---|
emacs_eval |
Execute arbitrary Elisp code |
emacs_buffer_read |
Read contents of a buffer |
emacs_buffer_write |
Write/replace content in a buffer |
emacs_buffer_edit |
Apply targeted edits (find and replace) |
emacs_buffer_list |
List all open buffers |
emacs_buffer_switch |
Switch to a buffer |
emacs_buffer_create |
Create a new buffer |
emacs_buffer_kill |
Close/kill a buffer |
Phase 2: File & Project Operations
| Tool | Description |
|---|---|
emacs_file_open |
Open a file (with optional line/column) |
emacs_file_save |
Save buffer to file |
emacs_file_save_as |
Save buffer to new path |
emacs_file_info |
Get file metadata |
emacs_project_list |
List known projects |
emacs_project_current |
Get current project info |
emacs_project_switch |
Switch to a project |
emacs_project_files |
List files in project |
emacs_project_search |
Search files by pattern |
emacs_workspace_list |
List workspaces/tabs |
emacs_workspace_current |
Get current workspace |
emacs_workspace_switch |
Switch workspace |
emacs_workspace_create |
Create new workspace |
emacs_workspace_delete |
Delete workspace |
emacs_workspace_save |
Save workspace state |
Phase 3: Org-mode Integration
| Tool | Description |
|---|---|
emacs_org_read |
Read org document (raw or parsed structure) |
emacs_org_write |
Write content to org buffer |
emacs_org_heading_add |
Add a new heading |
emacs_org_heading_update |
Update heading title/content |
emacs_org_heading_delete |
Delete a heading and subtree |
emacs_org_heading_move |
Move heading (up/down/promote/demote) |
emacs_org_todo_set |
Set TODO state for a heading |
emacs_org_todo_list |
List all TODO items |
emacs_org_tag_set |
Set tags for a heading |
emacs_org_property_set |
Set a property for a heading |
emacs_org_export |
Export to html/pdf/markdown/latex/ascii/odt |
emacs_org_agenda |
Query agenda (day/week/month) |
emacs_org_capture |
Create entry via capture template |
emacs_org_search |
Search org files (text/heading/tag/property) |
Phase 4: Git/Magit Integration
| Tool | Description |
|---|---|
emacs_git_status |
Get git status (staged, unstaged, untracked) |
emacs_git_diff |
Get diff (staged/unstaged/committed) |
emacs_git_log |
Get commit log |
emacs_git_stage |
Stage files for commit |
emacs_git_unstage |
Unstage files |
emacs_git_commit |
Create a commit |
emacs_git_branch_list |
List branches |
emacs_git_branch_current |
Get current branch |
emacs_git_branch_checkout |
Checkout a branch |
emacs_git_stash_list |
List stashes |
emacs_git_stash_push |
Create a stash |
emacs_git_stash_pop |
Pop a stash |
emacs_git_blame |
Show git blame for a file |
Phase 5: Ediff & Comparison
| Tool | Description |
|---|---|
emacs_ediff_files |
Compare two files (unified/context/side-by-side) |
emacs_ediff_buffers |
Compare two buffers |
emacs_ediff_regions |
Compare two text strings |
emacs_ediff_3way |
Three-way file comparison (for merges) |
emacs_diff_summary |
Get summary of differences |
Resources
| URI | Description |
|---|---|
emacs://buffers |
List of all open buffers |
emacs://buffer/{name} |
Contents of a buffer |
emacs://projects |
List of known projects |
emacs://project/current |
Current project info |
emacs://project/{path}/files |
Files in a project |
emacs://workspaces |
List of workspaces |
emacs://workspace/current |
Current workspace |
emacs://org/agenda |
Today's agenda items |
emacs://org/todos |
All TODO items |
emacs://org/files |
Org-agenda files |
emacs://org/capture-templates |
Available capture templates |
emacs://git/status |
Current git status |
emacs://git/branch |
Current branch info |
Compatibility
- Vanilla Emacs: Uses
project.elandtab-bar-mode - Doom Emacs: Uses
projectileand+workspace(auto-detected)
Prerequisites
- Emacs 28+ with daemon support
- Node.js 18+
- Running Emacs daemon:
emacs --daemon
Installation
npm install
npm run build
Configuration
Add to your Claude Code .mcp.json:
{
"mcpServers": {
"emacs": {
"command": "node",
"args": ["/path/to/emacs-mcp/dist/index.js"],
"env": {
"EMACS_SOCKET": "/run/user/1000/emacs/server",
"EMACSCLIENT_PATH": "/usr/bin/emacsclient"
}
}
}
}
Environment Variables
| Variable | Description | Default |
|---|---|---|
EMACS_SOCKET |
Path to Emacs daemon socket | Auto-detect |
EMACSCLIENT_PATH |
Path to emacsclient binary | emacsclient |
EMACS_TIMEOUT |
Default timeout for operations (ms) | 5000 |
EMACS_ORG_DIRECTORY |
Org files directory | ~/org |
Usage Examples
Claude: Read the contents of the *scratch* buffer
> Uses emacs_buffer_read tool
Claude: List all open buffers
> Uses emacs_buffer_list tool
Claude: Evaluate (+ 1 2 3) in Emacs
> Uses emacs_eval tool
Claude: What projects do I have open?
> Uses emacs_project_list tool
Claude: Switch to workspace "main"
> Uses emacs_workspace_switch tool
Claude: Open /path/to/file.ts at line 42
> Uses emacs_file_open tool
Claude: Show me my TODO items
> Uses emacs_org_todo_list tool
Claude: Add a TODO heading "Review PRD" to notes.org
> Uses emacs_org_heading_add tool
Claude: What's on my agenda this week?
> Uses emacs_org_agenda tool
Claude: Export my notes.org to PDF
> Uses emacs_org_export tool
Claude: What's my git status?
> Uses emacs_git_status tool
Claude: Show me the recent commits
> Uses emacs_git_log tool
Claude: Stage all changes and commit
> Uses emacs_git_stage and emacs_git_commit tools
Claude: What branch am I on?
> Uses emacs_git_branch_current tool
Claude: Compare file.ts with file.ts.bak
> Uses emacs_ediff_files tool
Claude: Show me the differences between these two buffers
> Uses emacs_ediff_buffers tool
Claude: Do a three-way merge comparison
> Uses emacs_ediff_3way tool
Development
# Watch mode
npm run dev
# Run tests
npm test
# Lint
npm run lint
Roadmap
See PRD.md for full roadmap:
- [x] Phase 1: Core Infrastructure (MVP)
- [x] Phase 2: File & Project Operations
- [x] Phase 3: Org-mode Integration
- [x] Phase 4: Git/Magit Integration
- [x] Phase 5: Ediff & Advanced Features
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。