Skip to main content
Glama

select

Select text lines in a file by specifying start and end positions for editing operations. This tool prepares content for subsequent modifications within the editor-mcp server.

Instructions

Select lines from for subsequent overwrite operation.

Args: start (int): Start line number (1-based) end (int): End line number (1-based)

Returns: dict: status, lines, start, end, id, line_count, message

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
startYes
endYes

Implementation Reference

  • The main handler function for the 'select' MCP tool. It validates the line range, reads the current file, computes a unique ID for the selected content using calculate_id, stores the selection in instance variables, and returns details including the lines, ID, and status for use in subsequent overwrite operations.
    async def select( start: int, end: int, ) -> Dict[str, Any]: """ Select lines from for subsequent overwrite operation. Args: start (int): Start line number (1-based) end (int): End line number (1-based) Returns: dict: status, lines, start, end, id, line_count, message """ 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() if start < 1: return {"error": "start must be at least 1."} if end > len(lines): end = len(lines) if start > end: return {"error": "start cannot be greater than end."} if end - start + 1 > self.max_select_lines: return { "error": f"Cannot select more than {self.max_select_lines} lines at once (attempted {end - start + 1} lines)." } selected_lines = lines[start - 1 : end] text = "".join(selected_lines) current_id = calculate_id(text, start, end) self.selected_start = start self.selected_end = end self.selected_id = current_id # Convert selected lines to a list without line numbers lines_content = [line.rstrip() for line in selected_lines] result = { "status": "success", "lines": lines_content, "start": start, "end": end, "id": current_id, "line_count": len(selected_lines), "message": f"Selected lines {start} to {end} for editing.", } return result except Exception as e: return {"error": f"Error selecting lines: {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