@giantswarm-io/pro 1.11.0 → 1.11.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@giantswarm-io/pro",
3
- "version": "1.11.0",
3
+ "version": "1.11.1",
4
4
  "description": "Core library and MCP server for managing Giant Swarm's roadmap and customer project boards",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -51,11 +51,15 @@ const sessions = {};
51
51
  * @param {Object} options
52
52
  * @param {number} options.port - Port to listen on (default: 8080; 0 picks a free port)
53
53
  * @param {string} options.endpoint - MCP endpoint path (default: /mcp)
54
+ * @param {number} options.sessionTtlMs - Idle time after which a session is evicted (default: 30 minutes)
55
+ * @param {number} options.sessionSweepIntervalMs - How often idle sessions are swept (default: 5 minutes)
54
56
  * @returns {Promise<import('http').Server>} the listening server
55
57
  */
56
58
  export async function startHTTPServer(options = {}) {
57
59
  const port = options.port ?? (parseInt(process.env.HTTP_PORT, 10) || DEFAULT_PORT);
58
60
  const endpoint = options.endpoint || DEFAULT_ENDPOINT;
61
+ const sessionTtlMs = options.sessionTtlMs ?? SESSION_TTL_MS;
62
+ const sessionSweepIntervalMs = options.sessionSweepIntervalMs ?? SESSION_SWEEP_INTERVAL_MS;
59
63
 
60
64
  const app = express();
61
65
  // Trust exactly 1 proxy hop (Envoy Gateway). express-rate-limit requires
@@ -208,11 +212,13 @@ export async function startHTTPServer(options = {}) {
208
212
  await transport.handleRequest(req, res, req.body);
209
213
  return;
210
214
  } else if (sessionId) {
211
- // Session ID provided but not found — expired or invalid
212
- res.status(400).json({
215
+ // Session ID provided but not found — expired or invalid. The MCP
216
+ // spec (Streamable HTTP, session management) requires 404 here: it is
217
+ // the client's signal to start a new session with a fresh initialize.
218
+ res.status(404).json({
213
219
  jsonrpc: '2.0',
214
220
  error: {
215
- code: -32000,
221
+ code: -32001,
216
222
  message: 'Session not found or expired'
217
223
  },
218
224
  id: null
@@ -246,7 +252,7 @@ export async function startHTTPServer(options = {}) {
246
252
  const sweepInterval = setInterval(() => {
247
253
  const now = Date.now();
248
254
  for (const sessionId in sessions) {
249
- if (now - sessions[sessionId].lastActivity > SESSION_TTL_MS) {
255
+ if (now - sessions[sessionId].lastActivity > sessionTtlMs) {
250
256
  logger.info(`Evicting idle session: ${sessionId}`);
251
257
  try {
252
258
  sessions[sessionId].transport.close();
@@ -256,7 +262,7 @@ export async function startHTTPServer(options = {}) {
256
262
  delete sessions[sessionId];
257
263
  }
258
264
  }
259
- }, SESSION_SWEEP_INTERVAL_MS);
265
+ }, sessionSweepIntervalMs);
260
266
  sweepInterval.unref();
261
267
 
262
268
  // Start listening