Cover image
Try Now
2025-04-04

Sonarqube的模型上下文协议(MCP)服务器

3 years

Works with Finder

3

Github Watches

2

Github Forks

19

Github Stars

SonarQube MCP Server

CI Quality Gate Status Bugs Code Smells Coverage Duplicated Lines (%) npm version npm downloads License

A Model Context Protocol (MCP) server that integrates with SonarQube to provide AI assistants with access to code quality metrics, issues, and analysis results.

Overview

The SonarQube MCP Server enables AI assistants to interact with SonarQube's code quality analysis capabilities through the Model Context Protocol. This integration allows AI assistants to:

  • Retrieve code metrics and analysis results
  • Access and filter issues
  • Check quality status
  • Analyze project quality over time

Features

  • List all SonarQube projects with pagination support
  • Get detailed issue information from SonarQube projects with extensive filtering options
  • Support for both SonarQube and SonarCloud
  • Comprehensive parameter validation using Zod schemas
  • Full TypeScript support

Usage with Claude Desktop

  1. Edit claude_desktop_config.json:

    • Open Claude Desktop
    • Go to Settings -> Developer -> Edit Config
    • Add the one of the configurations below to the mcpServers section
  2. Restart Claude Desktop to apply the changes

Docker

{
  "mcpServers": {
    "sonarqube": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "-e",
        "SONARQUBE_URL",
        "-e",
        "SONARQUBE_TOKEN",
        "-e",
        "SONARQUBE_ORGANIZATION",
        "sapientpants/sonarqube-mcp-server"
      ],
      "env": {
        "SONARQUBE_URL": "https://sonarqube.example.com",
        "SONARQUBE_TOKEN": "your-sonarqube-token",
        "SONARQUBE_ORGANIZATION": "your-organization-key (optional)"
      }
    }
  }
}

NPX

{
  "mcpServers": {
    "sonarqube": {
      "command": "npx",
      "args": [
        "-y",
        "sonarqube-mcp-server@1.0.0"
      ],
      "env": {
        "SONARQUBE_URL": "https://sonarqube.example.com",
        "SONARQUBE_TOKEN": "your-sonarqube-token",
        "SONARQUBE_ORGANIZATION": "your-organization-key (optional)"
      }
    }
  }
}

Available Tools

The SonarQube MCP Server provides the following tools:

SonarQube Tools

  1. projects: List all SonarQube projects

    • Parameters:
      • organization (optional) - Organization key for SonarQube Cloud
      • page (optional) - Page number for results pagination
      • page_size (optional) - Number of items per page
  2. issues: Get issues from a SonarQube project

    • Parameters:
      • project_key (required) - The unique identifier for the SonarQube project
      • severity (optional) - Filter issues by severity (INFO, MINOR, MAJOR, CRITICAL, BLOCKER)
      • organization (optional) - Organization key for SonarQube Cloud
      • page (optional) - Page number for results pagination
      • page_size (optional) - Number of items per page
      • statuses (optional) - Filter issues by status (array of: OPEN, CONFIRMED, REOPENED, RESOLVED, CLOSED, TO_REVIEW, IN_REVIEW, REVIEWED)
      • resolutions (optional) - Filter issues by resolution (array of: FALSE-POSITIVE, WONTFIX, FIXED, REMOVED)
      • resolved (optional) - Whether to return only resolved issues (true) or unresolved issues (false)
      • types (optional) - Filter issues by type (array of: CODE_SMELL, BUG, VULNERABILITY, SECURITY_HOTSPOT)
      • rules (optional) - Array of rule keys to filter issues
      • tags (optional) - Array of tags to filter issues
      • created_after (optional) - Return issues created after the given date (format: YYYY-MM-DD)
      • created_before (optional) - Return issues created before the given date (format: YYYY-MM-DD)
      • created_at (optional) - Return issues created on the given date
      • created_in_last (optional) - Return issues created during a time span before the current time (e.g., "1d" for issues created in the last day)
      • assignees (optional) - Array of assignee login names to filter issues
      • authors (optional) - Array of author login names to filter issues
      • cwe (optional) - Array of CWE identifiers to filter vulnerability issues
      • languages (optional) - Array of languages to filter issues
      • owasp_top10 (optional) - Array of OWASP Top 10 categories to filter issues
      • sans_top25 (optional) - Array of SANS Top 25 categories to filter issues
      • sonarsource_security (optional) - Array of SonarSource security categories to filter issues
      • on_component_only (optional) - Return only issues at the specified component level (true) or issues from the component's subtree (false)
      • facets (optional) - Array of facets to return along with the issues
      • since_leak_period (optional) - Return only issues created since the leak period
      • in_new_code_period (optional) - Return only issues created in the new code period

