
laktek/nvim-mcp-server
Developer toolsこのページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。 原文を見る
Neovim バッファを Claude コードのような AI エージェントに公開するための MCP サーバー
概要
Neovim バッファを Claude コードと統合する MCP (Model Context Protocol) サーバーで、シームレスなバッファの認識とリアルタイムの更新を実現します。 - - 現在、パスとコンテンツの有効バッファ - - メタデータを含むすべてのオープンバッファのリスト - - - 現在のディレクトリで実行されているnvimインスタンス内のすべてのオープンバッファをリスト - - 現在アクティブなバッファを取得する - - パスで特定のバッファのコンテンツを取得する - - nvimで直接バッファコンテンツを更新する(変更はすぐに表示されます) - - - nvim でファイルを開きます(新しいファイルを作成した後に便利です) - - ディスクからバッファをリロード - ディスクで変更されたすべてのバッファをチェックしてリロードする ターミナルで次のコマンドを実行します。 サーバを ~/.claude.json 設定に自動的に追加します。 あるいは、手動で ~/.claude.json を編集します。 設定を追加した後、Claudeコードを再起動して、効果を取るために変更します。 サーバが正しく設定されていることを確認してください
概要(AI 翻訳)
Neovim バッファを Claude コードと統合する MCP (Model Context Protocol) サーバーで、シームレスなバッファの認識とリアルタイムの更新を実現します。
##特徴
リソース(自動利用できるコンテキスト)
-[nvim://current-buffer - 現在、パスとコンテンツの有効バッファ
-[nvim://open-buffers - すべてのオープンバッファのメタデータのリスト
ツール(クロードは呼び出すことができます)
-[list_nvim_buffers() - 現在のディレクトリで実行されているnvimインスタンスのすべてのオープンバッファをリスト
-[get_current_buffer() - 現在アクティブなバッファを取得する
-[get_buffer_content(path) - パスで特定のバッファのコンテンツを取得する
-[update_buffer(path, content) - nvimで直接バッファコンテンツを更新する(すぐに変更が表示されます)
-[open_file(path) - nvim でファイルを開きます(新しいファイルを作成すると便利です)
-[reload_buffer(path) - ディスクからバッファをリロードする
-[reload_all_buffers() - ディスクに変更されたすべてのバッファをチェックしてリロードする
#Claudeコードのセットアップ
Option 1: CLI を使用する (推奨)
ターミナルで次のコマンドを実行します。
~/.claude.json 設定にサーバーを自動的に追加します。
##Option 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"]
}
}
}