Skip to main content
Glama

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";

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