Skip to main content
Glama
laktek
by laktek

get_current_buffer

Retrieve the currently active Neovim buffer content to enable real-time editor awareness and direct in-editor updates through MCP integration.

Instructions

Get the currently active buffer in Neovim

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Core handler function that connects to a Neovim instance in the current directory and retrieves the path and content of the currently active buffer.
    export async function getCurrentBuffer() {
      const instances = await getNvimInstancesInCwd();
    
      if (instances.length === 0) {
        return null;
      }
    
      // Use the first instance found
      const { nvim } = instances[0];
    
      try {
        const currentBuf = await nvim.buffer;
        const bufName = await currentBuf.name;
        const lines = await currentBuf.lines;
        const content = lines.join("\n");
    
        return {
          path: bufName,
          content,
        };
      } catch (error) {
        throw error;
      }
    }
  • index.js:123-130 (registration)
    Registration of the 'get_current_buffer' tool in the MCP server's list of tools, including its name, description, and input schema (no parameters required).
    {
      name: "get_current_buffer",
      description: "Get the currently active buffer in Neovim",
      inputSchema: {
        type: "object",
        properties: {},
      },
    },
  • Dispatch handler in the MCP CallToolRequestSchema that invokes getCurrentBuffer() and formats the response as MCP tool content.
    if (name === "get_current_buffer") {
      const current = await getCurrentBuffer();
      if (!current) {
        return {
          content: [
            {
              type: "text",
              text: "No Neovim instance found in current directory",
            },
          ],
        };
      }
    
      return {
        content: [
          {
            type: "text",
            text: `Current buffer: ${current.path}\n\n${current.content}`,
          },
        ],
      };
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool retrieves the active buffer but doesn't describe what happens if no buffer is active, the format of the return value (e.g., buffer ID, name, content), or any error conditions. This leaves significant gaps in understanding the tool's behavior beyond its basic purpose.

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's front-loaded with the core action and resource, making it easy to parse quickly. Every word contributes directly to understanding the tool's purpose without redundancy or fluff.

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 the tool's simplicity (0 parameters, no annotations, no output schema), the description is minimal but incomplete. It doesn't address behavioral aspects like return format, error handling, or how it interacts with sibling tools. For a tool in a Neovim context with multiple buffer-related siblings, more context is needed to ensure proper usage.

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

Parameters4/5

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

The tool has 0 parameters, and the input schema has 100% description coverage (though empty). The description doesn't need to add parameter details, so it appropriately focuses on the tool's purpose. A baseline of 4 is applied since no parameters exist, and the description doesn't introduce unnecessary complexity.

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 the resource ('the currently active buffer in Neovim'), making the purpose immediately understandable. However, it doesn't explicitly distinguish this tool from sibling tools like 'get_buffer_content' or 'list_nvim_buffers', which also retrieve buffer information but with different scopes or outputs.

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. For example, it doesn't clarify if this should be used instead of 'list_nvim_buffers' for retrieving only the active buffer, or if it's a prerequisite for tools like 'update_buffer'. 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