Skip to main content
Glama

rename_symbol

Rename variables, functions, or classes across all files in a project. Update symbol names consistently throughout your codebase to maintain clarity and avoid errors.

Instructions

Rename a symbol (variable, function, class, etc.) across all files

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fileYesFile containing the symbol
lineYesLine number of the symbol
characterNoCharacter position of the symbol
newNameYesNew name for the symbol
languageNoProgramming languagetypescript

Implementation Reference

  • The main handler function that executes the rename_symbol tool using LSP textDocument/rename request and applies the workspace edit.
    export async function renameSymbol(args: RenameSymbolArgs, clientManager: LSPClientManager) {
      const { file, line, character = 0, newName, language = 'typescript' } = args;
      const workspaceRoot = findWorkspaceRoot(file);
    
      try {
        const client = await clientManager.getOrCreateLSPClient(language, workspaceRoot);
    
        // Open the file
        const content = await fs.readFile(file, 'utf-8');
        await clientManager.sendLSPNotification(client, 'textDocument/didOpen', {
          textDocument: {
            uri: `file://${file}`,
            languageId: language,
            version: 1,
            text: content,
          },
        });
    
        const workspaceEdit = await clientManager.sendLSPRequest(client, 'textDocument/rename', {
          textDocument: { uri: `file://${file}` },
          position: { line: line - 1, character },
          newName,
        });
    
        if (workspaceEdit) {
          const edit = workspaceEdit as LSPWorkspaceEdit;
          await applyWorkspaceEdit(edit);
    
          const changedFiles = Object.keys(edit.changes || {});
          return {
            content: [
              {
                type: 'text',
                text: `Successfully renamed symbol to '${newName}' across ${changedFiles.length} files`,
              },
            ],
          };
        } else {
          throw new Error('No workspace edit returned from LSP server');
        }
      } catch (error) {
        throw new Error(`Failed to rename symbol: ${error instanceof Error ? error.message : String(error)}`);
      }
    }
  • src/server.ts:171-202 (registration)
    Registration of the 'rename_symbol' tool in the listTools response, including name, description, and input schema.
    {
      name: 'rename_symbol',
      description: 'Rename a symbol (variable, function, class, etc.) across all files',
      inputSchema: {
        type: 'object',
        properties: {
          file: {
            type: 'string',
            description: 'File containing the symbol',
          },
          line: {
            type: 'number',
            description: 'Line number of the symbol',
          },
          character: {
            type: 'number',
            description: 'Character position of the symbol',
            default: 0,
          },
          newName: {
            type: 'string',
            description: 'New name for the symbol',
          },
          language: {
            type: 'string',
            description: 'Programming language',
            default: 'typescript',
          },
        },
        required: ['file', 'line', 'newName'],
      },
    },
  • src/server.ts:220-221 (registration)
    Handler dispatch in the switch statement for the 'rename_symbol' tool call.
    case 'rename_symbol':
      return await renameSymbol(args as unknown as RenameSymbolArgs, this.clientManager);
  • TypeScript interface defining the arguments for the rename_symbol tool.
    export interface RenameSymbolArgs {
      file: string;
      line: number;
      character?: number;
      newName: string;
      language?: string;
    }
Behavior2/5

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

No annotations are provided, so the description carries full burden. It states the tool renames symbols 'across all files', which suggests a potentially destructive, wide-scope operation, but doesn't disclose behavioral details like whether changes are reversible, what permissions are needed, how conflicts are handled, or what the response looks like. This is inadequate for a mutation tool with zero annotation coverage.

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?

The description is a single, efficient sentence that front-loads the core action ('rename a symbol') and adds clarifying scope ('across all files'). There is zero wasted text, and it's 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?

Given this is a mutation tool with no annotations and no output schema, the description is incomplete. It lacks critical behavioral context (e.g., safety, permissions, response format) and doesn't compensate for the absence of structured data. The 100% schema coverage helps with parameters, but overall completeness is poor for a tool that modifies code across files.

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 already documents all 5 parameters (file, line, character, newName, language) with descriptions. The description adds no additional parameter semantics beyond what the schema provides, such as explaining how 'character' is used or what 'language' affects. Baseline 3 is appropriate when schema does the heavy lifting.

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 verb 'rename' and the resource 'symbol', specifying it applies to variables, functions, classes, etc. across all files. It distinguishes from siblings like 'rename_file' (which renames files, not symbols) and 'move_function' (which moves rather than renames).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for renaming symbols in codebases, but doesn't explicitly state when to use this vs. alternatives like 'find_references' (for locating symbols) or 'extract_function' (for refactoring). No exclusions or prerequisites are mentioned.

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/sminnee/lsp-mcp'

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