Back to MCP directory
publicPublicdnsLocal runtime

emacs-mcp-server

Emacs的MCP服务,支持生成和执行elisp代码

article

README

🚀 Emacs MCP 服务器

Emacs MCP 服务器基于模型上下文协议(MCP),专为 Emacs 打造。它具备强大的功能,能够生成 Elisp 代码,并在运行中的 Emacs 进程里执行这些代码,为用户带来高效便捷的使用体验。

✨ 主要特性

该服务器公开了两个实用工具:

  • generate_emacs_lisp_code:可针对给定任务生成相应的 Elisp 代码。
  • execute_emacs_lisp_code:借助emacsclient,将 Elisp 代码传递到正在运行的 Emacs 中进行评估和执行。

📦 安装指南

该项目使用uv进行管理,安装步骤如下:

  1. 运行uv sync,安装所有依赖项。
  2. 执行source .venv/bin/activate,激活生成的虚拟环境。

💻 使用示例

基础用法

要在检查器中运行 MCP 服务器,可使用以下命令:

mcp dev emacs_mcp_server.py

高级用法

若要将 MCP 服务器安装为 Claude Desktop 可用,可使用以下命令:

mcp install emacs_mcp_server.py

不过,你必须编辑生成的 JSON 配置文件claude_desktop_config.json,以包含 API 密钥和emacsclient的完整路径。配置文件示例如下:

    "Emacs-MCP-Server": {
      "command": "/Users/haldar/.local/bin/uv",
      "args": [
        "run",
        "--with",
        "mcp[cli]",
        "--with",
        "smartfunc",
        "mcp",
        "run",
        "/Users/haldar/repos/gh/emacs-mcp-server/emacs_mcp_server.py"
      ],
      "env": {
          "OPENAI_API_KEY": "sk-xxxx",
          "EMACSCLIENT": "/your/path/to/emacsclient"
      }
    }
help

Runtime guide

cloud

Hosted runtime

Hosted servers run from a provider-managed environment. You usually connect the MCP client to the hosted endpoint or follow the provider's authorization flow, without keeping a local process alive

  1. Open provider connection page
  2. Authorize or copy endpoint
  3. Connect from your MCP client
terminal

Local runtime / other methods

Local servers run on your own machine or infrastructure. You normally copy the server_config into your MCP client, install the required package, and provide env variables from env_schema when needed

  1. Copy server_config
  2. Install required package
  3. Fill env variables and restart client