Skip to main content
Glama

vim_macro

Record, stop, and play Neovim macros using specific registers and counts to automate repetitive text editing tasks in your workflow.

Instructions

Record, stop, and play Neovim macros

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionYesAction to perform with macros
countNoNumber of times to play macro (default: 1)
registerNoRegister to record/play macro (a-z, required for record/play)

Implementation Reference

  • Core handler implementation for vim_macro tool. Handles 'record', 'stop', and 'play' actions by sending appropriate Neovim input sequences (q<register>, q, @<register>).
    public async manageMacro(action: string, register?: string, count: number = 1): Promise<string> {
      try {
        const nvim = await this.connect();
        
        switch (action) {
          case 'record':
            if (!register || register.length !== 1 || !/[a-z]/.test(register)) {
              throw new NeovimValidationError('Register must be a single letter a-z for recording');
            }
            await nvim.input(`q${register}`);
            return `Started recording macro in register '${register}'`;
            
          case 'stop':
            await nvim.input('q');
            return 'Stopped recording macro';
            
          case 'play':
            if (!register || register.length !== 1 || !/[a-z]/.test(register)) {
              throw new NeovimValidationError('Register must be a single letter a-z for playing');
            }
            const playCommand = count > 1 ? `${count}@${register}` : `@${register}`;
            await nvim.input(playCommand);
            return `Played macro from register '${register}' ${count} time(s)`;
            
          default:
            throw new NeovimValidationError(`Unknown macro action: ${action}`);
        }
      } catch (error) {
        if (error instanceof NeovimValidationError) {
          throw error;
        }
        console.error('Error managing macro:', error);
        throw new NeovimCommandError(`macro ${action}`, error instanceof Error ? error.message : 'Unknown error');
      }
    }
  • src/index.ts:481-507 (registration)
    Registers the vim_macro tool with MCP server, including schema definition and thin handler delegating to neovimManager.manageMacro.
    server.tool(
      "vim_macro",
      "Record, stop, and play Neovim macros",
      {
        action: z.enum(["record", "stop", "play"]).describe("Action to perform with macros"),
        register: z.string().optional().describe("Register to record/play macro (a-z, required for record/play)"),
        count: z.number().optional().describe("Number of times to play macro (default: 1)")
      },
      async ({ action, register, count = 1 }) => {
        try {
          const result = await neovimManager.manageMacro(action, register, count);
          return {
            content: [{
              type: "text",
              text: result
            }]
          };
        } catch (error) {
          return {
            content: [{
              type: "text",
              text: error instanceof Error ? error.message : 'Error managing macro'
            }]
          };
        }
      }
    );
  • Zod schema defining input parameters for vim_macro: action (enum: record/stop/play), optional register (string), optional count (number).
    {
      action: z.enum(["record", "stop", "play"]).describe("Action to perform with macros"),
      register: z.string().optional().describe("Register to record/play macro (a-z, required for record/play)"),
      count: z.number().optional().describe("Number of times to play macro (default: 1)")
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 lists the actions but doesn't explain what happens during recording (e.g., overwrites existing macros), stopping (e.g., saves to register), or playing (e.g., executes keystrokes). It also omits details like error handling, side effects, or any constraints, which are critical for a tool that modifies editor state.

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 lists all key actions without any fluff. Every word earns its place by directly stating the tool's core functionality, making it efficient and easy to scan.

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 complexity (manipulating macros in an editor) and the lack of annotations and output schema, the description is insufficient. It doesn't cover behavioral aspects like what 'record' entails (e.g., starts capturing keystrokes), how 'stop' works, or what 'play' returns (e.g., success/failure). For a tool with potential side effects, more context is needed to ensure safe and correct usage.

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 input schema has 100% description coverage, clearly documenting all three parameters with enums and defaults. The description adds no additional semantic context beyond what's in the schema, such as explaining interactions between parameters (e.g., 'count' only applies to 'play'). This meets the baseline score since the schema adequately covers parameter details.

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 tool's purpose with specific verbs ('record, stop, and play') and resource ('Neovim macros'), making it easy to understand what the tool does. However, it doesn't explicitly distinguish this tool from its sibling 'vim_register', which might also handle macro registers, leaving room for slight ambiguity in sibling differentiation.

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. It doesn't mention any prerequisites, context for choosing between actions, or how it relates to sibling tools like 'vim_register' or 'vim_command', leaving users to infer usage based on the action names alone.

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