community-sonarcloud-mcp-server

community-sonarcloud-mcp-server

A lightweight TypeScript MCP server that provides AI assistants with seamless access to SonarCloud data, enabling code quality metrics, issues, and project queries.

Category
访问服务器

README

SonarCloud MCP Server

npm version npm downloads License: MIT GitHub issues

A TypeScript-based Model Context Protocol (MCP) server that provides AI assistants with seamless access to SonarCloud data. Query code quality metrics, issues, pull requests, and project information directly from your AI tools.

Why This Server?

  • No Docker Required: Unlike SonarSource's official Docker-based MCP server, this is a lightweight TypeScript solution
  • AI-Optimized: Returns JSON data structured for optimal AI consumption and analysis
  • Comprehensive API Coverage: 12 tools covering all major SonarCloud endpoints
  • Flexible Authentication: Multiple auth methods including environment variables, CLI args, and config files
  • Claude Code Integration: Perfect for use with Anthropic's Claude Code and other MCP-compatible AI tools

Installation

npm install -g community-sonarcloud-mcp-server

Or run directly with npx:

npx community-sonarcloud-mcp-server

Check version:

npx community-sonarcloud-mcp-server --version

Configuration

Method 1: Environment Variables

export SONARCLOUD_TOKEN="your_token_here"
export SONARCLOUD_ORGANIZATION="your_org_here"
export SONARCLOUD_URL="https://sonarcloud.io"  # Optional, defaults to sonarcloud.io

Method 2: Command Line Arguments

npx community-sonarcloud-mcp-server --token "your_token" --org "your_org" --url "https://sonarcloud.io"

Method 3: Config File

Create a config file and use:

npx community-sonarcloud-mcp-server --config ./sonarcloud-config.json

Config file format:

{
  "token": "your_sonarcloud_token",
  "organization": "your_organization_key", 
  "url": "https://sonarcloud.io"
}

Priority order: CLI args > Environment vars > Config file

Available Tools

This server provides 12 comprehensive tools for SonarCloud integration:

Core Project & Issue Management

  • list_projects - List all projects in your organization
  • search_issues - Search and filter issues by project, severity, type, status, and Clean Code impact qualities
  • get_pull_requests - List pull requests for a specific project
  • change_issue_status - Mark issues as confirmed, false positive, won't fix, or reopen

Code Quality & Metrics

  • get_measures - Get detailed metrics (coverage, bugs, vulnerabilities, code smells, technical debt)
  • search_metrics - Discover available metrics and their descriptions
  • get_quality_gate_status - Check if projects pass quality gates
  • list_quality_gates - List all available quality gate configurations

Rules & Analysis

  • show_rule - Get detailed information about specific coding rules
  • list_rule_repositories - Browse rule repositories by language
  • list_languages - See all supported programming languages

Source Code

  • get_raw_source - Retrieve raw source code for any file in your projects

Each tool returns structured JSON data optimized for AI analysis and decision-making.

Quick Setup

VS Code

Install for VS Code

Claude Code

claude mcp add -s user -e SONARCLOUD_TOKEN=your-token-here -e SONARCLOUD_ORGANIZATION=your-org-key sonarcloud -- npx community-sonarcloud-mcp-server

Verify the connection with:

claude mcp list

Manual Configuration

Add this server to your MCP configuration file (.mcp.json for Claude Code):

Option 1: Environment Variables (Recommended)

{
  "mcpServers": {
    "community-sonarcloud-mcp": {
      "command": "npx",
      "args": ["community-sonarcloud-mcp-server"],
      "env": {
        "SONARCLOUD_TOKEN": "your_token_here",
        "SONARCLOUD_ORGANIZATION": "your_org_here"
      }
    }
  }
}

Option 2: Direct Installation

npm install -g community-sonarcloud-mcp-server

Then reference the global installation:

{
  "mcpServers": {
    "community-sonarcloud-mcp": {
      "command": "community-sonarcloud-mcp",
      "env": {
        "SONARCLOUD_TOKEN": "your_token_here",
        "SONARCLOUD_ORGANIZATION": "your_org_here"
      }
    }
  }
}

Getting Your SonarCloud Token

  1. Go to SonarCloud Security Settings
  2. Click Generate Tokens
  3. Give your token a name (e.g., "Claude Code MCP")
  4. Set token permissions:
    • Browse: Required for viewing projects and issues
    • Execute Analysis: Optional (only needed for CI/CD integration)
  5. Generate the token and copy it immediately (you won't see it again)
  6. Add the token to your configuration

Finding Your Organization Key

Your organization key is found in the URL when viewing your SonarCloud organization:

  • URL format: https://sonarcloud.io/organizations/{your-org-key}
  • Example: For URL https://sonarcloud.io/organizations/my-company, the key is my-company

⚠️ Security Note: Never commit your SonarCloud token to version control. Store it securely as an environment variable.

Troubleshooting

"SONARCLOUD_TOKEN is required" error

  • Ensure your token is properly set in environment variables or config
  • Check that the token hasn't been revoked or expired in SonarCloud
  • Verify the token has the correct permissions (Browse is minimum required)

"Failed to connect" in Claude Code

  • Verify the organization name matches exactly (case-sensitive)
  • Check that your organization key is correct (found in SonarCloud URL)
  • Ensure the token has access to the specified organization
  • Try running the server directly: SONARCLOUD_TOKEN="your_token" SONARCLOUD_ORGANIZATION="your_org" npx community-sonarcloud-mcp-server

"No projects found" or empty responses

  • Verify your token has Browse permissions for the organization
  • Check that projects exist in the specified organization
  • Ensure your user account has access to the organization's projects

MCP Server not starting

  • Check that Node.js version is compatible (18+)
  • Verify npm/npx is working correctly
  • Try installing globally first: npm install -g community-sonarcloud-mcp-server

Usage Examples

Once configured, you can ask your AI assistant questions like:

  • "What projects do I have in SonarCloud?"
  • "Show me all bugs in my main project"
  • "What's the test coverage for my latest pull request?"
  • "List all critical security vulnerabilities"
  • "Show me the quality gate status for project X"
  • "What coding rules are failing in this project?"

The server will automatically query SonarCloud and return structured data for analysis.

Development

git clone https://github.com/langtind/community-sonarcloud-mcp-server.git
cd community-sonarcloud-mcp-server
npm install
npm run dev

Building

npm run build
npm start

Testing

# Test the server directly
SONARCLOUD_TOKEN="your_token" SONARCLOUD_ORGANIZATION="your_org" npm start

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

License

MIT License - see LICENSE file for details.

Related Projects

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选