Skip to main content
Glama
laktek
by laktek

open_file

Open files in Neovim for editing. Use this tool to access existing files or newly created files by providing the file path.

Instructions

Open a file in Neovim. Use this to open newly created files or existing files for editing.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesThe file path to open (can be absolute or relative to current directory)

Implementation Reference

  • Core implementation of the open_file tool: finds Neovim instance, converts path to absolute, and executes the 'edit' command to open the file.
    export async function openFile(filePath) {
      const instances = await getNvimInstancesInCwd();
    
      if (instances.length === 0) {
        throw new Error("No Neovim instance found in current directory");
      }
    
      // Use the first instance found
      const { nvim } = instances[0];
    
      try {
        // Convert to absolute path if relative
        const absolutePath = path.isAbsolute(filePath)
          ? filePath
          : path.join(process.cwd(), filePath);
    
        // Open the file in nvim
        await nvim.command(`edit ${absolutePath}`);
    
        return {
          success: true,
          path: absolutePath,
        };
      } catch (error) {
        throw new Error(`Failed to open file: ${error.message}`);
      }
    }
  • Input schema definition for the 'open_file' tool requiring a 'path' parameter.
    name: "open_file",
    description:
      "Open a file in Neovim. Use this to open newly created files or existing files for editing.",
    inputSchema: {
      type: "object",
      properties: {
        path: {
          type: "string",
          description:
            "The file path to open (can be absolute or relative to current directory)",
        },
      },
      required: ["path"],
    },
  • index.js:188-203 (registration)
    Registration of the 'open_file' tool in the ListToolsRequestSchema handler, including name, description, and schema.
    {
      name: "open_file",
      description:
        "Open a file in Neovim. Use this to open newly created files or existing files for editing.",
      inputSchema: {
        type: "object",
        properties: {
          path: {
            type: "string",
            description:
              "The file path to open (can be absolute or relative to current directory)",
          },
        },
        required: ["path"],
      },
    },
  • index.js:298-308 (registration)
    Tool call dispatcher in CallToolRequestSchema handler that invokes the openFile function for 'open_file' tool.
    if (name === "open_file") {
      const result = await openFile(args.path);
      return {
        content: [
          {
            type: "text",
            text: `Successfully opened file in Neovim: ${result.path}`,
          },
        ],
      };
    }
  • Import of the openFile handler from lib/nvim-operations.js.
      openFile,
    } from "./lib/nvim-operations.js";
Behavior3/5

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

With no annotations provided, the description carries the full burden. It implies a write operation (opening for editing) but doesn't disclose behavioral traits like whether it requires file permissions, if it creates non-existent files, or potential side effects. It adds basic context but lacks detail on mutation 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 appropriately sized with two sentences that are front-loaded and efficient. Every sentence earns its place by stating the purpose and usage context without waste.

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 moderate complexity (file operation with potential mutation), no annotations, and no output schema, the description is minimally adequate. It covers basic purpose and usage but lacks details on behavior, error handling, or return values, leaving 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?

Schema description coverage is 100%, so the schema already documents the 'path' parameter fully. The description doesn't add any meaning beyond what the schema provides, such as examples or edge cases, meeting the baseline for high coverage.

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 ('Open a file') and resource ('in Neovim'), specifying it works for both newly created and existing files. It doesn't explicitly differentiate from sibling tools like 'update_buffer' or 'reload_buffer', which prevents a perfect score.

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

Usage Guidelines4/5

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

The description provides clear context on when to use this tool ('to open newly created files or existing files for editing'), but it doesn't specify when not to use it or mention alternatives among sibling tools like 'reload_buffer' for already open files.

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