Skip to main content
Glama

nvim-ui-mcp

Playwright for Neovim agents.

An MCP server that lets AI agents see, act on, and verify the real, rendered Neovim UI — not just buffer text and API state.

License: MIT Node Neovim npm


Table of Contents

Related MCP server: visual-ui-debug-agent-mcp

Requirements

Installation

npm install -g nvim-ui-mcp

MCP Client Configuration

claude mcp add nvim-ui -- npx -y nvim-ui-mcp
{
  "mcpServers": {
    "nvim-ui": {
      "command": "npx",
      "args": ["-y", "nvim-ui-mcp"]
    }
  }
}

Tools

Exactly 8 tools — deliberately not a generic nvim_* API wrapper.

Usage

The loop is observe → act → wait → observe:

// 1. Start an isolated instance
nvim_launch  { "clean": true, "rows": 24, "cols": 80 }
//          → { "sessionId": "nvim-1", ... }

// 2. Look at the real screen
nvim_observe { "sessionId": "nvim-1" }
//          → { "screen": "…24 rows of text…", "cursor": {...}, "mode": {...} }

// 3. Act
nvim_input   { "sessionId": "nvim-1", "keys": "ihello world<Esc>" }

// 4. Synchronize before looking again — see Gotchas below
nvim_wait    { "sessionId": "nvim-1", "condition": "contains", "text": "hello world" }

// 5. Verify, cheaply
nvim_observe_diff { "sessionId": "nvim-1" }
//          → { "changed": true, "rowChanges": [{ "row": 0, "after": "hello world…" }] }

nvim_close   { "sessionId": "nvim-1" }

Gotchas

nvim_input and nvim_command return as soon as Neovim accepts the request — not when the screen has repainted. Observing immediately races the redraw.

contains / not-contains test current screen content, so they work whether the redraw lands before or after the wait started. redraw, screen-change, and idle are edge-triggered and can miss a repaint that already happened — use idle only when you cannot predict the resulting text.

Neovim composites floats into a single grid, so popup and float content is already in the rendered text. The floats array from nvim_observe reports each float's row, col, width, and height — how you tell a completion popup from buffer text at the same coordinates.

Attach Mode

nvim --listen /tmp/nvim.sock
nvim_attach { "address": "/tmp/nvim.sock" }

The instance belongs to you, so nvim_close refuses it. Neovim sizes the screen to the smallest attached UI, so requesting a size can shrink your own view.

Development

npm install
npm test          # unit + integration, needs a real nvim binary
npm run typecheck
npm run lint
npm run build

See DESIGN.md for the architecture, the UI event pipeline, and the known gaps.

License

MIT

Available Tools

8 tools
nvim_attachAttach to NeovimA

Attach as an additional UI to an already-running Neovim instance. The instance belongs to the user: nvim_close will refuse to terminate it. Note that Neovim sizes the screen to the smallest attached UI, so the requested size can shrink what the user sees.

Inputs: address (required), cols, rows. Returns: cols, mode, rows, address, +1 more

nvim_closeClose a Neovim sessionA

Terminate a Neovim instance this server launched and release its session. Refuses attach-mode sessions: that instance belongs to the user, and attach sessions are released when the server shuts down.

Inputs: sessionId (required). Returns: closed, sessionId

nvim_commandRun an Ex commandA

Execute an Ex command. A command that Neovim rejects comes back as an error result with Neovim's own message. Like nvim_input, this does not wait for the screen to settle.

Inputs: command (required), sessionId (required). Returns: ok, command, sessionId

nvim_inputSend input to NeovimA

Send a key sequence to Neovim. Returns as soon as the keys are queued, not when the screen has updated: follow with nvim_wait before observing, otherwise the observation races the redraw.

Inputs: keys (required), sessionId (required). Returns: keys, sessionId, bytesWritten

nvim_launchLaunch NeovimA

Launch an isolated, disposable Neovim instance owned by this server and attach to it as a UI client. Returns a session id for the other tools. Use nvim_close when finished.

Inputs: cwd, args, cols, file, +4 more. Returns: pid, cols, mode, rows, +1 more

nvim_observeObserve NeovimA

Return the rendered Neovim screen as plain text rows, plus cursor, mode, size, current buffer/window and floating-window geometry. The screen is the source of truth; the metadata explains it. Rows are plain text with no cursor markers or line numbers, so substring matching is reliable. Resets the nvim_observe_diff baseline.

Inputs: sessionId (required). Returns: cols, mode, rows, buffer, +5 more

nvim_observe_diffObserve Neovim diffA

Return only what changed since the last observation: changed screen rows with their before/after text, plus cursor, mode and size deltas. Much smaller than a full nvim_observe for verifying a single action. Resets the baseline.

Inputs: sessionId (required). Returns: mode, size, cursor, changed, +2 more

nvim_waitWait for NeovimA

Block until a screen condition holds, so an observation is not raced against the redraw it is meant to see. On timeout the error includes the screen as it was, so a failed wait is diagnosable.

Inputs: condition (required), sessionId (required), text, idleMs, +1 more. Returns: waitedMs, condition, sessionId

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.4/5.0

    Scored across 8 tools

    Disambiguation5/5

    Each tool serves a distinct purpose: launch/attach manage instances, observe/observe_diff provide screen state at different granularities, input/command send different interaction types, wait synchronizes, and close cleans up. There is no meaningful overlap or ambiguity between tools.

    Naming Consistency4/5

    All tools share the nvim_ prefix and use lowercase snake_case, creating a clear family identity. Most names are single verbs (launch, attach, observe, wait, close) while input and command are nouns, and observe_diff is a compound, but the overall pattern remains predictable and consistent.

    Tool Count5/5

    Eight tools is a well-scoped size for a UI-control server, covering the full interaction lifecycle without unnecessary bloat. Each tool earns its place and the count is comfortably within the ideal 3-15 range.

    Completeness5/5

    The toolset covers the complete lifecycle: starting/attaching to a Neovim instance, observing the screen (full and delta), sending input via keys and commands, waiting for conditions, and closing. The only potential gap would be direct buffer/filer access, but the screen-as-source-of-truth design makes that unnecessary.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers