Skip to main content
Glama

Analyze one source file

analyze_file
Read-only

Analyze a JavaScript or TypeScript file to get static complexity metrics and a 0-1 heuristic risk score. Use it before reading code to locate structural risks like nested loops and long functions.

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?

Annotations already declare readOnlyHint=true, destructiveHint=false, and openWorldHint=false, so safety is covered. The description adds genuine value beyond that: determinism ('Deterministic and fast — no model call') and the nature of the output (metrics plus a 0-1 risk score), which sets expectations for cost and reliability. It omits any file-size or performance limits, keeping it just shy of 5.

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 tight sentences, front-loaded with the return value, then the mechanism, then the use case. Every sentence carries distinct information with no filler.

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?

With one parameter, no output schema, and full coverage of the return shape (metrics + risk score) in the text, an agent has enough to invoke it correctly. Minor gaps around output structure specifics remain, but not enough to impede correct invocation.

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% and the single 'file' parameter is fully documented as 'Absolute path to a .js/.jsx/.ts/.tsx file'. The description adds no syntax or format detail beyond the schema, so the baseline of 3 for high coverage 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?

States a specific verb and resource ('Return static complexity metrics and a heuristic risk score') scoped precisely to 'a single JavaScript or TypeScript file'. This makes it immediately distinguishable from siblings like scan_project or map_dependencies, which operate at project or dependency scope.

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?

Gives clear when-to-use context: 'Call this when reviewing a file to find out where the structural risk sits ... before reading the whole file yourself.' It also enumerates what to look for (nested loops, long functions, async boundaries, unguarded mutation). It stops short of naming the sibling to use for whole-project analysis, so no explicit exclusion.

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