Skip to main content
Glama
laktek
by laktek

update_buffer

Modify Neovim buffer content directly from the MCP server to reflect changes immediately in the editor.

Instructions

Update the content of a buffer in Neovim. Changes appear immediately in the editor.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesThe file path of the buffer to update
contentYesThe new content for the buffer

Implementation Reference

  • The core handler function that locates the Neovim buffer by path across instances and updates its content by setting new lines.
    export async function updateBuffer(bufferPath, newContent) {
      const instances = await getNvimInstancesInCwd();
    
      for (const { nvim } of instances) {
        try {
          const buffers = await nvim.buffers;
    
          for (const buf of buffers) {
            const name = await buf.name;
            if (name === bufferPath) {
              const lines = newContent.split("\n");
              await buf.setLines(lines, { start: 0, end: -1 });
    
              return { success: true, path: bufferPath };
            }
          }
        } catch (error) {
          console.error("Error updating buffer:", error.message);
        }
      }
    
      throw new Error(`Buffer not found: ${bufferPath}`);
    }
  • The tool schema definition provided in the ListTools response, specifying the input parameters 'path' and 'content'.
    {
      name: "update_buffer",
      description:
        "Update the content of a buffer in Neovim. Changes appear immediately in the editor.",
      inputSchema: {
        type: "object",
        properties: {
          path: {
            type: "string",
            description: "The file path of the buffer to update",
          },
          content: {
            type: "string",
            description: "The new content for the buffer",
          },
        },
        required: ["path", "content"],
      },
    },
  • index.js:262-271 (registration)
    The registration and dispatch logic within the CallToolRequestHandler that matches the tool name and invokes the updateBuffer function.
    if (name === "update_buffer") {
      const result = await updateBuffer(args.path, args.content);
      return {
        content: [
          {
            type: "text",
            text: `Successfully updated buffer: ${result.path}`,
          },
        ],
      };
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden. It states the tool updates buffer content and changes appear immediately, which implies mutation, but doesn't disclose critical behavioral traits like whether it overwrites existing content entirely, requires specific permissions, handles unsaved changes, or what happens on errors. The description is minimal beyond the basic action.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is two concise sentences with zero waste. It's front-loaded with the core purpose and includes a useful behavioral note about immediate changes. Every sentence earns its place efficiently.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given this is a mutation tool with no annotations and no output schema, the description is incomplete. It lacks details on error handling, return values, side effects (e.g., impact on undo history), and how it interacts with other tools like reload_buffer. For a tool that modifies editor state, more context is needed.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents both parameters (path and content) fully. The description doesn't add any meaning beyond what the schema provides, such as format details or usage context for the parameters. Baseline 3 is appropriate when schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Update the content of a buffer') and resource ('a buffer in Neovim'), with the immediate effect ('Changes appear immediately in the editor'). It distinguishes from siblings like get_buffer_content (read-only) and reload_buffer (reloads from disk).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage when you want to modify buffer content directly in Neovim, but it doesn't explicitly state when to use this vs. alternatives like reload_buffer (for disk-based updates) or open_file (for opening new files). No exclusions or prerequisites are mentioned.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/laktek/nvim-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server