Skip to content

Commit aa61700

Browse files
committed
Clean up
1 parent ef6af49 commit aa61700

File tree

12 files changed

+461
-47
lines changed

12 files changed

+461
-47
lines changed

src/main/java/org/sonarsource/sonarqube/mcp/tools/Tool.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,6 @@ public List<String> getOptionalStringList(String argumentName) {
120120
}
121121

122122
public static class Result {
123-
public static Result success(String content, Map<String, Object> structuredContent) {
124-
return new Result(McpSchema.CallToolResult.builder()
125-
.isError(false)
126-
.addTextContent(content)
127-
.structuredContent(structuredContent)
128-
.build());
129-
}
130-
131123
/**
132124
* Create a successful result from a response object.
133125
* The response object will be serialized to both JSON text content and structured content.

src/main/java/org/sonarsource/sonarqube/mcp/tools/analysis/ToggleAutomaticAnalysisTool.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
import org.sonarsource.sonarqube.mcp.bridge.SonarQubeIdeBridgeClient;
2020
import org.sonarsource.sonarqube.mcp.tools.SchemaToolBuilder;
21-
import org.sonarsource.sonarqube.mcp.tools.SchemaUtils;
2221
import org.sonarsource.sonarqube.mcp.tools.Tool;
2322

2423
public class ToggleAutomaticAnalysisTool extends Tool {
@@ -59,7 +58,7 @@ public Result execute(Arguments arguments) {
5958

6059
var message = "Successfully toggled automatic analysis to " + enabled + ".";
6160
var response = new ToggleAutomaticAnalysisToolResponse(true, enabled, message);
62-
return Result.success(message, SchemaUtils.toStructuredContent(response));
61+
return Result.success(response);
6362
}
6463

6564
}

src/main/java/org/sonarsource/sonarqube/mcp/tools/issues/ChangeIssueStatusTool.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import org.sonarsource.sonarqube.mcp.serverapi.ServerApiProvider;
2020
import org.sonarsource.sonarqube.mcp.serverapi.issues.Transition;
2121
import org.sonarsource.sonarqube.mcp.tools.SchemaToolBuilder;
22-
import org.sonarsource.sonarqube.mcp.tools.SchemaUtils;
2322
import org.sonarsource.sonarqube.mcp.tools.Tool;
2423

2524
public class ChangeIssueStatusTool extends Tool {
@@ -46,7 +45,7 @@ public ChangeIssueStatusTool(ServerApiProvider serverApiProvider) {
4645
@Override
4746
public Tool.Result execute(Tool.Arguments arguments) {
4847
var key = arguments.getStringOrThrow(KEY_PROPERTY);
49-
var statusString = arguments.getStringListOrThrow(STATUS_PROPERTY).get(0);
48+
var statusString = arguments.getStringListOrThrow(STATUS_PROPERTY).getFirst();
5049
var status = Transition.fromStatus(statusString);
5150
if (status.isEmpty()) {
5251
return Tool.Result.failure("Status is unknown: " + statusString);
@@ -55,7 +54,7 @@ public Tool.Result execute(Tool.Arguments arguments) {
5554
serverApiProvider.get().issuesApi().doTransition(key, status.get());
5655
var message = "The issue status was successfully changed.";
5756
var response = new ChangeIssueStatusToolResponse(true, message, key, statusString);
58-
return Tool.Result.success(message, SchemaUtils.toStructuredContent(response));
57+
return Tool.Result.success(response);
5958
}
6059

6160
}

src/main/java/org/sonarsource/sonarqube/mcp/tools/system/SystemPingTool.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
import org.sonarsource.sonarqube.mcp.serverapi.ServerApiProvider;
2020
import org.sonarsource.sonarqube.mcp.tools.SchemaToolBuilder;
21-
import org.sonarsource.sonarqube.mcp.tools.SchemaUtils;
2221
import org.sonarsource.sonarqube.mcp.tools.Tool;
2322

2423
public class SystemPingTool extends Tool {
@@ -39,9 +38,8 @@ public SystemPingTool(ServerApiProvider serverApiProvider) {
3938
@Override
4039
public Tool.Result execute(Tool.Arguments arguments) {
4140
var response = serverApiProvider.get().systemApi().getPing();
42-
var trimmedResponse = response.trim();
43-
var toolResponse = new SystemPingToolResponse(trimmedResponse);
44-
return Tool.Result.success(trimmedResponse, SchemaUtils.toStructuredContent(toolResponse));
41+
var toolResponse = new SystemPingToolResponse(response);
42+
return Tool.Result.success(toolResponse);
4543
}
4644

4745
}

src/main/java/org/sonarsource/sonarqube/mcp/tools/webhooks/CreateWebhookTool.java

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
import org.sonarsource.sonarqube.mcp.serverapi.ServerApiProvider;
2020
import org.sonarsource.sonarqube.mcp.tools.SchemaToolBuilder;
21-
import org.sonarsource.sonarqube.mcp.tools.SchemaUtils;
2221
import org.sonarsource.sonarqube.mcp.tools.Tool;
2322

2423
public class CreateWebhookTool extends Tool {
@@ -56,20 +55,8 @@ public Result execute(Arguments arguments) {
5655
var apiResponse = serverApiProvider.get().webhooksApi().createWebhook(name, url, project, secret);
5756
var webhook = apiResponse.webhook();
5857

59-
var resultMessage = """
60-
Webhook created successfully.
61-
Key: %s
62-
Name: %s
63-
URL: %s
64-
Has Secret: %s""".formatted(
65-
webhook.key(),
66-
webhook.name(),
67-
webhook.url(),
68-
webhook.hasSecret() ? "Yes" : "No"
69-
);
70-
7158
var response = new CreateWebhookToolResponse(webhook.key(), webhook.name(), webhook.url(), webhook.hasSecret());
72-
return Result.success(resultMessage, SchemaUtils.toStructuredContent(response));
59+
return Result.success(response);
7360
}
7461

7562
}

0 commit comments

Comments
 (0)