33import com .intellij .openapi .application .PathManager ;
44import lombok .extern .slf4j .Slf4j ;
55import 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 ;
96import org .apache .commons .lang3 .StringUtils ;
107import org .apache .commons .lang3 .SystemUtils ;
118import 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 }
0 commit comments