Environment Variables

  • SONARQUBE_URL - URL of your SonarQube instance (default: https://next.sonarqube.com/sonarqube)
  • SONARQUBE_TOKEN - Authentication token for SonarQube API access
  • SONARQUBE_ORGANIZATION - (Optional) Organization key for SonarQube Cloud

Development

  1. Clone the repository:
git clone https://github.com/sapientpants/sonarqube-mcp-server.git
cd sonarqube-mcp-server
  1. Install dependencies:
pnpm install
  1. Build the project:
pnpm run build
  1. Configure Claude Desktop
{
  "mcpServers": {
    "sonarqube": {
      "command": "node",
      "args": [
        "/path/to/sonarqube-mcp-server/dist/index.js"
      ],
      "env": {
        "SONARQUBE_TOKEN": "your-sonarqube-token"
      }
    }
  }
}

Prerequisites

  • Node.js 20 or higher
  • pnpm 10.7.0 or higher
  • Docker (for container builds)

Scripts

  • pnpm run build - Build the TypeScript code
  • pnpm run start - Start the server
  • pnpm run dev - Start the server in development mode
  • pnpm run test - Run tests
  • pnpm run lint - Run ESLint
  • pnpm run format - Format code with Prettier

License

MIT

相关推荐

  • NiKole Maxwell
  • I craft unique cereal names, stories, and ridiculously cute Cereal Baby images.

  • Bora Yalcin
  • Evaluator for marketplace product descriptions, checks for relevancy and keyword stuffing.

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • https://suefel.com
  • Latest advice and best practices for custom GPT development.

  • Alexandru Strujac
  • Efficient thumbnail creator for YouTube videos

  • Callycode Limited
  • A geek-themed horoscope generator blending Bitcoin prices, tech jargon, and astrological whimsy.

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • Khalid kalib
  • Write professional emails

  • Beniyam Berhanu
  • Therapist adept at identifying core issues and offering practical advice with images.

  • Elijah Ng Shi Yi
  • Advanced software engineer GPT that excels through nailing the basics.

  • apappascs
  • 发现市场上最全面,最新的MCP服务器集合。该存储库充当集中式枢纽,提供了广泛的开源和专有MCP服务器目录,并提供功能,文档链接和贡献者。

  • ShrimpingIt
  • MCP系列GPIO Expander的基于Micropython I2C的操作,源自ADAFRUIT_MCP230XX

  • huahuayu
  • 统一的API网关,用于将多个Etherscan样区块链Explorer API与对AI助手的模型上下文协议(MCP)支持。

  • deemkeen
  • 用电源组合控制您的MBOT2:MQTT+MCP+LLM

  • jae-jae
  • MCP服务器使用剧作《无头浏览器》获取网页内容。

    Reviews

    1 (1)
    Avatar
    user_OrE7cO22
    2025-04-15

    Unstorage MCP Server by slow-groovin is a game-changer for seamless data management. The intuitive interface and reliable performance make it a must-have for any serious MCP application user. Highly recommend it for its efficiency and ease of use! Check it out here: https://mcp.so/server/unstorage-mcp/slow-groovin