Skip to content

Conversation

@eray-felek-sonarsource
Copy link
Contributor

No description provided.

@eray-felek-sonarsource eray-felek-sonarsource force-pushed the feature/ef/MCP-248-create-a3s-tool branch 2 times, most recently from 301878e to 8a6f907 Compare January 27, 2026 15:50
@eray-felek-sonarsource eray-felek-sonarsource marked this pull request as ready for review January 27, 2026 16:08
@eray-felek-sonarsource eray-felek-sonarsource changed the base branch from master to feature/ef/MCP-245-integrate-with-a3s January 27, 2026 16:19
Comment on lines 284 to 288
* Loads analysis tools based on configuration.
* When advanced analysis is enabled on SonarCloud, registers the advanced remote analysis tool.
* Otherwise, registers local analysis tools (IDE bridge tools or analyze_code_snippet).
*/
private void loadBackendDependentTools() {
private void loadAnalysisTools() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd keep the previous name loadBackendDependentTools, it's important because otherwise we would simply add these tools where others are declared.

Copy link
Contributor Author

@eray-felek-sonarsource eray-felek-sonarsource Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My only concern is that this tool does not depend on backend and it would be very hard for someone to understand why we have this tool under a function named this way. I think a better option would having the check higher level and calling either loadBackendDependentTools or loadAdvancedAnalysis(making it a separate function) WDYT?


import static org.assertj.core.api.Assertions.assertThat;

class AdvancedAnalysisEnablementTest {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need this test class

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was for coverage

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to keep it I'd move it somewhere else, it's currently at the root of the test folder

@eray-felek-sonarsource eray-felek-sonarsource force-pushed the feature/ef/MCP-248-create-a3s-tool branch from 8a6f907 to 2e99400 Compare January 28, 2026 08:52
@eray-felek-sonarsource eray-felek-sonarsource force-pushed the feature/ef/MCP-248-create-a3s-tool branch from 2e99400 to 2108f70 Compare January 28, 2026 09:05
@sonarqubecloud
Copy link

SonarQube reviewer guide

Important

We are currently testing different models for AI Summary.
Please give us your feedback by filling this form.

Model A:

Summary: Add advanced analysis mode for SonarCloud with feature flag to replace local analysis tools

Review Focus: The conditional tool loading logic in SonarQubeMcpServer.initializeBasicServicesAndTools() that switches between standard and advanced analysis modes based on environment flag and SonarCloud detection. The new tool currently only returns a placeholder "Hello, World" response.

Start review at: src/main/java/org/sonarsource/sonarqube/mcp/SonarQubeMcpServer.java. This file contains the core branching logic that determines which analysis tools are loaded and includes the important fallback behavior for non-SonarCloud environments.

Model B:

Summary: Add support for advanced code analysis mode on SonarCloud, controlled by the SONARQUBE_ADVANCED_ANALYSIS_ENABLED environment variable. When enabled on SonarCloud, the new run_advanced_code_analysis tool replaces local analysis tools.

Review Focus:

  • The conditional logic in SonarQubeMcpServer.initializeBasicServicesAndTools() that switches between advanced and standard analysis paths—ensure the SonarCloud detection and fallback behavior are correct.
  • The RunAdvancedCodeAnalysisTool currently returns a placeholder "Hello, World" response and will need actual implementation.
  • Verify that disabling local analysis tools when advanced mode is active doesn't break dependent functionality.

Start review at: src/main/java/org/sonarsource/sonarqube/mcp/SonarQubeMcpServer.java. This is the entry point where the feature is gated and tool loading strategy is determined. Understanding the initialization flow and conditional tool registration is critical to validating the overall design.

Review in SonarQube
See all code changes, issues, and quality metrics in one place.

Quality Gate Passed Quality Gate passed

Issues
0 New issues
1 Accepted issue
0 Dependency risks

Measures
0 Security Hotspots
96.9% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarQube Cloud

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces an advanced analysis tool for SonarCloud environments, allowing users to opt into a new analysis mode that replaces local analysis tools with a remote advanced analysis capability.

Changes:

  • Added RunAdvancedCodeAnalysisTool - a new tool that provides advanced code analysis functionality (currently returns "Hello, World" as a placeholder implementation)
  • Added configuration support via SONARQUBE_ADVANCED_ANALYSIS_ENABLED environment variable/system property
  • Implemented conditional tool loading logic that enables advanced analysis tools on SonarCloud while falling back to standard analysis on SonarQube Server

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/main/java/org/sonarsource/sonarqube/mcp/tools/analysis/RunAdvancedCodeAnalysisTool.java New tool implementation with placeholder "Hello, World" response
src/main/java/org/sonarsource/sonarqube/mcp/configuration/McpServerLaunchConfiguration.java Added configuration field and getter for advanced analysis enablement flag
src/main/java/org/sonarsource/sonarqube/mcp/SonarQubeMcpServer.java Modified tool loading logic to conditionally load advanced or standard analysis tools based on configuration
src/test/java/org/sonarsource/sonarqube/mcp/tools/analysis/RunAdvancedCodeAnalysisToolTests.java Added unit tests for the new tool's basic properties and placeholder behavior
src/test/java/org/sonarsource/sonarqube/mcp/configuration/McpServerLaunchConfigurationTest.java Added tests for parsing and handling the new configuration flag
src/test/java/org/sonarsource/sonarqube/mcp/AdvancedAnalysisEnablementTest.java Added integration tests verifying tool registration behavior and fallback logic
README.md Updated documentation to describe the new advanced analysis feature and configuration

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

}
loadBackendDependentTools();
}

Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The loadProxiedServerTools() call has been removed from the initialization flow, which means proxied MCP servers and their tools will never be loaded. This breaks functionality that depends on proxied tools. The call to loadProxiedServerTools() should be restored after the conditional tool loading logic.

Suggested change
loadProxiedServerTools();

Copilot uses AI. Check for mistakes.
Comment on lines +290 to +292
private void loadAdvancedAnalysisTools() {
supportedTools.add(new RunAdvancedCodeAnalysisTool());
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure we need a method for a single line addition to a list

| Toolset | Key | Description |
|--------------------|---------------------|----------------------------------------------------------------------|
| **Analysis** | `analysis` | Code analysis tools (analyze code snippets and files) |
| **Analysis** | `analysis` | Code analysis tools (local analysis and advanced analysis) |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should mention that it's remote

super(SchemaToolBuilder.forOutput(RunAdvancedCodeAnalysisToolResponse.class)
.setName(TOOL_NAME)
.setTitle("Advanced Code Analysis")
.setDescription("Run advanced code analysis remotely using SonarCloud advanced analysis.")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.setDescription("Run advanced code analysis remotely using SonarCloud advanced analysis.")
.setDescription("Run advanced code analysis remotely using SonarQube Cloud advanced analysis.")

@SonarSource SonarSource deleted a comment from Copilot AI Jan 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants