Skip to main content
Glama

summarize_sonarcloud_issues

Summarize SonarCloud issues for a pull request to identify code quality concerns, filter by severity and status, and detect issues since the leak period for efficient resolution.

Instructions

Get a high-level summary of SonarCloud issues for a PR

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
impactSeveritiesNoComma-separated list of impact severities.
issueStatusesNoComma-separated list of issue statuses
pullRequestNoPull request id
sinceLeakPeriodNoTo retrieve issues created since the leak period. If this parameter is set to a truthy value, createdAfter must not be set and one component id or key must be provided. (default: false)
tokenNoSonarCloud API token (optional if set in environment)

Implementation Reference

  • The core handler function that implements the 'summarize_sonarcloud_issues' tool logic. It fetches detailed issues using the internal fetchSonarCloudIssues method, processes them to create counts by severity, type, status, debt, top rules, and affected files, then returns a JSON summary.
    private async summarizeSonarCloudIssues(args: any): Promise<any> { // Get the raw issues first const issuesResponse = await this.fetchSonarCloudIssues({ ...args, additionalFields: ["_all"], facets: ["issueStatuses", "impactSeverities", "types", "rules"], ps: 500 // Get more issues for better summary }); const data = JSON.parse(issuesResponse.content[0].text); const issues = data.issues; // Create summary const summary: IssueSummary = { totalIssues: data.summary.total, criticalIssues: issues.filter((i: any) => i.severity === "BLOCKER").length, highImpactIssues: issues.filter((i: any) => i.severity === "CRITICAL" || i.severity === "MAJOR").length, mediumImpactIssues: issues.filter((i: any) => i.severity === "MINOR").length, lowImpactIssues: issues.filter((i: any) => i.severity === "INFO").length, infoIssues: issues.filter((i: any) => i.severity === "INFO").length, bugCount: issues.filter((i: any) => i.type === "BUG").length, vulnerabilityCount: issues.filter((i: any) => i.type === "VULNERABILITY").length, codeSmellCount: issues.filter((i: any) => i.type === "CODE_SMELL").length, securityHotspotCount: issues.filter((i: any) => i.type === "SECURITY_HOTSPOT").length, openIssues: issues.filter((i: any) => i.status === "OPEN").length, confirmedIssues: issues.filter((i: any) => i.status === "CONFIRMED").length, totalDebt: data.debtTotal?.toString() || "0", totalEffort: data.effortTotal?.toString() || "0", topRules: this.getTopRules(issues), filesAffected: new Set(issues.map((i: any) => i.component)).size, }; return { content: [ { type: "text", text: JSON.stringify(summary, null, 2), }, ], }; }
  • The input schema defining the parameters for the 'summarize_sonarcloud_issues' tool, including pullRequest, token, impactSeverities, sinceLeakPeriod, and issueStatuses.
    type: "object", properties: { pullRequest: { type: "string", description: "Pull request id", }, token: { type: "string", description: "SonarCloud API token (optional if set in environment)", }, impactSeverities: { type: "array", items: { type: "string", enum: ["INFO", "LOW", "MEDIUM", "HIGH", "BLOCKER"], }, description: "Comma-separated list of impact severities.", }, sinceLeakPeriod: { type: "boolean", description: "To retrieve issues created since the leak period. If this parameter is set to a truthy value, createdAfter must not be set and one component id or key must be provided. (default: false)", }, issueStatuses: { type: "array", items: { type: "string", enum: [ "OPEN", "CONFIRMED", "FALSE_POSITIVE", "ACCEPTED", "FIXED", ], }, description: "Comma-separated list of issue statuses", }, },
  • src/index.ts:402-403 (registration)
    Registration of the tool in the main request handler dispatch logic, mapping the tool name to its handler method.
    if (name === "summarize_sonarcloud_issues") { return await this.summarizeSonarCloudIssues(args);
  • src/index.ts:347-390 (registration)
    Tool definition and registration in the tools list, including name, description, and input schema for MCP tool discovery.
    { name: "summarize_sonarcloud_issues", description: "Get a high-level summary of SonarCloud issues for a PR", inputSchema: { type: "object", properties: { pullRequest: { type: "string", description: "Pull request id", }, token: { type: "string", description: "SonarCloud API token (optional if set in environment)", }, impactSeverities: { type: "array", items: { type: "string", enum: ["INFO", "LOW", "MEDIUM", "HIGH", "BLOCKER"], }, description: "Comma-separated list of impact severities.", }, sinceLeakPeriod: { type: "boolean", description: "To retrieve issues created since the leak period. If this parameter is set to a truthy value, createdAfter must not be set and one component id or key must be provided. (default: false)", }, issueStatuses: { type: "array", items: { type: "string", enum: [ "OPEN", "CONFIRMED", "FALSE_POSITIVE", "ACCEPTED", "FIXED", ], }, description: "Comma-separated list of issue statuses", }, }, required: [], }, },
  • Helper function used by the handler to compute the top 10 most frequent rules in the issues for the summary.
    private getTopRules(issues: any[]): Array<{rule: string; count: number}> { const ruleCounts = issues.reduce((acc, issue) => { acc[issue.rule] = (acc[issue.rule] || 0) + 1; return acc; }, {} as Record<string, number>); return Object.entries(ruleCounts) .sort(([,a], [,b]) => (b as number) - (a as number)) .slice(0, 10) .map(([rule, count]) => ({rule, count: count as number})); }

Other Tools

Related 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/dozzman/sonarcloud-mcp'

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