Skip to main content
Glama
laktek
by laktek

list_nvim_buffers

View all open Neovim buffers in the current directory to manage editing sessions and track active files.

Instructions

List all open buffers in Neovim instances running in the current directory

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Core implementation of listing open buffers: connects to Neovim instances in current dir, fetches listed buffers with path, bufnr, cwd.
    export async function listOpenBuffers() {
      const instances = await getNvimInstancesInCwd();
      const allBuffers = [];
    
      for (const { nvim, cwd } of instances) {
        try {
          const buffers = await nvim.buffers;
    
          for (const buf of buffers) {
            const listed = await nvim.call("buflisted", [buf.id]);
            if (listed) {
              const name = await buf.name;
              if (name) {
                allBuffers.push({
                  path: name,
                  bufnr: buf.id,
                  cwd,
                });
              }
            }
          }
        } catch (error) {
          console.error("Error listing buffers:", error.message);
        }
      }
    
      return allBuffers;
    }
  • MCP CallToolRequestSchema handler: invokes listOpenBuffers() and returns JSON-formatted buffer list as text content.
    if (name === "list_nvim_buffers") {
      const buffers = await listOpenBuffers();
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify(buffers, null, 2),
          },
        ],
      };
    }
  • index.js:114-122 (registration)
    Tool registration in ListToolsRequestSchema response, including name, description, and empty input schema.
    {
      name: "list_nvim_buffers",
      description:
        "List all open buffers in Neovim instances running in the current directory",
      inputSchema: {
        type: "object",
        properties: {},
      },
    },
  • Input schema definition for the list_nvim_buffers tool (no parameters required).
    inputSchema: {
      type: "object",
      properties: {},
    },
  • Helper function to find and connect to Neovim instances running in the current working directory, used by listOpenBuffers.
    export async function getNvimInstancesInCwd() {
      const cwd = process.cwd();
      const sockets = await findNvimSockets();
      const instances = [];
    
      for (const socketPath of sockets) {
        try {
          const nvim = attach({ socket: socketPath });
          const instanceCwd = await nvim.call("getcwd", []);
    
          // Check if this nvim instance is in our current directory
          if (instanceCwd === cwd || instanceCwd.startsWith(cwd + "/")) {
            instances.push({
              socket: socketPath,
              cwd: instanceCwd,
              nvim,
            });
          }
          // Note: We don't quit non-matching instances, just skip them
        } catch (error) {
          // Failed to connect to this socket, skip it
          continue;
        }
      }
    
      return instances;
    }
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 lists buffers, but doesn't describe what the output looks like (e.g., format, structure), whether it includes hidden buffers, how it handles multiple Neovim instances, or any error conditions. For a tool with zero annotation coverage, this leaves significant behavioral gaps.

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 that efficiently conveys the tool's purpose and scope without any redundant words. It is front-loaded with the core action ('List all open buffers') and appropriately sized for its simplicity.

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 lack of annotations and output schema, the description is incomplete for effective tool use. It doesn't explain the return format (e.g., list of buffer IDs, names, or states), how to interpret the output, or any limitations (e.g., buffers in non-current directories). For a tool with no structured output documentation, the description should provide more context about what the agent can expect.

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 schema description coverage is 100% (since there are no parameters to describe). The description doesn't need to add parameter semantics, so it meets the baseline expectation. No additional parameter information is required or provided.

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 ('List') and resource ('all open buffers in Neovim instances'), making the purpose immediately understandable. It specifies the scope ('running in the current directory'), which helps distinguish it from generic buffer listing tools. However, it doesn't explicitly differentiate from sibling tools like 'get_current_buffer' or 'reload_all_buffers' in terms of specific use cases.

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 minimal guidance on when to use this tool. It mentions 'Neovim instances running in the current directory', which implies a context, but doesn't specify when to choose this over alternatives like 'get_current_buffer' (for a single buffer) or 'reload_all_buffers' (for refreshing buffers). No explicit when-not-to-use or prerequisite information is provided.

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