Skip to main content
Glama

get_edit_preview

Preview code changes before applying them to verify edits in Python files using semantic analysis.

Instructions

Preview changes a code action would make.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYes
lineYes
columnYes
action_indexYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The get_edit_preview tool handler that retrieves code actions and previews their edits.
    async def get_edit_preview(
        file_path: str, line: int, column: int, action_index: int
    ) -> str:
        """Preview changes a code action would make."""
        client = _get_client()
    
        path = Path(file_path).resolve()
        if not path.exists():
            return _error(f"File not found: {file_path}")
    
        try:
            await client.open_document(path)
    
            import asyncio
            await asyncio.sleep(0.3)
    
            diagnostics = client.get_diagnostics(path)
            relevant_diags = [
                d for d in diagnostics
                if d.range.start.line <= line - 1 <= d.range.end.line
            ]
    
            actions = await client.get_code_actions(
                path, line - 1, column - 1, line - 1, column, relevant_diags
            )
    
            if not actions:
                return _not_found(f"No actions at {path.name}:{line}:{column}")
    
            if action_index < 1 or action_index > len(actions):
                return _error(f"Invalid index. Choose 1-{len(actions)}")
    
            action = actions[action_index - 1]
    
            if not action.edit:
                return _error(f"Action '{action.title}' has no edits")
    
            all_edits = action.edit.get_all_edits()
            total_edits = sum(len(e) for e in all_edits.values())
    
            preview = []
            for uri, edits in all_edits.items():
                edit_path = _uri_to_path(uri)
                for e in edits:
                    text_preview = e.new_text[:80].replace("\n", "\\n") if e.new_text else "(delete)"
                    preview.append({
                        "file": edit_path.name,
                        "line": e.range.start.line + 1,
                        "column": e.range.start.character + 1,
                        "new_text": text_preview
                    })
    
            return _ok({
                "action": action.title,
                "edits_count": total_edits,
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. While 'preview' implies a read-only operation, the description fails to specify what the output contains (e.g., diff format, edit ranges, full file content) or error conditions when invalid coordinates are supplied.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The single sentence is efficient and front-loaded, but the tool is underspecified for its complexity. With zero schema descriptions and no annotations, the brevity represents under-documentation rather than effective conciseness.

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 four required parameters with zero schema coverage and no annotations, the description is inadequate. While an output schema exists (reducing the need to describe returns), the complete absence of parameter semantics and workflow context leaves critical gaps.

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

Parameters1/5

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

Schema coverage is 0% and the description completely omits any discussion of the four parameters. It does not explain that 'action_index' references a previous code action result, nor clarify coordinate systems (0-indexed vs 1-indexed) for line/column.

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 core function using specific verb ('Preview') and resource ('changes'), and implicitly distinguishes itself from sibling 'apply_code_action' through the 'preview' semantics. However, it assumes familiarity with 'code action' terminology without defining it.

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?

No explicit guidance on when to use this tool versus alternatives, nor does it mention the prerequisite workflow (e.g., that 'action_index' must likely be obtained from 'get_code_actions' first). The user must infer usage from parameter 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/qinsehm1128/mcp-ty'

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