@tmcp/transport-http 0.8.4 → 0.8.6

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 +6 -5
  2. package/src/index.js +21 -12
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@tmcp/transport-http",
3
- "version": "0.8.4",
3
+ "version": "0.8.6",
4
+ "license": "MIT",
4
5
  "description": "Transport for TMCP using HTTP",
5
6
  "type": "module",
6
7
  "main": "src/index.js",
@@ -36,7 +37,7 @@
36
37
  },
37
38
  "dependencies": {
38
39
  "esm-env": "^1.2.2",
39
- "@tmcp/session-manager": "^0.2.1"
40
+ "@tmcp/session-manager": "^0.2.2"
40
41
  },
41
42
  "devDependencies": {
42
43
  "@modelcontextprotocol/sdk": "^1.17.1",
@@ -46,9 +47,9 @@
46
47
  "publint": "^0.3.12",
47
48
  "valibot": "^1.1.0",
48
49
  "vitest": "^4.0.0",
49
- "@tmcp/adapter-valibot": "^0.1.5",
50
- "@tmcp/auth": "^0.4.0",
51
- "tmcp": "^1.19.0"
50
+ "@tmcp/adapter-valibot": "^0.1.6",
51
+ "@tmcp/auth": "^0.4.1",
52
+ "tmcp": "^1.19.4"
52
53
  },
53
54
  "publishConfig": {
54
55
  "access": "public"
package/src/index.js CHANGED
@@ -393,17 +393,28 @@ export class HttpTransport {
393
393
 
394
394
  const session_id_storage = this.#session_id_storage;
395
395
 
396
+ const messages = Array.isArray(body) ? body : [body];
397
+
396
398
  const handle = async () => {
397
- const client_capabilities =
398
- await this.#options.sessionManager.info
399
- .getClientCapabilities(session_id)
400
- .catch(() => undefined);
401
- const client_info = await this.#options.sessionManager.info
402
- .getClientInfo(session_id)
403
- .catch(() => undefined);
404
- const log_level = await this.#options.sessionManager.info
405
- .getLogLevel(session_id)
406
- .catch(() => undefined);
399
+ const init_message = messages.find(
400
+ (/** @type {any} */ m) => m.method === 'initialize',
401
+ );
402
+
403
+ const client_capabilities = init_message
404
+ ? init_message.params?.capabilities
405
+ : await this.#options.sessionManager.info
406
+ .getClientCapabilities(session_id)
407
+ .catch(() => undefined);
408
+ const client_info = init_message
409
+ ? init_message.params?.clientInfo
410
+ : await this.#options.sessionManager.info
411
+ .getClientInfo(session_id)
412
+ .catch(() => undefined);
413
+ const log_level = init_message
414
+ ? undefined
415
+ : await this.#options.sessionManager.info
416
+ .getLogLevel(session_id)
417
+ .catch(() => undefined);
407
418
 
408
419
  const response = await this.#controller_storage.run(
409
420
  controller,
@@ -434,8 +445,6 @@ export class HttpTransport {
434
445
 
435
446
  handle();
436
447
 
437
- const messages = Array.isArray(body) ? body : [body];
438
-
439
448
  const has_request = messages.some((message) => message.id != null);
440
449
 
441
450
  // Determine status code based on response type