@theronap/cortex-mcp 0.4.0 → 0.4.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.
@@ -16,7 +16,7 @@
16
16
  * Get your token from the Cortex console → Connect your AI.
17
17
  */
18
18
 
19
- const VERSION = '0.4.0'
19
+ const VERSION = '0.4.1'
20
20
  const cmd = process.argv[2]
21
21
  const rest = process.argv.slice(3)
22
22
 
@@ -42,20 +42,31 @@ if (cmd === '--help' || cmd === '-h' || cmd === 'help') {
42
42
  process.exit(0)
43
43
  }
44
44
 
45
+ // The network-using subcommands close the global fetch (undici) connections before exit so the
46
+ // process tears down cleanly — without it, process.exit() can race a lingering keep-alive socket
47
+ // and trip a libuv assertion on Windows (src\win\async.c). The MCP server never exits, so it's
48
+ // unaffected and doesn't need this.
45
49
  if (cmd === 'setup') {
46
50
  const { runSetup } = await import('../lib/setup.mjs')
47
51
  await runSetup(rest)
52
+ const { closeFetch } = await import('../lib/diagnose.mjs')
53
+ await closeFetch()
48
54
  process.exit(0)
49
55
  }
50
56
 
51
57
  if (cmd === 'doctor') {
52
58
  const { runDoctor } = await import('../lib/doctor.mjs')
53
- process.exit(await runDoctor())
59
+ const code = await runDoctor()
60
+ const { closeFetch } = await import('../lib/diagnose.mjs')
61
+ await closeFetch()
62
+ process.exit(code)
54
63
  }
55
64
 
56
65
  if (cmd === 'capture') {
57
66
  const { runCapture } = await import('../lib/capture.mjs')
58
67
  await runCapture()
68
+ const { closeFetch } = await import('../lib/diagnose.mjs')
69
+ await closeFetch()
59
70
  process.exit(0)
60
71
  }
61
72
 
package/lib/diagnose.mjs CHANGED
@@ -108,3 +108,14 @@ export async function checkToken(token, base) {
108
108
  } catch { /* context shape changed — non-fatal for a health check */ }
109
109
  return { ok: true, status: 200, projectCount, requestId }
110
110
  }
111
+
112
+ // Release the keep-alive sockets the global fetch (undici) holds, so a short-lived CLI command
113
+ // can tear down cleanly. Without this, calling process.exit() right after a fetch can race a
114
+ // lingering socket handle and trip a libuv assertion on Windows
115
+ // (`!(handle->flags & UV_HANDLE_CLOSING)`, src\win\async.c). Best-effort + never throws.
116
+ export async function closeFetch() {
117
+ try {
118
+ const dispatcher = globalThis[Symbol.for('undici.globalDispatcher.1')]
119
+ if (dispatcher && typeof dispatcher.close === 'function') await dispatcher.close()
120
+ } catch { /* cleanup must never break the caller */ }
121
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theronap/cortex-mcp",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "Connect your AI assistant to Cortex — your org's projects, activity, gaps, and directives, scoped to you.",
5
5
  "type": "module",
6
6
  "bin": {