Cover image
Try Now
2025-03-31

使用模型上下文协议(MCP)和官方Neovim/Neovim/Node-Client JavaScript库来控制Neovim

3 years

Works with Finder

2

Github Watches

9

Github Forks

111

Github Stars

Neovim MCP Server

A proof of concept integration between Claude Desktop (or any client) and Neovim using Model Context Protocol (MCP) and the official neovim/node-client JavaScript library. This server leverages Vim's native text editing commands and workflows, which Claude already understands, to create a lightweight code or general purpose AI text assistance layer.

mcp-neovim-server MCP server

Features

  • Connects to your nvim instance if you expose a socket file, for example --listen /tmp/nvim, when starting nvim
  • Views your current buffers
  • Gets cursor location, mode, file name
  • Runs vim commands and optionally shell commands through vim
  • Can make edits using insert or replacement

API

Resources

  • nvim://session: Current neovim text editor session
  • nvim://buffers: List of all open buffers in the current Neovim session with metadata including modified status, syntax, and window IDs

Tools

  • vim_buffer
    • Current VIM text editor buffer with line numbers shown
    • Input filename (string)
    • Filename is ignored, returns a string of numbered lines with the current active buffer content
  • vim_command
    • Send a command to VIM for navigation, spot editing, and line deletion
    • Input command (string)
    • Runs a vim command first passed through nvim.replaceTermcodes. Multiple commands will work if separated by newlines
    • On error, 'nvim:errmsg' contents are returned
  • vim_status
    • Get the status of the VIM editor
    • Status contains cursor position, mode, filename, visual selection, window layout, current tab, marks, registers, and working directory
  • vim_edit
    • Edit lines using insert, replace, or replaceAll in the VIM editor
    • Input startLine (number), mode ("insert" | "replace" | "replaceAll"), lines (string)
    • insert will insert lines at startLine
    • replace will replace lines starting at startLine
    • replaceAll will replace the entire buffer contents
  • vim_window
    • Manipulate Neovim windows (split, vsplit, close, navigate)
    • Input command (string: "split", "vsplit", "only", "close", "wincmd h/j/k/l")
    • Allows window management operations
  • vim_mark
    • Set a mark at a specific position
    • Input mark (string: a-z), line (number), column (number)
    • Sets named marks at specified positions
  • vim_register
    • Set content of a register
    • Input register (string: a-z or "), content (string)
    • Manages register contents
  • vim_visual
    • Make a visual selection
    • Input startLine (number), startColumn (number), endLine (number), endColumn (number)
    • Creates visual mode selections

Using this simple set of tools, Claude can peer into your neovim session to answer questions as well as make edits to the buffer.

Limitations

  • This is a quick proof of concept to experiment with Model Context Protocol. Use at your own risk.
  • May not interact well with a custom neovim config!
  • Error handling could be better.
  • Sometimes Claude doesn't get the vim command input just right.

Configuration

Environment Variables

  • ALLOW_SHELL_COMMANDS: Set to 'true' to enable shell command execution (e.g. !ls). Defaults to false for security.
  • NVIM_SOCKET_PATH: Set to the path of your Neovim socket. Defaults to '/tmp/nvim' if not specified.

Usage with Claude Desktop

Add this to your claude_desktop_config.json:

{
  "mcpServers": {
    "MCP Neovim Server": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-neovim-server"
      ],
      "env": {
        "ALLOW_SHELL_COMMANDS": "true",
        "NVIM_SOCKET_PATH": "/tmp/nvim"
      }
    }
  }
}

License

This MCP server is licensed under the MIT License. This means you are free to use, modify, and distribute the software, subject to the terms and conditions of the MIT License. For more details, please see the LICENSE file in the project repository.

相关推荐

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • https://suefel.com
  • Latest advice and best practices for custom GPT development.

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • Elijah Ng Shi Yi
  • Advanced software engineer GPT that excels through nailing the basics.

  • https://maiplestudio.com
  • Find Exhibitors, Speakers and more

  • Alexandru Strujac
  • Efficient thumbnail creator for YouTube videos

  • Yusuf Emre Yeşilyurt
  • I find academic articles and books for research and literature reviews.

  • Carlos Ferrin
  • Encuentra películas y series en plataformas de streaming.

  • https://zenepic.net
  • Embark on a thrilling diplomatic quest across a galaxy on the brink of war. Navigate complex politics and alien cultures to forge peace and avert catastrophe in this immersive interstellar adventure.

  • https://reddgr.com
  • Delivers concise Python code and interprets non-English comments

  • apappascs
  • 发现市场上最全面,最新的MCP服务器集合。该存储库充当集中式枢纽,提供了广泛的开源和专有MCP服务器目录,并提供功能,文档链接和贡献者。

  • ShrimpingIt
  • MCP系列GPIO Expander的基于Micropython I2C的操作,源自ADAFRUIT_MCP230XX

  • pontusab
  • 光标与风浪冲浪社区,查找规则和MCP

  • av
  • 毫不费力地使用一个命令运行LLM后端,API,前端和服务。

  • 1Panel-dev
  • 🔥1Panel提供了直观的Web接口和MCP服务器,用于在Linux服务器上管理网站,文件,容器,数据库和LLMS。

  • GeyserMC
  • 与Minecraft客户端/服务器通信的库。

  • Mintplex-Labs
  • 带有内置抹布,AI代理,无代理构建器,MCP兼容性等的多合一桌面和Docker AI应用程序。

  • awslabs
  • AWS MCP服务器 - 将AWS最佳实践直接带入您的开发工作流程的专门MCP服务器

  • WangRongsheng
  • 🧑‍🚀 llm 资料总结(数据处理、模型训练、模型部署、 o1 模型、mcp 、小语言模型、视觉语言模型)|摘要世界上最好的LLM资源。

    Reviews

    2 (1)
    Avatar
    user_tvMChOvJ
    2025-04-17

    As a devoted user of the mcp-neovim-server by bigcodegen, I must say it has vastly improved my development workflow. The seamless integration with Neovim is outstanding, and the responsiveness of the server is impeccable. For anyone serious about coding efficiency, this tool is a must-have. Check it out here: https://github.com/bigcodegen/mcp-neovim-server. Highly recommended!