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

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)}"}

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