Skip to main content
Glama
igorolv

sonar-mcp-server

getRule

getRule
Read-onlyIdempotent

Retrieve a Sonar rule's title, severity, type, language, tags, and structured explanation and fix sections by its rule key.

Instructions

Get a Sonar rule. Returns title, severity, type, language, tags, and structured explanation and fix sections.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ruleKeyYesRule key, e.g. `java:S1234`

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
keyNoUnique rule key (e.g. 'java:S1186').
langNoLanguage key (e.g. 'java', 'js', 'py').
nameNoHuman-readable rule name.
repoNoRepository key (language or technology identifier, e.g. 'java', 'js', 'py').
tagsNoTags categorising the rule (e.g. 'performance', 'java8', 'owasp-a1').
typeNoRule type: BUG, VULNERABILITY, CODE_SMELL, or SECURITY_HOTSPOT.
statusNoRule lifecycle status: READY, DEPRECATED, or REMOVED.
langNameNoHuman-readable language name (e.g. 'Java', 'JavaScript', 'Python').
severityNoDefault severity. Standard mode: BLOCKER, CRITICAL, MAJOR, MINOR, INFO. MQR mode: BLOCKER, HIGH, MEDIUM, LOW, INFO.
htmlDescriptionNoFull rule description as raw HTML (including code examples and formatting).
descriptionSectionsNoStructured description broken into sections (rationale, non-compliant code, compliant code, etc.).

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A3.6/5.0
Behavior3/5

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

Annotations already declare readOnlyHint, idempotentHint, and destructiveHint: false, so the safety profile is covered. The description mentions returned fields, but since an output schema is present, this largely repeats structured data rather than revealing behavior. No additional traits such as authentication needs, rate limits, or error behavior are disclosed. No contradiction with annotations.

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 a single compact sentence that front-loads the operation ('Get a Sonar rule') and then lists the return contents. There is no filler, redundancy, or unnecessary detail, making it appropriately concise for a simple lookup tool.

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 the tool's low complexity—one fully documented parameter, an output schema, and read-only/idempotent annotations—the description is functionally adequate for correct invocation. The main gap is the absence of any relationship to sibling tools or selection guidance, but this is minor for such a simple and distinct resource.

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% for ruleKey, including an example format (`java:S1234`), so the schema fully documents the parameter. The description adds no extra meaning about the parameter itself, matching the baseline score for high schema coverage.

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 uses a specific verb 'Get' and a clear resource 'Sonar rule', and it lists the returned content (title, severity, type, language, tags, explanation/fix sections). This makes the tool's purpose unambiguous. The resource is distinct from sibling tools that target projects, issues, hotspots, and components, so an agent can tell it apart.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description gives no guidance about when to use getRule versus alternatives such as getIssue or getHotspot. It does not mention any exclusions, prerequisites, or contexts where this tool is preferred. An agent must rely entirely on the tool name to infer selection.

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