Skip to main content
Glama
laktek
by laktek

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
NameRequiredDescriptionDefault
pathYesThe file path of the buffer

Implementation Reference

  • 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}`);
    }
  • 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,
          },
        ],
      };
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool gets content but doesn't describe what 'content' entails (e.g., text, metadata), potential errors (e.g., if the path doesn't exist), or side effects (e.g., whether it opens the buffer). This leaves significant gaps in understanding the tool's behavior.

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 a single, clear sentence with zero waste—it directly states the tool's purpose without unnecessary words. It's appropriately sized and front-loaded, making it easy to understand at a glance.

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

Completeness3/5

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

Given the tool's low complexity (one parameter, no output schema, no annotations), the description is minimally adequate. It covers the basic purpose but lacks details on usage context, behavioral traits, and output, which are needed for full completeness. It meets the minimum viable standard but has clear gaps.

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?

The schema description coverage is 100%, with the single parameter 'path' documented as 'The file path of the buffer'. The description adds no additional meaning beyond this, such as path format examples or constraints. Since the schema does the heavy lifting, the baseline score of 3 is appropriate.

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

Purpose4/5

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

The description clearly states the action ('Get') and target resource ('content of a specific buffer by path'), making the purpose understandable. However, it doesn't differentiate from sibling tools like 'get_current_buffer' or 'list_nvim_buffers', which also retrieve buffer information, so it doesn't reach the highest clarity level.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives like 'get_current_buffer' (which might get content without specifying a path) or 'list_nvim_buffers' (which lists buffers rather than getting content). There's no mention of prerequisites, exclusions, or specific contexts for usage.

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