Skip to main content
Glama

get_complexity_metrics

Calculate cyclomatic and cognitive complexity and lines of code for Java source files, providing risk assessment.

Instructions

Get cyclomatic complexity, cognitive complexity, LOC.

USAGE: get_complexity_metrics(filePath="path/to/File.java") OUTPUT: Complexity metrics with risk assessment

Metrics:

  • Cyclomatic Complexity: Count of decision points (+1 for if/for/while/case/catch)

  • Cognitive Complexity: Penalizes nesting and breaks in linear flow

  • LOC: Physical and logical lines of code

Risk levels:

  • High: CC > 10

  • Medium: CC 6-10

  • Low: CC <= 5

Requires load_project to be called first.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
includeDetailsNoInclude per-method breakdown (default: true)
granularityNoLevel of detail: 'file', 'type', or 'method' (default: 'file')
filePathYesPath to source file
Behavior3/5

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

No annotations exist, so the description carries full burden. It discloses that the tool requires load_project and describes output with risk levels, implying a read-only, analytical operation. However, it does not mention whether the operation is idempotent, any performance impact, or error handling beyond output format. The prerequisite is helpful but more detail on behavior would improve score.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is fairly long with example, metric details, risk levels, and prerequisite. It uses headings and bullet points for structure, which aids readability. However, some information (e.g., metric formulas) could be briefed without losing clarity. It is not overly verbose but could be tightened.

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?

Given no output schema or annotations, the description includes example, output explanation, risk levels, and a prerequisite. It covers the tool's purpose, how to use it, and what results to expect. Missing details like error states or load_project failure behavior prevent a 5, but it is well-rounded for a three-parameter tool.

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?

Input schema covers 100% of parameters with descriptions. Description adds an example usage showing filePath but does not elaborate on includeDetails or granularity beyond schema defaults. The additional details on metrics and risk levels are not directly about parameter meaning. Since schema provides adequate coverage, a 3 is appropriate.

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 the action 'Get' and the resources 'cyclomatic complexity, cognitive complexity, LOC'. It clearly identifies the tool's purpose among siblings like analyze_file or get_method_at_position, which focus on different aspects. The example and metric breakdown further clarify scope.

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 provides an example call and states the prerequisite 'Requires load_project to be called first', which guides usage. However, it does not explicitly state when to avoid this tool in favor of alternatives (e.g., analyze_method might also compute complexity) or what to do if conditions are not met. No direct comparison with siblings is given.

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