Skip to content

Commit 6049427

Browse files
Merge pull request #11356 from srnagar/azmcp-name-update
Update the Azure MCP server name from releases list
2 parents 97e76ea + 3a5fc99 commit 6049427

File tree

3 files changed

+41
-33
lines changed

3 files changed

+41
-33
lines changed

PluginsAndFeatures/azure-toolkit-for-intellij/azure-intellij-plugin-azuremcp/src/main/java/com/microsoft/azure/toolkit/intellij/azuremcp/AzureMcpPackageManager.java

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
import com.intellij.openapi.application.PathManager;
44
import lombok.extern.slf4j.Slf4j;
55
import org.apache.commons.codec.digest.DigestUtils;
6-
import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
7-
import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
8-
import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream;
96
import org.apache.commons.lang3.StringUtils;
107
import org.apache.commons.lang3.SystemUtils;
118
import org.jetbrains.annotations.NotNull;
@@ -40,7 +37,7 @@ public synchronized File getAzureMcpExecutable() {
4037

4138
final Optional<GithubAsset> githubAsset = latestRelease.getAssets()
4239
.stream()
43-
.filter(asset -> asset.getName().startsWith("azure-mcp-" + platform))
40+
.filter(asset -> asset.getName().startsWith("Azure.Mcp.Server-" + platform))
4441
.findFirst();
4542

4643
if (githubAsset.isPresent()) {
@@ -58,13 +55,13 @@ public synchronized File getAzureMcpExecutable() {
5855
final File azMcpExe = new File(executablePath);
5956
if (!azMcpExe.exists()) {
6057
Files.writeString(versionFile, tagName, StandardOpenOption.CREATE, StandardOpenOption.WRITE);
61-
final File azMcpTgz = new File(azMcpDir, "azmcp_" + tagName + ".tgz");
62-
log.info("Downloading Azure MCP Server to: " + azMcpTgz.getAbsolutePath());
63-
final boolean downloaded = gitHubClient.downloadToFile(asset.getBrowserDownloadUrl(), azMcpTgz);
64-
if (downloaded && digestMatches(azMcpTgz, asset.getDigest())) {
58+
final File azMcpZip = new File(azMcpDir, "azmcp_" + tagName + ".zip");
59+
log.info("Downloading Azure MCP Server to: " + azMcpZip.getAbsolutePath());
60+
final boolean downloaded = gitHubClient.downloadToFile(asset.getBrowserDownloadUrl(), azMcpZip);
61+
if (downloaded && digestMatches(azMcpZip, asset.getDigest())) {
6562
log.info("Downloaded Azure MCP Server successfully in " + (System.currentTimeMillis() - startTime) + " ms");
6663
log.info("Extracting Azure MCP Server to: " + extractedDir.getAbsolutePath());
67-
extractTarGz(azMcpTgz, extractedDir);
64+
extractZip(azMcpZip, extractedDir);
6865
log.info("Azure MCP Server extracted successfully to: " + extractedDir.getAbsolutePath());
6966
}
7067
}
@@ -83,11 +80,11 @@ public synchronized File getAzureMcpExecutable() {
8380
return null;
8481
}
8582

86-
private boolean digestMatches(File azMcpTgz, String expectedDigest) {
83+
private boolean digestMatches(File azMcpZip, String expectedDigest) {
8784
try {
8885
// GitHub releases API computes the SHA-256 digest of the file contents.
8986
// https://github.blog/changelog/2025-06-03-releases-now-expose-digests-for-release-assets/
90-
final String downloadFileDigest = DigestUtils.sha256Hex(new FileInputStream(azMcpTgz));
87+
final String downloadFileDigest = DigestUtils.sha256Hex(new FileInputStream(azMcpZip));
9188
return StringUtils.equalsIgnoreCase("sha256:" + downloadFileDigest, expectedDigest);
9289
} catch (final Exception e) {
9390
log.error("Failed to calculate file digest", e);
@@ -134,28 +131,28 @@ private static void delete(Path path) {
134131
}
135132

136133
private @NotNull String getExecutableRelativePath() {
137-
String executablePath = "/package/dist/azmcp";
134+
String executablePath = "/azmcp";
138135
if (SystemUtils.IS_OS_WINDOWS) {
139136
executablePath += ".exe";
140137
}
141138
return executablePath;
142139
}
143140

144-
private void extractTarGz(File tarGzFile, File destDir) throws IOException {
145-
try (final TarArchiveInputStream tarIn = new TarArchiveInputStream(
146-
new GzipCompressorInputStream(
147-
new FileInputStream(tarGzFile)))) {
148-
TarArchiveEntry entry;
149-
while ((entry = tarIn.getNextTarEntry()) != null) {
150-
final File outputFile = new File(destDir, entry.getName());
151-
if (entry.isDirectory()) {
152-
if (!outputFile.exists()) {
153-
outputFile.mkdirs();
154-
}
141+
private void extractZip(File zipFile, File destDir) throws IOException {
142+
try (final java.util.zip.ZipInputStream zis = new java.util.zip.ZipInputStream(new FileInputStream(zipFile))) {
143+
java.util.zip.ZipEntry zipEntry;
144+
while ((zipEntry = zis.getNextEntry()) != null) {
145+
final File outputFile = new File(destDir, zipEntry.getName());
146+
if (zipEntry.isDirectory()) {
147+
if (!outputFile.exists()) outputFile.mkdirs();
155148
} else {
156-
outputFile.getParentFile().mkdirs();
149+
if (!outputFile.getParentFile().exists()) outputFile.getParentFile().mkdirs();
157150
try (final FileOutputStream fos = new FileOutputStream(outputFile)) {
158-
tarIn.transferTo(fos);
151+
final byte[] buffer = new byte[4096];
152+
int len;
153+
while ((len = zis.read(buffer)) > 0) {
154+
fos.write(buffer, 0, len);
155+
}
159156
}
160157
}
161158
}
@@ -164,13 +161,13 @@ private void extractTarGz(File tarGzFile, File destDir) throws IOException {
164161

165162
private static String getPlatformIdentifier() {
166163
// Operating System detection
167-
String os = null;
164+
final String os;
168165
if (SystemUtils.IS_OS_WINDOWS) {
169-
os = "win32";
166+
os = "win";
170167
} else if (SystemUtils.IS_OS_LINUX) {
171168
os = "linux";
172169
} else if (SystemUtils.IS_OS_MAC) {
173-
os = "darwin";
170+
os = "osx";
174171
} else {
175172
throw new RuntimeException("Unsupported OS " + SystemUtils.OS_NAME);
176173
}

PluginsAndFeatures/azure-toolkit-for-intellij/azure-intellij-plugin-azuremcp/src/main/java/com/microsoft/azure/toolkit/intellij/azuremcp/GithubClient.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,18 @@ public class GithubClient implements Closeable {
2929
private static final String AZURE_MCP_RELEASE_URL = "https://api.github.com/repos/microsoft/mcp/releases";
3030
private static final TypeReference<List<GithubRelease>> GITHUB_RELEASE_LIST_TYPE = new TypeReference<>() {
3131
};
32+
private static final String AZURE_MCP_SERVER = "Azure.Mcp.Server";
3233

3334
private final CloseableHttpClient httpClient = HttpClients.createDefault();
3435

3536
public GithubRelease getLatestAzureMcpRelease() {
3637
final HttpUriRequest request = RequestBuilder.get().setUri(AZURE_MCP_RELEASE_URL).build();
3738
try (final CloseableHttpResponse response = httpClient.execute(request)) {
3839
final List<GithubRelease> releases = OBJECT_MAPPER.readValue(response.getEntity().getContent(), GITHUB_RELEASE_LIST_TYPE);
39-
return releases.stream().findFirst().orElse(null);
40+
return releases.stream()
41+
.filter(release -> release.getName() != null && release.getName().startsWith(AZURE_MCP_SERVER))
42+
.findFirst()
43+
.orElse(null);
4044
} catch (final IOException exception) {
4145
log.error("Error getting latest Azure MCP release details: " + exception.getMessage());
4246
AzureMcpUtils.logErrorTelemetryEvent("azmcp-get-latest-release-failed", exception);

PluginsAndFeatures/azure-toolkit-for-intellij/azure-intellij-plugin-azuremcp/src/main/java/com/microsoft/azure/toolkit/intellij/azuremcp/GithubCopilotMcpInitializer.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ public class GithubCopilotMcpInitializer implements ProjectActivity, DumbAware,
3939

4040
private static final ComparableVersion LOWEST_SUPPORTED_COPILOT_VERSION = new ComparableVersion("1.5.50");
4141
private static final String COPILOT_PLUGIN_ID = "com.github.copilot";
42+
private static final String AZURE_MCP_SERVER_NAME = "Azure MCP Server IntelliJ";
43+
private static final String LEGACY_SERVER_NAME = "Azure MCP Server";
4244
private final AzureMcpPackageManager azureMcpPackageManager;
4345

4446
public GithubCopilotMcpInitializer() {
@@ -49,6 +51,7 @@ public GithubCopilotMcpInitializer() {
4951
public Object execute(@NotNull Project project, @NotNull Continuation<? super Unit> continuation) {
5052

5153
if (Registry.is("azure.mcp.ghcp.autoconfigure.disabled", false)) {
54+
logTelemetryEvent("azmcp-copilot-initialization-disabled");
5255
return null;
5356
}
5457

@@ -114,11 +117,15 @@ private void configureMcpServer(File azMcpExe) throws Exception {
114117
final McpServer azureMcpServer = new McpServer();
115118
azureMcpServer.setCommand(azMcpExe.getAbsolutePath());
116119
azureMcpServer.setArgs(Arrays.asList("server", "start"));
117-
if (servers.containsKey("Azure MCP Server")) {
118-
servers.remove("Azure MCP Server");
120+
servers.remove(LEGACY_SERVER_NAME); // legacy name - remove if it exists
121+
122+
if (servers.containsKey(AZURE_MCP_SERVER_NAME)) {
123+
final McpServer existingConfig = servers.get(AZURE_MCP_SERVER_NAME);
124+
if (!azureMcpServer.getCommand().equals(existingConfig.getCommand())) {
125+
servers.put(AZURE_MCP_SERVER_NAME, azureMcpServer);
126+
Files.writeString(mcpConfigPath, OBJECT_MAPPER.writeValueAsString(mcpConfig));
127+
}
119128
}
120-
servers.put("Azure MCP Server IntelliJ", azureMcpServer);
121-
Files.writeString(mcpConfigPath, OBJECT_MAPPER.writeValueAsString(mcpConfig));
122129
logTelemetryEvent("azmcp-copilot-initialization-success");
123130
}
124131

0 commit comments

Comments
 (0)