@commonlyai/mcp 0.3.29 → 0.3.30

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/package.json +1 -1
  2. package/src/index.js +18 -5
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@commonlyai/mcp",
3
3
  "mcpName": "io.github.Team-Commonly/commonly",
4
- "version": "0.3.29",
4
+ "version": "0.3.30",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
7
7
  "type": "git",
package/src/index.js CHANGED
@@ -30,6 +30,7 @@ import { buildTools } from './tools.js';
30
30
  import { PACKAGE_VERSION } from './version.js';
31
31
 
32
32
  const PACKAGE_NAME = '@commonlyai/mcp';
33
+ const CHECK_IN_WAIT_MS = 1000;
33
34
 
34
35
  const main = async () => {
35
36
  // Fail fast on missing env. The MCP host (codex/claude) will surface this
@@ -64,22 +65,34 @@ const main = async () => {
64
65
  return tool.call(req.params.arguments || {});
65
66
  });
66
67
 
67
- const transport = new StdioServerTransport();
68
- await server.connect(transport);
69
-
70
68
  // One authenticated call at start (TASK-345). Until a tool ran, nothing
71
69
  // reached Commonly, so a working install and a broken one looked the same and
72
70
  // the agent never showed as connected. A failure goes to stderr and never
73
71
  // ends the server: stdout belongs to the MCP transport.
74
72
  // Bounded, so a server that never answers cannot keep the process alive
75
- // after the host has gone.
76
- request(config, {
73
+ // after the host has gone. Started before the transport, so it is already
74
+ // on its way when the client's initialize arrives.
75
+ const checkIn = request(config, {
77
76
  method: 'GET', path: '/api/agents/runtime/installations', signal: AbortSignal.timeout(10000),
78
77
  }).catch((e) => {
79
78
  // The status says which kind of failure this is; see docs/MCP_INTEGRATION.md.
80
79
  const status = e.status ? `HTTP ${e.status}: ` : '';
81
80
  process.stderr.write(`[commonly-mcp] could not reach Commonly at start: ${status}${e.message}\n`);
82
81
  });
82
+
83
+ const transport = new StdioServerTransport();
84
+ await server.connect(transport);
85
+
86
+ // `claude mcp list` initializes, prints "Connected" and closes the server,
87
+ // which once came before the check-in landed (Growth's walk, 11-04): the
88
+ // person who added it looked like one who never had. So initialize waits for
89
+ // the check-in, for at most a second, so a slow API never holds startup.
90
+ const deliver = transport.onmessage;
91
+ transport.onmessage = (message, extra) => {
92
+ if (message?.method !== 'initialize') return deliver(message, extra);
93
+ const cap = new Promise((resolve) => { setTimeout(resolve, CHECK_IN_WAIT_MS).unref(); });
94
+ return Promise.race([checkIn, cap]).then(() => deliver(message, extra));
95
+ };
83
96
  };
84
97
 
85
98
  main().catch((e) => {