Skip to main content
Glama

Analyze one source file

analyze_file

Get static complexity metrics and a heuristic risk score (0-1) for a JavaScript/TypeScript file to identify structural risks like nested loops, long functions, or unguarded mutation before reading the file.

Instructions

Return static complexity metrics and a heuristic risk score (0-1) for a single JavaScript or TypeScript file. Deterministic and fast — no model call. Call this when reviewing a file to find out where the structural risk sits (nested loops, long functions, async boundaries, unguarded mutation) before reading the whole file yourself.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fileYesAbsolute path to a .js/.jsx/.ts/.tsx file

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.8.2

TDQS

A4.2/5.0
Behavior4/5

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

With no annotations, the description carries the full behavioral burden. It discloses that the tool is deterministic, fast, makes no model call, and is heuristic in nature. It also lists the risk categories it detects. It does not explicitly state read-only/no side effects, but 'Return...' strongly implies a pure analysis operation.

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 two sentences with no filler: it front-loads the return value, defines the risk score range, names the risk categories, and gives usage context. 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?

For a one-parameter tool with no annotations and no output schema, this description is largely complete: it covers purpose, return concept, detected risk categories, and when to call it. The main gaps are the exact output shape and error behavior, which would matter more without an output schema.

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?

The single parameter `file` is fully documented in the schema with its absolute-path requirement and allowed extensions, giving 100% schema description coverage. The tool description only reinforces that it is a single JavaScript or TypeScript file and adds no new format, default, or edge-case semantics, so the baseline 3 applies.

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 states the specific verb + resource: 'Return static complexity metrics and a heuristic risk score (0-1) for a single JavaScript or TypeScript file.' It clearly distinguishes this from sibling tools like scan_project or map_dependencies by emphasizing single-file analysis.

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?

It gives explicit when-to-use guidance: 'Call this when reviewing a file to find out where the structural risk sits... before reading the whole file yourself.' However, it does not mention when not to use it or name specific sibling alternatives, so it stops short of a perfect score.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.