Skip to main content
Glama

get_diagnostics

Get compilation errors and warnings for a Java file or entire project, with optional severity filtering and result limits. Use it to find syntax errors, type mismatches, and missing imports.

Instructions

Get compilation diagnostics (errors and warnings) for a file or project.

USAGE: get_diagnostics() for all files, or get_diagnostics(filePath="...") for one file OUTPUT: List of compilation errors and warnings with locations

Useful for finding syntax errors, type mismatches, missing imports, etc.

severity (optional, compared case-insensitively): error or warning keeps the diagnostics of that severity; all (the default) keeps both. Any other value is rejected with INVALID_PARAMETER.

Every file is checked and every diagnostic kept is counted in totalDiagnostics, errorCount and warningCount; maxResults limits only the diagnostics listed, and meta.truncated says when the list is cut.

Requires load_project to be called first.

Input Schema

NameRequiredDescriptionDefault
filePathNoOptional path to source file. If omitted, checks all files.
severityNoFilter by severity, case-insensitive: 'error', 'warning' or 'all' (default: 'all')
maxResultsNoMax diagnostics to return (default 100)

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv1.5.3
    • changedInput schema / properties / severity / description
      Previous value: -"Filter by severity: 'error', 'warning', or 'all' (default: 'all')"New value: +"Filter by severity, case-insensitive: 'error', 'warning' or 'all' (default: 'all')"
  2. Addedv1.3.4
  3. Removedv1.3.3
  4. First observedv1.2.0

TDQS

A4.4/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 and does well: it discloses that unrecognized severity values are rejected with INVALID_PARAMETER, that filtering is case-insensitive, that all files are checked and counted even when maxResults truncates the list, and that meta.truncated signals truncation. It does not cover permissions or performance on very large projects, but the operational semantics are unusually well documented.

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

Conciseness4/5

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

USAGE and OUTPUT are front-loaded before the finer filtering rules, so an agent gets the essential call shape immediately. The description is on the long side and the 'Useful for finding syntax errors, type mismatches, missing imports, etc.' sentence is largely filler, but the labeled structure keeps it scannable.

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?

For a 3-parameter read tool with no annotations and no output schema, the description covers the invocation modes, the prerequisite, the meaning of each parameter, the shape of the return value (diagnostics with locations plus counts and a truncation flag), and the error path. Nothing an agent needs to call it correctly is missing.

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 coverage is 100%, so the baseline is 3, but the description earns extra credit by adding semantics the schema does not: case-insensitive severity matching with INVALID_PARAMETER rejection, and the non-obvious interaction where maxResults limits only the listed diagnostics while totalDiagnostics/errorCount/warningCount count everything.

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 opening sentence gives a specific verb and resource ('Get compilation diagnostics (errors and warnings)') plus the scope (file or project). It is distinguishable from nearby siblings like validate_syntax or analyze_file because it names the artifact being returned (errors and warnings) rather than a generic 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?

The USAGE line explicitly shows the two invocation modes: no-arg for all files and filePath for a single file, and it states the prerequisite 'Requires load_project to be called first.' It stops short of saying when to prefer this over siblings such as validate_syntax or find_possible_bugs, so it is clear context without alternatives.

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