Skip to main content
Glama

vim_buffer_save

Save the current buffer or to a specified filename directly within the MCP Neovim Server, streamlining text editing and file management workflows.

Instructions

Save current buffer or save to specific filename

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filenameNoOptional filename to save buffer to (defaults to current buffer's filename)

Implementation Reference

  • Core implementation of buffer saving logic in NeovimManager.saveBuffer method, which executes Neovim :write command
    public async saveBuffer(filename?: string): Promise<string> {
      try {
        const nvim = await this.connect();
        
        if (filename) {
          // Save with specific filename
          await nvim.command(`write ${filename}`);
          return `Buffer saved to: ${filename}`;
        } else {
          // Save current buffer
          const buffer = await nvim.buffer;
          const bufferName = await buffer.name;
          
          if (!bufferName) {
            throw new NeovimValidationError('Cannot save unnamed buffer without specifying filename');
          }
          
          await nvim.command('write');
          return `Buffer saved: ${bufferName}`;
        }
      } catch (error) {
        if (error instanceof NeovimValidationError) {
          throw error;
        }
        console.error('Error saving buffer:', error);
        throw new NeovimCommandError(`save ${filename || 'current buffer'}`, error instanceof Error ? error.message : 'Unknown error');
      }
    }
  • MCP tool handler function for vim_buffer_save that wraps neovimManager.saveBuffer and formats the response
    async ({ filename }) => {
      try {
        const result = await neovimManager.saveBuffer(filename);
        return {
          content: [{
            type: "text",
            text: result
          }]
        };
      } catch (error) {
        return {
          content: [{
            type: "text",
            text: error instanceof Error ? error.message : 'Error saving buffer'
          }]
        };
      }
    }
  • Zod input schema definition for the vim_buffer_save tool parameters
      filename: z.string().optional().describe("Optional filename to save buffer to (defaults to current buffer's filename)")
    },
  • src/index.ts:326-350 (registration)
    Registration of the vim_buffer_save tool with MCP server including name, description, schema, and handler
    server.tool(
      "vim_buffer_save",
      "Save current buffer or save to specific filename",
      {
        filename: z.string().optional().describe("Optional filename to save buffer to (defaults to current buffer's filename)")
      },
      async ({ filename }) => {
        try {
          const result = await neovimManager.saveBuffer(filename);
          return {
            content: [{
              type: "text",
              text: result
            }]
          };
        } catch (error) {
          return {
            content: [{
              type: "text",
              text: error instanceof Error ? error.message : 'Error saving buffer'
            }]
          };
        }
      }
    );
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 mentions saving but doesn't specify if this overwrites files, requires write permissions, handles errors (e.g., if filename is invalid), or confirms success. This leaves gaps in understanding the tool's behavior beyond the basic action.

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 extremely concise—a single, front-loaded sentence that efficiently conveys the core functionality without any wasted words. It directly addresses the tool's purpose in a clear and structured manner.

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 complexity of a file-saving operation with no annotations and no output schema, the description is incomplete. It doesn't cover behavioral aspects like error handling, permissions, or what happens on success/failure, which are crucial for an AI agent to use the tool correctly in a Vim context.

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 parameter 'filename' clearly documented in the schema as optional and defaulting to the current buffer's filename. The description adds minimal value by restating this but doesn't provide additional context like format requirements or examples beyond what the schema already covers.

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 verb 'save' and the resource 'current buffer' or 'specific filename', making the tool's purpose immediately understandable. It distinguishes between saving to the current buffer's filename versus a different filename, though it doesn't explicitly differentiate from sibling tools like vim_buffer or vim_edit.

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 vim_buffer (which might manage buffers) or vim_edit (which might create/edit files). It lacks context about prerequisites, such as needing an active buffer, or exclusions like not working on read-only 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

Related 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/bigcodegen/mcp-neovim-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server