Skip to main content
Glama

vim_grep

Perform project-wide searches using vimgrep and populate the quickfix list for efficient navigation. Specify search patterns and file patterns to locate content in codebases quickly.

Instructions

Project-wide search using vimgrep with quickfix list

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filePatternNoFile pattern to search in (default: **/* for all files)
patternYesSearch pattern to grep for

Implementation Reference

  • Core handler function that executes vimgrep in Neovim, retrieves quickfix list, and formats search results for the vim_grep tool.
    public async grepInProject(pattern: string, filePattern: string = '**/*'): Promise<string> {
      if (!pattern || pattern.trim().length === 0) {
        throw new NeovimValidationError('Grep pattern cannot be empty');
      }
      
      try {
        const nvim = await this.connect();
        
        // Use vimgrep for internal searching
        const command = `vimgrep /${pattern}/ ${filePattern}`;
        await nvim.command(command);
        
        // Get quickfix list
        const qflist = await nvim.eval('getqflist()');
        const results = qflist as Array<{ filename: string; lnum: number; text: string }>;
        
        if (results.length === 0) {
          return `No matches found for: ${pattern}`;
        }
        
        const summary = results.slice(0, 10).map(item => 
          `${item.filename}:${item.lnum}: ${item.text.trim()}`
        ).join('\n');
        
        const totalText = results.length > 10 ? `\n... and ${results.length - 10} more matches` : '';
        return `Found ${results.length} matches for: ${pattern}\n${summary}${totalText}`;
      } catch (error) {
        console.error('Error in grep:', error);
        throw new NeovimCommandError(`grep ${pattern}`, error instanceof Error ? error.message : 'Unknown error');
      }
    }
  • src/index.ts:437-462 (registration)
    Registers the vim_grep tool using server.tool(), including description, input schema, and thin async handler that delegates to neovimManager.grepInProject and formats MCP response.
    server.tool(
      "vim_grep",
      "Project-wide search using vimgrep with quickfix list",
      {
        pattern: z.string().describe("Search pattern to grep for"),
        filePattern: z.string().optional().describe("File pattern to search in (default: **/* for all files)")
      },
      async ({ pattern, filePattern = "**/*" }) => {
        try {
          const result = await neovimManager.grepInProject(pattern, filePattern);
          return {
            content: [{
              type: "text",
              text: result
            }]
          };
        } catch (error) {
          return {
            content: [{
              type: "text",
              text: error instanceof Error ? error.message : 'Error in grep search'
            }]
          };
        }
      }
    );
  • Zod input schema definition for the vim_grep tool parameters.
    {
      pattern: z.string().describe("Search pattern to grep for"),
      filePattern: z.string().optional().describe("File pattern to search in (default: **/* for all files)")
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions the quickfix list output, which hints at a read-only operation with structured results, but doesn't clarify permissions, side effects, error handling, or output format details. This is inadequate for a search tool with zero annotation coverage.

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, efficient sentence with zero waste—it directly states the tool's purpose and method. It's appropriately sized and front-loaded, making it easy for an agent to parse quickly.

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 no annotations and no output schema, the description is incomplete. It mentions the quickfix list but doesn't explain what that entails (e.g., structured results, navigation capabilities). For a search tool in a complex environment like Vim, more context on behavior and output is needed to guide the agent effectively.

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 fully documents both parameters. The description adds no additional parameter semantics beyond implying project-wide scope, which is already suggested by the schema's default filePattern. Baseline 3 is appropriate as the schema handles parameter documentation.

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 performs 'Project-wide search using vimgrep with quickfix list', which specifies the verb (search), resource (project files), and method (vimgrep with quickfix). It distinguishes from siblings like 'vim_search' by mentioning the vimgrep method and quickfix output, though not explicitly contrasting them.

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_search' or other sibling tools. It mentions the method (vimgrep) but doesn't explain when this is preferable or what contexts it's designed for, leaving the agent to infer usage.

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