mcpField
V
Vim MCP Server

Vim MCP Server

Remote
github.com/bregglesDeveloper Tools0Updated 4w ago
Repository

About Vim MCP Server

Vim MCP Server runs inside Vim and lets MCP clients, including coding agents, inspect and modify buffers and control editor navigation. It also exposes Vim diff views, message history, and quickfix and location lists, with selected write and command tools opt-in.

Key features

  1. 01Read and edit buffers
  2. 02Open and close files
  3. 03Move cursor and read selections
  4. 04Manage quickfix and location lists
  5. 05Show file and git diffs
  6. 06Read Vim message history

Use cases

  1. 01Showing changed files and lines to a coding agent
  2. 02Sharing a selected buffer region for code advice
  3. 03Navigating to multiple code locations
  4. 04Reviewing file or git diffs inside Vim

MCP support

It runs an HTTP MCP server embedded in Vim and exposes editor tools to MCP clients. Buffer saving, editing, and arbitrary Ex command execution can be enabled through options.

Configuration

Remote servers need no local install. Pick your client, then copy the config or install in one click.

Endpointhttp://localhost:8765/mcp
Copy install command
Claude CodeTerminal
Cursor.cursor/mcp.json
VS Code.vscode/mcp.json
Claude Desktopclaude_desktop_config.json
Windsurf~/.codeium/windsurf/mcp_config.json

Run commands in a terminal; paste JSON into the client’s MCP config and restart. Servers that need sign-in will prompt on first connect.

Tools

Details

From the project README

vim-mcp-server

An MCP (Model Context Protocol) server embedded in Vim. It exposes tools over HTTP that let MCP-compatible clients — such as AI coding agents — read and modify buffers, move the cursor, retrieve visual selections, manage quickfix and location lists, open side-by-side diffs (including git diffs computed inside Vim), read message history, and run Ex commands.

Atm, I mainly use this for getting the agent to show me files/lines in Vim. Sometimes, I use it for showing selected regions to the agent.

Requirements

  • Vim compiled with +python3

Installation

Use your preferred plugin manager.

vim-plug
Plug 'breggles/vim-mcp-server'
Vundle
Plugin 'breggles/vim-mcp-server'
Manual

Clone the repository into your Vim packages directory:

git clone https://github.com/breggles/vim-mcp-server.git \
    ~/.vim/pack/plugins/start/vim-mcp-server

Usage

Start the server

In Vim, run:

:McpServerStart

Auto-start the server on Vim launch by adding this to your vimrc:

let g:mcp_server_autostart = 1
MCP Client Configuration

Point your MCP client at http://127.0.0.1:8765/mcp (or whichever port you chose).

For example, for opencode add the server to your opencode.jsonc:

"mcp": {
  "vim": {
    "type": "remote",
    "url": "http://localhost:8765/mcp",
    "enabled": true
  }
}

Commands

CommandDescription
:McpServerStart [port]Start the server (default port 8765)
:McpServerStopStop the server
:McpServerStatusPrint server status and URL

Options

VariableDefaultDescription
g:mcp_server_port8765Port the server listens on
g:mcp_server_autostart0Start the server automatically on VimEnter
g:mcp_server_allow_execute0Enable the execute_command tool
g:mcp_server_allow_save0Enable the save_buffer tool
g:mcp_server_allow_edit0Enable the edit_buffer tool

Tools

The server exposes the following tools to MCP clients:

ToolDescription
list_buffersList all open buffers
get_bufferRead buffer contents (optionally a line range)
edit_bufferReplace, insert, or delete lines in a buffer
open_fileOpen a file via :edit
save_bufferSave a buffer via :write (opt-in, see above)
close_bufferClose a buffer via :bdelete
get_cursorGet current cursor position
set_cursorMove cursor to a line and column
get_visual_selectionGet the current visual selection, if any
execute_commandRun an arbitrary Ex command (opt-in, see above)
get_quickfix_listGet the current quickfix list entries
set_quickfix_listSet the quickfix list
get_location_listGet the location list for the current window
set_location_listSet the location list for the current window
get_messagesGet Vim's message history (:messages output)
show_diffOpen a side-by-side diff view in a new tab (files or content)
show_git_diffOpen a side-by-side git diff in a new tab; git computes both sides inside Vim

When a tool accepts a buffer argument it can be specified by number (buffer_id) or by file path (buffer_path). When both are omitted, the current buffer is used.

OpenCode Plan Mode

By default, OpenCode's plan mode disables all MCP tools. To allow read-only vim tools in plan mode, add the following to your opencode.jsonc:

{
  "agent": {
    "plan": {
      "tools": {
        "vim_*": false,
        "vim_list_buffers": true,
        "vim_get_buffer": true,
        "vim_get_cursor": true,
        "vim_get_visual_selection": true,
        "vim_open_file": true,
        "vim_set_cursor": true,
        "vim_get_quickfix_list": true,
        "vim_set_quickfix_list": true,
        "vim_get_location_list": true,
        "vim_set_location_list": true,
        "vim_get_messages": true,
        "vim_show_diff": true,
        "vim_show_git_diff": true
      }
    }
  }
}

This disables all vim_* tools first, then re-enables specific ones. Adjust the list to suit your workflow.

Development

To work on the plugin without installing it, clone the repository and add it to Vim's runtime path:

set rtp+=~/path/to/vim-mcp-server

Add this to your vimrc or run it manually. Changes take effect the next time Vim is started.

Generate the help tags with:

:helptags ~/path/to/vim-mcp-server/doc

License

MIT

Comments

Markdown supported

New to MCP?

From what the protocol is to installing your first server, these answers cover most first questions.

An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.