Skip to main content
Glama

find_line

Search for specific text within a file to locate matching lines and their positions. This tool helps identify content by returning line numbers and full text for matches.

Instructions

Find lines that match provided text in the current file.

Args: search_text (str): Text to search for in the file

Returns: dict: Matching lines with their line numbers, and full text

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
search_textYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for the 'find_line' MCP tool. It searches the current file for lines containing the specified search_text and returns a list of matching lines with their 1-based line numbers and full line content.
    async def find_line(
        search_text: str,
    ) -> Dict[str, Any]:
        """
        Find lines that match provided text in the current file.
    
        Args:
            search_text (str): Text to search for in the file
    
        Returns:
            dict: Matching lines with their line numbers, and full text
        """
        if self.current_file_path is None:
            return {"error": "No file path is set. Use set_file first."}
    
        try:
            with open(self.current_file_path, "r", encoding="utf-8") as file:
                lines = file.readlines()
    
            matches = []
            for i, line in enumerate(lines, start=1):
                if search_text in line:
                    matches.append([i, line])
    
            result = {
                "status": "success",
                "matches": matches,
                "total_matches": len(matches),
            }
    
            return result
    
        except Exception as e:
            return {"error": f"Error searching file: {str(e)}"}
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It states the tool finds matching lines but does not disclose behavioral traits such as case sensitivity, regex support, search scope (e.g., whole file vs. visible portion), or performance considerations (e.g., large file handling). The description is minimal beyond the basic operation.

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 and front-loaded: the first sentence states the core purpose, followed by structured Args and Returns sections. Every sentence earns its place with no redundant information, making it efficient and easy to parse.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's low complexity (one parameter) and the presence of an output schema (which covers return values), the description is mostly complete. It explains what the tool does and the parameter, but lacks behavioral details (e.g., search behavior) that would be helpful despite the output schema.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage (schema has no descriptions), the description must compensate. It adds meaning by specifying that 'search_text' is 'Text to search for in the file', clarifying the parameter's purpose. However, it does not detail constraints (e.g., length, special characters) or examples, leaving some gaps.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Find lines that match provided text') and resource ('in the current file'), distinguishing it from siblings like 'find_function' (which likely searches for functions) and 'read' (which reads the entire file). The verb+resource combination is precise and unambiguous.

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

Usage Guidelines3/5

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

The description implies usage for text matching in a file, but does not explicitly state when to use this tool versus alternatives like 'find_function' (for functions) or 'skim' (purpose unclear). No exclusions or prerequisites are mentioned, leaving the agent to infer context from tool 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

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/danielpodrazka/editor-mcp'

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