
MCP服务器,用于将Neovim缓冲器曝光给克洛德代码等AI代理
概览
MCP(模式上下文协议)服务器将Neovim缓冲与克洛德代码相融合,可以实现无缝缓冲意识和实时更新. - 当前有路径和内容的主动缓冲 - - 列出所有有元数据的开放式缓冲 - 在当前目录中运行的 nvim 实例中列出所有打开的缓冲器 - 获取当前活动的缓冲器 - 以路径获取特定缓冲器的内容 - 直接在 nvim 中更新缓冲器内容( 立即出现更改 !) - 在 nvim 中打开文件( 创建新文件后有用) - - 从磁盘上重新装入缓冲器 - - 检查并重新装入磁盘上所有更改的缓冲器 在终端中运行以下命令 : 这将自动将服务器添加到您的 ~/. claude.json 配置中 。 或者,手动编辑~/.claude.json: 添加配置后, 重新启动 Claude 代码以生效 。 检查服务器配置是否正确 :
概述(AI 翻译)
MCP(模式上下文协议)服务器将Neovim缓冲与克洛德代码相融合,可以实现无缝缓冲意识和实时更新.
□ 特性
- 资源(可自动获取的背景)
- [T0] – – 目前带有路径和内容的主动缓冲器
- [T1] – – 所有有元数据的开放缓冲列表
• 工具(Claude Can Invoke)
- ** [T2] ** - 在当前目录中运行的nvim实例中列出所有打开的缓冲
- ** [[T3]** – 获取当前活动的缓冲器
- ** [T4]** – – 通过路径获取特定缓冲器的内容 -[T5] - 直接以nvim更新缓冲内容(变化立即出现!) -[[T6]] - 用 nvim 打开文件(在创建新文件后有用)
- [T7]-从磁盘上重新装入缓冲器
- [[T8]] - 检查并重新装入磁盘上更改的所有缓冲器
□ 用 Claude 代码设置
备选1:使用国家综合倡议(建议)
在终端中运行以下命令 :
这将自动将服务器添加到您的 [[T9] 配置中 。
备选2:手工配置
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
Neovim MCP Server
MCP (Model Context Protocol) server that integrates Neovim buffers with Claude Code, enabling seamless buffer awareness and real-time updates.
Features
Resources (Auto-available Context)
nvim://current-buffer- Currently active buffer with path and contentnvim://open-buffers- List of all open buffers with metadata
Tools (Claude Can Invoke)
list_nvim_buffers()- List all open buffers in nvim instances running in current directoryget_current_buffer()- Get the currently active bufferget_buffer_content(path)- Get content of a specific buffer by pathupdate_buffer(path, content)- Update buffer content directly in nvim (changes appear immediately!)open_file(path)- Open a file in nvim (useful after creating new files)reload_buffer(path)- Reload a buffer from diskreload_all_buffers()- Check and reload all buffers that changed on disk
Setup with Claude Code
Option 1: Using the CLI (Recommended)
Run the following command in your terminal:
claude mcp add --transport stdio nvim -- npx nvim-mcp-server
This will automatically add the server to your ~/.claude.json configuration.
Option 2: Manual Configuration
Alternatively, manually edit ~/.claude.json:
{
"mcpServers": {
"nvim": {
"command": "npx",
"args": ["nvim-mcp-server"]
}
}
}
After adding the configuration, restart Claude Code for changes to take effect.
Verify Setup
Check that the server is configured correctly:
claude mcp list
Or use /mcp within Claude Code to check server status.
Usage
Once configured, the MCP server will automatically:
- Detect Neovim instances running in the current directory
- Expose buffer context to Claude via resources
- Enable buffer operations via tools
Example Workflows
1. Refactor Current File
You: "Refactor the current file to use async/await"
Claude:
- Reads nvim://current-buffer resource automatically
- Sees you're working on src/api.js
- Refactors the code
- Calls update_buffer() to push changes to nvim
- Changes appear instantly in your editor!
2. Check Open Buffers
You: "What files do I have open in nvim?"
Claude:
- Calls list_nvim_buffers() tool
- Shows you all open buffers
3. Update Specific Buffer
You: "Add error handling to src/utils.js"
Claude:
- Calls get_buffer_content("src/utils.js")
- Adds error handling
- Calls update_buffer() to apply changes
- You see updates in nvim immediately
4. Create and Open New File
You: "Create a new component called Button.jsx"
Claude:
- Creates the file using Write tool
- Calls open_file("src/components/Button.jsx")
- File opens in your nvim automatically
- You can continue editing right away!
How It Works
- Discovery: Uses
$TMPDIRto find nvim socket files
安装
npx nvim-mcp-server配置
{
"mcpServers": {
"nvim": {
"command": "npx",
"args": ["nvim-mcp-server"]
}
}
}