get_buffer_content
Retrieve content from Neovim buffers by specifying file paths to access and work with in-editor text directly through the MCP server.
Instructions
Get the content of a specific buffer by path
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | The file path of the buffer |
Implementation Reference
- lib/nvim-operations.js:127-149 (handler)The core handler function that retrieves the content of a specific Neovim buffer by its path. It iterates through Neovim instances and their buffers to find a matching path and returns the joined lines as a string.export async function getBufferContent(bufferPath) { 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 = await buf.lines; const content = lines.join("\n"); return content; } } } catch (error) { console.error("Error getting buffer content:", error.message); } } throw new Error(`Buffer not found: ${bufferPath}`); }
- index.js:131-144 (schema)The input schema definition for the 'get_buffer_content' tool, specifying a required 'path' string parameter.{ name: "get_buffer_content", description: "Get the content of a specific buffer by path", inputSchema: { type: "object", properties: { path: { type: "string", description: "The file path of the buffer", }, }, required: ["path"], }, },
- index.js:250-259 (registration)The registration and dispatch logic in the CallToolRequestSchema handler that invokes getBufferContent for the 'get_buffer_content' tool name and formats the response.if (name === "get_buffer_content") { const content = await getBufferContent(args.path); return { content: [ { type: "text", text: content, }, ], };