dotnet-ai-mcp-server 1.0.4 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dotnet-ai-mcp-server",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "MCP Server for .NET AI development - provides real code samples from Semantic Kernel, OpenAI .NET, MCP C# SDK, and more",
5
5
  "bin": {
6
6
  "dotnet-ai-mcp-server": "bin/cli.js"
@@ -1,105 +1,54 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- const https = require('https');
4
3
  const fs = require('fs');
5
4
  const path = require('path');
6
5
  const os = require('os');
7
- const { execSync } = require('child_process');
8
6
 
9
- const REPO = 'Ahod26/DotNetAIMCPServer';
10
- const VERSION = require('../package.json').version;
11
-
12
- function getPlatformInfo() {
7
+ function getPlatformBinary() {
13
8
  const platform = os.platform();
14
9
  const arch = os.arch();
15
10
 
16
11
  const platformMap = {
17
- 'darwin-x64': 'dotnet-ai-mcp-server-darwin-x64',
18
- 'darwin-arm64': 'dotnet-ai-mcp-server-darwin-arm64',
19
- 'linux-x64': 'dotnet-ai-mcp-server-linux-x64',
20
- 'linux-arm64': 'dotnet-ai-mcp-server-linux-arm64',
21
- 'win32-x64': 'dotnet-ai-mcp-server-win-x64.exe',
12
+ 'darwin-x64': 'darwin-x64/dotnet-ai-mcp-server',
13
+ 'darwin-arm64': 'darwin-arm64/dotnet-ai-mcp-server',
14
+ 'linux-x64': 'linux-x64/dotnet-ai-mcp-server',
15
+ 'linux-arm64': 'linux-arm64/dotnet-ai-mcp-server',
16
+ 'win32-x64': 'win-x64/dotnet-ai-mcp-server.exe',
22
17
  };
23
18
 
24
19
  const key = `${platform}-${arch}`;
25
- const binaryName = platformMap[key];
26
-
27
- if (!binaryName) {
28
- console.error(`Unsupported platform: ${platform}-${arch}`);
29
- console.error('Supported platforms: darwin-x64, darwin-arm64, linux-x64, linux-arm64, win32-x64');
30
- process.exit(1);
31
- }
32
-
33
- return { binaryName, isWindows: platform === 'win32' };
20
+ return platformMap[key];
34
21
  }
35
22
 
36
- function downloadFile(url, dest) {
37
- return new Promise((resolve, reject) => {
38
- const follow = (url, redirectCount = 0) => {
39
- if (redirectCount > 5) {
40
- reject(new Error('Too many redirects'));
41
- return;
42
- }
23
+ function main() {
24
+ const binarySubpath = getPlatformBinary();
43
25
 
44
- https.get(url, { headers: { 'User-Agent': 'dotnet-ai-mcp-server-npm' } }, (response) => {
45
- if (response.statusCode >= 300 && response.statusCode < 400 && response.headers.location) {
46
- follow(response.headers.location, redirectCount + 1);
47
- return;
48
- }
49
-
50
- if (response.statusCode !== 200) {
51
- reject(new Error(`Failed to download: ${response.statusCode}`));
52
- return;
53
- }
54
-
55
- const file = fs.createWriteStream(dest);
56
- response.pipe(file);
57
- file.on('finish', () => {
58
- file.close();
59
- resolve();
60
- });
61
- file.on('error', (err) => {
62
- fs.unlink(dest, () => {});
63
- reject(err);
64
- });
65
- }).on('error', reject);
66
- };
67
-
68
- follow(url);
69
- });
70
- }
26
+ if (!binarySubpath) {
27
+ console.error(`Unsupported platform: ${os.platform()}-${os.arch()}`);
28
+ console.error('Supported: darwin-x64, darwin-arm64, linux-x64, linux-arm64, win32-x64');
29
+ process.exit(1);
30
+ }
71
31
 
72
- async function main() {
73
- const { binaryName, isWindows } = getPlatformInfo();
74
32
  const binDir = path.join(__dirname, '..', 'bin');
75
- const binaryPath = path.join(binDir, isWindows ? 'dotnet-ai-mcp-server.exe' : 'dotnet-ai-mcp-server');
76
-
77
- // Skip if binary already exists
78
- if (fs.existsSync(binaryPath)) {
79
- console.log('Binary already exists, skipping download.');
80
- return;
33
+ const sourcePath = path.join(binDir, binarySubpath);
34
+ const isWindows = os.platform() === 'win32';
35
+ const targetName = isWindows ? 'dotnet-ai-mcp-server.exe' : 'dotnet-ai-mcp-server';
36
+ const targetPath = path.join(binDir, targetName);
37
+
38
+ if (!fs.existsSync(sourcePath)) {
39
+ console.error(`Binary not found: ${sourcePath}`);
40
+ console.error('The npm package may be corrupted. Try reinstalling.');
41
+ process.exit(1);
81
42
  }
82
43
 
83
- const downloadUrl = `https://github.com/${REPO}/releases/download/v${VERSION}/${binaryName}`;
84
-
85
- console.log(`Downloading ${binaryName}...`);
86
- console.log(`URL: ${downloadUrl}`);
44
+ // Copy platform binary to bin root
45
+ fs.copyFileSync(sourcePath, targetPath);
87
46
 
88
- try {
89
- await downloadFile(downloadUrl, binaryPath);
90
-
91
- if (!isWindows) {
92
- fs.chmodSync(binaryPath, 0o755);
93
- }
94
-
95
- console.log('Download complete!');
96
- } catch (error) {
97
- console.error(`Failed to download binary: ${error.message}`);
98
- console.error('');
99
- console.error('You may need to download it manually from:');
100
- console.error(`https://github.com/${REPO}/releases`);
101
- process.exit(1);
47
+ if (!isWindows) {
48
+ fs.chmodSync(targetPath, 0o755);
102
49
  }
50
+
51
+ console.log('dotnet-ai-mcp-server installed successfully!');
103
52
  }
104
53
 
105
54
  main();