Skip to main content
Glama

run_static_analysis

Analyze code for unused variables, dead code, type errors, and syntax issues using native linters and compilers instead of LLM guessing. Supports TypeScript, Python, Rust, and Go.

Instructions

Run the project's native linter/compiler to find unused variables, dead code, type errors, and syntax issues. Delegates detection to deterministic tools instead of LLM guessing. Supports TypeScript, Python, Rust, Go.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
target_pathNoSpecific file or folder to lint (relative to root). Omit for full project.

Implementation Reference

  • The handler function `runStaticAnalysis` executes the logic for running linters or compilers based on file extension or project type.
    export async function runStaticAnalysis(options: StaticAnalysisOptions): Promise<string> {
      const targetPath = options.targetPath ? resolve(options.rootDir, options.targetPath) : options.rootDir;
      const ext = extname(targetPath);
    
      if (ext) {
        const linter = await detectAvailableLinter(options.rootDir, ext);
        if (!linter) return `No linter configured for ${ext} files.`;
    
        const args = [...linter.args];
        if ([".js", ".ts", ".tsx"].includes(ext)) args.push(targetPath);
        else if (ext === ".py") args.push(targetPath);
    
        const result = await runCommand(linter.cmd, args, options.rootDir);
    
        if (result.exitCode === 0 && !result.output) return "No issues found. Code is clean.";
        return `Static analysis (${result.tool}):\n\n${result.output.substring(0, 5000)}`;
      }
    
      const results: string[] = [];
      for (const [fileExt] of Object.entries(LINTER_MAP)) {
        const linter = await detectAvailableLinter(options.rootDir, fileExt);
        if (!linter) continue;
    
        const result = await runCommand(linter.cmd, linter.args, options.rootDir);
        if (result.output) {
          results.push(`[${result.tool}] ${fileExt} files:\n${result.output.substring(0, 2000)}`);
        }
      }
    
      return results.length > 0 ? results.join("\n\n") : "No linters available or no issues found.";
    }
  • src/index.ts:296-309 (registration)
    Registration of the `run_static_analysis` tool in the MCP server instance, mapping the tool name to the `runStaticAnalysis` handler.
    server.tool(
      "run_static_analysis",
      "Run the project's native linter/compiler to find unused variables, dead code, type errors, and syntax issues. " +
      "Delegates detection to deterministic tools instead of LLM guessing. Supports TypeScript, Python, Rust, Go.",
      {
        target_path: z.string().optional().describe("Specific file or folder to lint (relative to root). Omit for full project."),
      },
      withRequestActivity(async ({ target_path }) => ({
        content: [{
          type: "text" as const,
          text: await runStaticAnalysis({ rootDir: ROOT_DIR, targetPath: target_path }),
        }],
      })),
    );
Behavior3/5

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

With no annotations provided, description carries full disclosure burden. It clarifies the delegation pattern (deterministic tools vs. LLM) and identifies specific defect types detected. However, it omits critical execution details: whether the tool is read-only or potentially destructive (some linters auto-fix), output format expectations, and dependency requirements.

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?

Three tightly crafted sentences: first establishes core functionality, second differentiates approach (deterministic vs. LLM), third specifies language support. Every sentence earns its place; no redundancy or boilerplate. Front-loaded with action verb.

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

Completeness3/5

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

Adequate for tool selection given the simple single-parameter schema. Covers primary use case and scope. However, for a tool executing external linters/compilers, the absence of output schema makes the lack of return value description or execution safety notes (read-only vs. mutating) a modest gap.

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

Parameters4/5

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

Schema has 100% coverage with clear target_path description. The tool description adds valuable semantic context by listing supported languages, which helps constrain valid target_path values to appropriate file types. While it doesn't detail syntax further, the combination of complete schema and language context provides solid parameter guidance.

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?

Excellent specificity with 'Run the project's native linter/compiler' (verb + resource) and enumerates exact findings (unused variables, dead code, type errors, syntax issues). Clearly distinguishes from semantic search siblings by focusing on deterministic static analysis.

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?

Provides implied guidance via 'Delegates detection to deterministic tools instead of LLM guessing,' suggesting preference over heuristic analysis. Lists supported languages (TypeScript, Python, Rust, Go) indicating applicability. However, lacks explicit when-to-use vs. siblings like semantic_code_search or prerequisites (e.g., needing config files).

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