Skip to main content
Glama
AbdessamadTzn

FastAPI Architect MCP

rename_symbol

Rename a symbol across all project files by specifying its exact location (file, line, column) and new name, updating all references consistently.

Instructions

Rename the symbol at the given position across all files in the project.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fileYes
lineYes
columnYes
new_nameYes

Implementation Reference

  • The main handler function for the 'rename_symbol' tool. Uses Jedi to find all references to a symbol, then renames them in-place across all project files.
    def rename_symbol(file: str, line: int, column: int, new_name: str) -> dict:
        """Rename the symbol at the given position across all files in the project."""
        script = jedi.Script(path=file, project=_project(file))
        refs = [r for r in script.get_references(line=line, column=column) if r.module_path is not None]
    
        changed_files: dict[str, list[str]] = {}
    
        for r in sorted(refs, key=lambda r: (str(r.module_path), r.line), reverse=True):
            path = str(r.module_path)
            if path not in changed_files:
                with open(path) as f:
                    changed_files[path] = f.readlines()
            lines = changed_files[path]
            col = r.column
            idx = r.line - 1
            lines[idx] = lines[idx][:col] + new_name + lines[idx][col + len(r.name):]
    
        for path, lines in changed_files.items():
            with open(path, "w") as f:
                f.writelines(lines)
    
        return {
            "renamed_to": new_name,
            "files_changed": len(changed_files),
            "references_updated": len(refs),
        }
  • The tool is registered via the @mcp.tool() decorator from FastMCP, which automatically registers 'rename_symbol' as an MCP tool.
    @mcp.tool()
  • Helper function '_project' used by rename_symbol to find the project root directory for Jedi's project context.
    def _project(file: str) -> jedi.Project:
        """Walk up from file to find the project root."""
        path = Path(file).resolve()
        for parent in [path.parent, *path.parents]:
            if any((parent / f).exists() for f in ("pyproject.toml", "requirements.txt", "setup.py")):
                return jedi.Project(path=str(parent))
        return jedi.Project(path=str(path.parent))
Behavior2/5

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

With no annotations, the description must convey behavioral traits. It mentions renaming across all files but omits side effects (e.g., undoability, file modifications, risk of breaking code) and does not clarify if the operation is read-only or write.

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 description is a single short sentence, which is concise but lacks important details. It is front-loaded with the verb, but brevity comes at the cost of completeness.

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 4 required parameters with no explanations, no output schema, and no annotations, the description is insufficient. It does not cover return values, error cases, or success feedback, making it incomplete for an agent to use reliably.

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

Parameters2/5

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

Schema description coverage is 0%, and the description provides no additional context for parameters (e.g., file path format, line/column indexing base). Although parameter names are self-explanatory, the tool's description adds no value beyond the schema.

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 action (rename), the resource (symbol at given position), and the scope (across all files). It is easily distinguishable from sibling tools which focus on finding references or completions.

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 guidance on when to use this tool versus alternatives like find_references or go_to_definition. Does not specify prerequisites, such as the symbol needing to exist or write permissions.

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/AbdessamadTzn/fastapi-architect-mcp'

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