Skip to main content
Glama

get_blast_radius

Analyze code dependencies by tracing where a specific symbol is imported or used across files. Helps prevent orphaned code and identifies candidates for inlining before making changes.

Instructions

Before deleting or modifying code, check the BLAST RADIUS. Traces every file and line where a specific symbol (function, class, variable) is imported or used. Prevents orphaned code. Also warns if usage count is low (candidate for inlining).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
symbol_nameYesThe function, class, or variable name to trace across the codebase.
file_contextNoThe file where the symbol is defined. Excludes the definition line from results.

Implementation Reference

  • The main implementation of the getBlastRadius function.
    export async function getBlastRadius(options: BlastRadiusOptions): Promise<string> {
      const entries = await walkDirectory({ rootDir: options.rootDir, depthLimit: 0 });
      const files = entries.filter((e) => !e.isDirectory && isSupportedFile(e.path));
      const usages: SymbolUsage[] = [];
      const symbolPattern = new RegExp(`\\b${escapeRegex(options.symbolName)}\\b`, "g");
    
      for (const file of files) {
        try {
          const content = await readFile(file.path, "utf-8");
          const lines = content.split("\n");
    
          for (let i = 0; i < lines.length; i++) {
            if (symbolPattern.test(lines[i])) {
              const isDefinition = options.fileContext && file.relativePath === options.fileContext && isDefinitionLine(lines[i], options.symbolName);
              if (!isDefinition) {
                usages.push({
                  file: file.relativePath,
                  line: i + 1,
                  context: lines[i].trim().substring(0, 120),
                });
              }
              symbolPattern.lastIndex = 0;
            }
          }
        } catch {
        }
      }
    
      if (usages.length === 0) return `Symbol "${options.symbolName}" is not used anywhere in the codebase.`;
    
      const byFile = new Map<string, SymbolUsage[]>();
      for (const u of usages) {
        const existing = byFile.get(u.file) ?? [];
        existing.push(u);
        byFile.set(u.file, existing);
      }
    
      const lines: string[] = [
        `Blast radius for "${options.symbolName}": ${usages.length} usages in ${byFile.size} files\n`,
      ];
    
      for (const [file, fileUsages] of byFile) {
        lines.push(`  ${file}:`);
        for (const u of fileUsages) {
          lines.push(`    L${u.line}: ${u.context}`);
        }
      }
    
      if (usages.length <= 1) {
        lines.push(`\n⚠ LOW USAGE: This symbol is used only ${usages.length} time(s). Consider inlining if it's under 20 lines.`);
      }
    
      return lines.join("\n");
    }
  • The interface defining the input parameters for the getBlastRadius tool.
    export interface BlastRadiusOptions {
      rootDir: string;
      symbolName: string;
      fileContext?: string;
    }
  • src/index.ts:281-291 (registration)
    The tool registration and invocation logic in the main MCP handler.
    "get_blast_radius",
    "Before deleting or modifying code, check the BLAST RADIUS. Traces every file and line where a specific symbol " +
    "(function, class, variable) is imported or used. Prevents orphaned code. Also warns if usage count is low (candidate for inlining).",
    {
      symbol_name: z.string().describe("The function, class, or variable name to trace across the codebase."),
      file_context: z.string().optional().describe("The file where the symbol is defined. Excludes the definition line from results."),
    },
    withRequestActivity(async ({ symbol_name, file_context }) => ({
      content: [{
        type: "text" as const,
        text: await getBlastRadius({ rootDir: ROOT_DIR, symbolName: symbol_name, fileContext: file_context }),
Behavior4/5

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

With no annotations, the description carries full behavioral burden. It discloses key traits: traces imports AND uses, excludes definition line (via file_context behavior), generates warnings for low usage (inlining candidates), and prevents orphaned code. Missing explicit read-only declaration, though implied by 'get' prefix and 'traces' verb.

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?

Four tightly constructed sentences with zero waste. Front-loaded with usage context (sentence 1), followed by mechanism (sentence 2), and value-add behaviors (sentences 3-4). Every clause earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

No output schema exists, but the description adequately describes conceptual output ('every file and line', usage count warnings). Good coverage for a read-only analysis tool, though explicit mention of return format (e.g., list of locations) would strengthen it.

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 coverage is 100% and descriptions are thorough. The tool description reinforces the semantic types (function, class, variable) but doesn't add syntax details, format constraints, or examples beyond what the schema already provides. Baseline 3 appropriate for high-coverage schemas.

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?

Specific verb ('traces') + resource ('symbol') + scope ('every file and line'). The parenthetical '(function, class, variable)' clarifies the polymorphic input, and the front-loaded context 'Before deleting or modifying code' clearly distinguishes this impact-analysis tool from general search siblings like semantic_code_search.

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

Usage Guidelines4/5

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

Explicitly states when to use ('Before deleting or modifying code') and implies workflow integration (safety check). While it doesn't name specific alternatives, the context makes it clear this is for pre-modification validation versus general exploration.

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/ForLoopCodes/contextplus'

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