Skip to main content
Glama

update_buffer

Modify Neovim buffer content directly from Claude to reflect changes instantly 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 handler function that updates the content of a Neovim buffer by path using the neovim API.
    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}`); }
  • Tool schema definition including input schema for path and content parameters.
    { 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:245-255 (registration)
    Registration and dispatch logic in the CallToolRequest handler that 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}`, }, ], }; }

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