@maplezzk/mcps 1.1.4 → 1.1.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.
@@ -182,8 +182,59 @@ const startAction = async (options) => {
182
182
  };
183
183
  const stopAction = async (options) => {
184
184
  try {
185
- await daemonRequest('POST', '/stop');
186
- console.log(chalk.green('Daemon stopped successfully.'));
185
+ const logPath = '/tmp/mcps-daemon/stdout.log';
186
+ const fs = await import('fs');
187
+ // 发送 stop 请求并显示日志
188
+ const requestPromise = daemonRequest('POST', '/stop');
189
+ // 显示关闭日志
190
+ const showLogs = async () => {
191
+ try {
192
+ if (!fs.existsSync(logPath)) {
193
+ return;
194
+ }
195
+ let lastSize = fs.statSync(logPath).size;
196
+ const startTime = Date.now();
197
+ const timeout = 5000; // 5秒超时
198
+ while (Date.now() - startTime < timeout) {
199
+ await new Promise(r => setTimeout(r, 200));
200
+ try {
201
+ const { size: currentSize } = fs.statSync(logPath);
202
+ if (currentSize > lastSize) {
203
+ const buffer = Buffer.alloc(currentSize - lastSize);
204
+ const fd = fs.openSync(logPath, 'r');
205
+ fs.readSync(fd, buffer, 0, currentSize - lastSize, lastSize);
206
+ fs.closeSync(fd);
207
+ const newLogs = buffer.toString('utf-8');
208
+ const relevantLogs = newLogs.split('\n').filter(line => {
209
+ return line.includes('Closing connection to') ||
210
+ line.includes('Shutting down');
211
+ });
212
+ if (relevantLogs.length > 0) {
213
+ relevantLogs.forEach(log => {
214
+ if (log.trim()) {
215
+ console.log(chalk.yellow(log));
216
+ }
217
+ });
218
+ lastSize = currentSize;
219
+ }
220
+ }
221
+ }
222
+ catch (e) {
223
+ // 忽略读取错误
224
+ }
225
+ }
226
+ }
227
+ catch (e) {
228
+ // 忽略日志显示错误
229
+ }
230
+ };
231
+ const [{ ok }] = await Promise.all([
232
+ requestPromise,
233
+ showLogs()
234
+ ]);
235
+ if (ok) {
236
+ console.log(chalk.green('Daemon stopped successfully.'));
237
+ }
187
238
  }
188
239
  catch (e) {
189
240
  console.error(chalk.red('Failed to stop daemon. Is it running?'));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maplezzk/mcps",
3
- "version": "1.1.4",
3
+ "version": "1.1.5",
4
4
  "description": "A CLI to manage and use MCP servers",
5
5
  "publishConfig": {
6
6
  "access": "public"