Skip to main content
Glama

Rename Symbol

rename_symbol

Rename Svelte symbols across your workspace with automatic file updates. Change variable, function, or component names while maintaining consistency throughout your project.

Instructions

Rename a symbol across the workspace. Applies changes to disk.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filePathYesAbsolute path to the file
symbolNameYesName of the symbol to rename
newNameYesNew name for the symbol
symbolKindNoKind of symbol

Implementation Reference

  • The `rename_symbol` tool is registered and implemented in this block, using LSP `textDocument/prepareRename` and `textDocument/rename` requests, and then applying the changes via `applyWorkspaceEdit`.
    server.registerTool(
      "rename_symbol",
      {
        title: "Rename Symbol",
        description:
          "Rename a symbol across the workspace. Applies changes to disk.",
        inputSchema: z.object({
          filePath: z.string().describe("Absolute path to the file"),
          symbolName: z.string().describe("Name of the symbol to rename"),
          newName: z.string().describe("New name for the symbol"),
          symbolKind: z.string().optional().describe("Kind of symbol"),
        }),
      },
      async ({
        filePath,
        symbolName,
        newName,
        symbolKind,
      }): Promise<ToolResult> => {
        try {
          const prep = await prepareSymbolRequest(lsp, filePath, symbolName, symbolKind);
          if ("error" in prep) return textResult(prep.error);
    
          // Prepare rename check
          const prepareResult = await lsp.request(
            "textDocument/prepareRename",
            makePositionParams(prep.ctx)
          );
          if (!prepareResult) {
            return textResult(`Symbol '${symbolName}' cannot be renamed.`);
          }
    
          // Execute rename
          const renameParams = {
            ...makePositionParams(prep.ctx),
            newName,
          };
          const result = await lsp.request("textDocument/rename", renameParams);
    
          if (!result) return textResult("Rename failed - no changes returned.");
    
          const applied = await applyWorkspaceEdit(lsp, result);
          const summary = formatRenameEdit(result, symbolName, newName);
          return textResult(
            applied
              ? summary
              : `(dry-run, edits NOT applied to disk)\n\n${summary}`
          );
        } catch (ex) {
          return textResult(formatError(ex));
        }
      }
    );
Behavior2/5

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

With no annotations, the description carries full burden. It discloses that changes are applied to disk, indicating a destructive write operation, but lacks details on permissions, error handling (e.g., if symbol not found), side effects (e.g., refactoring across files), or rate limits. This is a significant gap for a mutation tool.

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?

Two concise sentences with zero waste: the first states the action and scope, the second clarifies the disk impact. It is front-loaded and appropriately sized for the tool's complexity.

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?

For a destructive mutation tool with no annotations and no output schema, the description is incomplete. It lacks critical context such as return values (e.g., success/failure), error conditions, or behavioral nuances like whether it performs a refactor or simple rename. This leaves gaps for an agent to use it correctly.

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

Parameters3/5

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

Schema description coverage is 100%, so the schema fully documents all parameters. The description adds no additional meaning beyond implying workspace-wide renaming, which is already suggested by the tool's purpose. Baseline 3 is appropriate as the schema handles parameter documentation.

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 a symbol'), the scope ('across the workspace'), and the effect ('Applies changes to disk'), which distinguishes it from read-only sibling tools like find_definition or find_references. It specifies a specific verb and resource with explicit behavioral impact.

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 is provided on when to use this tool versus alternatives. While it implies a write operation, it doesn't mention prerequisites (e.g., needing edit permissions), exclusions (e.g., not for unsaved files), or direct alternatives among siblings like apply_code_action for broader edits.

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/adainrivers/SvelteLS.MCP'

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