Skip to main content
Glama

get_buffer_content

Retrieve the content of a Neovim buffer using its file path to enable real-time editor awareness and content access.

Instructions

Get the content of a specific buffer by path

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesThe file path of the buffer

Implementation Reference

  • Core implementation of the getBufferContent function that searches Neovim instances for the buffer by path and returns its content.
    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}`); }
  • Input schema for the 'get_buffer_content' tool defining the required 'path' parameter.
    inputSchema: { type: "object", properties: { path: { type: "string", description: "The file path of the buffer", }, }, required: ["path"], },
  • index.js:130-143 (registration)
    Tool registration entry in the MCP server's ListTools response.
    { 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"], }, },
  • MCP server request handler that dispatches 'get_buffer_content' tool calls to the getBufferContent function.
    if (name === "get_buffer_content") { const content = await getBufferContent(args.path); return { content: [ { type: "text", text: content, }, ], }; }
  • index.js:14-18 (registration)
    Import of the getBufferContent handler from lib/nvim-operations.js.
    getBufferContent, updateBuffer, reloadBuffer, reloadAllBuffers, } from "./lib/nvim-operations.js";

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