Skip to main content
Glama

analyze_control_flow

Analyze method control flow to identify branching, loops, returns, throws, and nesting depth. Supports if, switch, ternary, for, while, do-while, enhanced-for, try-catch blocks.

Instructions

Analyze the control flow structure of a method.

USAGE: analyze_control_flow(filePath="path/to/File.java", line=10, column=5) OUTPUT: Branching points, loops, returns, throws, and nesting depth

Reports:

  • Branch count (if/switch/ternary)

  • Loop count and types (for/while/do-while/enhanced-for)

  • Return points with line numbers

  • Throw points with exception types and line numbers

  • Try-catch blocks with caught exception types

  • Maximum nesting depth

Requires load_project to be called first.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filePathYesFile containing the method
lineYesZero-based line number within the method
columnYesZero-based column number
Behavior4/5

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

No annotations are provided, so the description must disclose behavioral traits. It clarifies the tool's purpose (analysis, not modification) and the prerequisite, implying it is a read-only operation. However, it could explicitly state that it does not modify state. The detailed output description adds transparency.

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 concise and well-structured: a one-sentence purpose, a usage example, an output summary line, and a bulleted list of reported items. Every sentence adds value, and the key information is front-loaded.

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

Completeness5/5

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

Given there is no output schema, the description thoroughly explains the output (branch count, loop types, return points, throw points, try-catch blocks, nesting depth). It also covers the prerequisite. The sibling tools are numerous, but the description is sufficiently complete for an agent to use the tool correctly.

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?

The input schema covers all three parameters with descriptions (100% coverage). The description adds a usage example with concrete values (e.g., 'line=10, column=5'), which clarifies parameter usage beyond the schema. This provides marginal added value over the schema alone.

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 explicitly states 'Analyze the control flow structure of a method', includes a usage example, and lists detailed output items (branch count, loop types, etc.). This clearly distinguishes it from sibling tools like analyze_data_flow and analyze_file.

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 notes a prerequisite ('Requires load_project to be called first') and provides a usage example. However, it does not specify when to use this tool over alternatives such as analyze_data_flow or get_complexity_metrics, nor does it state when not to use it.

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/pzalutski-pixel/javalens-mcp'

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