Skip to main content
Glama
igorolv

sonar-mcp-server

getIssueSnippets

getIssueSnippets
Read-onlyIdempotent

Retrieve Sonar-analysed source snippets for every issue location, including cross-file flows. Includes code lines and SCM metadata. Use when local source is unavailable or may differ.

Instructions

Get Sonar-analysed source snippets for all issue locations, including cross-file flows. Returns component path, language, code lines, and SCM metadata. Use when local source is unavailable or may differ from the analysed ref. Scope explicitly: omitting both branch and pullRequest uses the configured default (usually main). For non-main or PR work, pass the matching ref explicitly; discover it with listProjectBranches / listProjectPullRequests.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
branchNoBranch name; mutually exclusive with `pullRequest`. Omission uses the configured default (usually main). For non-main lookup, pass explicitly; use `listProjectBranches` to discover names.
issueKeyYesIssue key
pullRequestNoPR key; mutually exclusive with `branch`; no default. For PR work, pass explicitly; use `listProjectPullRequests`.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
issueKeyNoKey of the issue these snippets belong to.
snippetsNoOne or more source code snippets showing the issue location and surrounding lines.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.3/5.0
Behavior4/5

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

Annotations already declare readOnlyHint=true, idempotentHint=true, and destructiveHint=false. The description adds useful behavioral context beyond that: snippets are Sonar-analysed rather than local, cross-file flows are included, and the result exposes component path, language, code lines, and SCM metadata. The default-branch behavior is also disclosed.

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 sentences with no filler: purpose, use case, and scoping guidance. Each sentence justifies its presence, and the front-loaded return value description lets an agent quickly recognize the tool's role.

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 read-only tool with a full output schema and a required single parameter, the description covers purpose, return contents, when to use, and how to handle branch/PR scoping. Nothing essential is missing for an agent to select and invoke it correctly.

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%, so the baseline is 3. The description reinforces the branch/pullRequest mutual exclusivity and default-branch behavior, but those semantics are already documented in the schema. The required issueKey is simple and needs no elaboration.

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?

Description names a specific verb and resource: 'Get Sonar-analysed source snippets for all issue locations, including cross-file flows.' It distinguishes itself from siblings like getIssue/listIssues by focusing on source snippets across all locations, not issue metadata or summaries.

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?

Explicitly states when to use it: 'Use when local source is unavailable or may differ from the analysed ref.' It also gives scoping guidance for branches and PRs and points to listProjectBranches/listProjectPullRequests for discovery. It does not explicitly name which sibling to use instead for ordinary local-source cases, but the context is clear.

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