aira-mcp 1.0.0 → 1.0.1

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.
Files changed (2) hide show
  1. package/index.js +12 -11
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -67,7 +67,7 @@ app.post('/download', async (req, res) => {
67
67
  const result = await aria2.call('addUri', [uri], options || {});
68
68
  res.json({ success: true, gid: result });
69
69
  } catch (error) {
70
- console.error('Error adding URI to aria2:', error);
70
+ process.stderr.write(`Error adding URI to aria2: ${error}\n`);
71
71
  res.status(500).json({ error: `Failed to add URI to aria2: ${error.message}` });
72
72
  }
73
73
  });
@@ -85,7 +85,7 @@ app.post('/download/magnet', async (req, res) => {
85
85
  const result = await aria2.call('addUri', [magnetUri], options || {});
86
86
  res.json({ success: true, gid: result });
87
87
  } catch (error) {
88
- console.error('Error adding magnet to aria2:', error);
88
+ process.stderr.write(`Error adding magnet to aria2: ${error}\n`);
89
89
  res.status(500).json({ error: `Failed to add magnet to aria2: ${error.message}` });
90
90
  }
91
91
  });
@@ -97,7 +97,7 @@ app.get('/download/:gid', async (req, res) => {
97
97
  const result = await aria2.call('tellStatus', gid);
98
98
  res.json({ success: true, status: result });
99
99
  } catch (error) {
100
- console.error('Error getting download status from aria2:', error);
100
+ process.stderr.write(`Error getting download status from aria2: ${error}\n`);
101
101
  res.status(500).json({ error: `Failed to get download status from aria2: ${error.message}` });
102
102
  }
103
103
  });
@@ -109,7 +109,7 @@ app.post('/download/:gid/pause', async (req, res) => {
109
109
  await aria2.call('pause', gid);
110
110
  res.json({ success: true, message: 'Download paused' });
111
111
  } catch (error) {
112
- console.error('Error pausing download in aria2:', error);
112
+ process.stderr.write(`Error pausing download in aria2: ${error}\n`);
113
113
  res.status(500).json({ error: `Failed to pause download in aria2: ${error.message}` });
114
114
  }
115
115
  });
@@ -121,7 +121,7 @@ app.post('/download/:gid/resume', async (req, res) => {
121
121
  await aria2.call('unpause', gid);
122
122
  res.json({ success: true, message: 'Download resumed' });
123
123
  } catch (error) {
124
- console.error('Error resuming download in aria2:', error);
124
+ process.stderr.write(`Error resuming download in aria2: ${error}\n`);
125
125
  res.status(500).json({ error: `Failed to resume download in aria2: ${error.message}` });
126
126
  }
127
127
  });
@@ -133,26 +133,27 @@ app.delete('/download/:gid', async (req, res) => {
133
133
  await aria2.call('remove', gid);
134
134
  res.json({ success: true, message: 'Download removed' });
135
135
  } catch (error) {
136
- console.error('Error removing download from aria2:', error);
136
+ process.stderr.write(`Error removing download from aria2: ${error}\n`);
137
137
  res.status(500).json({ error: `Failed to remove download from aria2: ${error.message}` });
138
138
  }
139
139
  });
140
140
 
141
141
  // 启动服务器
142
142
  app.listen(port, () => {
143
- console.log(`MCP Service running at http://localhost:${port}`);
144
- console.log(`Configured to connect to aria2 at ${aria2Secure ? 'https' : 'http'}://${aria2Host}:${aria2Port}${aria2Path}`);
143
+ // 使用stderr输出日志信息,避免干扰MCP的JSON输出
144
+ process.stderr.write(`MCP Service running at http://localhost:${port}\n`);
145
+ process.stderr.write(`Configured to connect to aria2 at ${aria2Secure ? 'https' : 'http'}://${aria2Host}:${aria2Port}${aria2Path}\n`);
145
146
 
146
147
  // 稍后尝试连接aria2服务器
147
148
  setTimeout(async () => {
148
149
  try {
149
150
  // 尝试连接aria2服务器
150
151
  await aria2.open();
151
- console.log('Successfully connected to aria2 server');
152
+ process.stderr.write('Successfully connected to aria2 server\n');
152
153
  await aria2.close(); // 关闭初始连接
153
154
  } catch (error) {
154
- console.warn(`Warning: Could not connect to aria2 server at ${aria2Secure ? 'https' : 'http'}://${aria2Host}:${aria2Port}${aria2Path}:`, error.message);
155
- console.log('MCP Service will still run, but aria2 operations will fail until a valid aria2 server is available.');
155
+ process.stderr.write(`Warning: Could not connect to aria2 server at ${aria2Secure ? 'https' : 'http'}://${aria2Host}:${aria2Port}${aria2Path}: ${error.message}\n`);
156
+ process.stderr.write('MCP Service will still run, but aria2 operations will fail until a valid aria2 server is available.\n');
156
157
  }
157
158
  }, 1000); // 延迟1秒后尝试连接
158
159
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aira-mcp",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "main": "index.js",
5
5
  "bin": {
6
6
  "aira-mcp": "index.js"