tmcp 1.15.3 → 1.15.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +36 -25
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tmcp",
3
- "version": "1.15.3",
3
+ "version": "1.15.5",
4
4
  "description": "The main tmcp library",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
package/src/index.js CHANGED
@@ -205,11 +205,6 @@ export class McpServer {
205
205
  */
206
206
  #client_info_map = new Map();
207
207
 
208
- /**
209
- * @type {Map<string|undefined, string>}
210
- */
211
- #negotiated_protocol_versions = new Map();
212
-
213
208
  /**
214
209
  * @type {Map<string|undefined, LoggingLevel>}
215
210
  */
@@ -250,12 +245,6 @@ export class McpServer {
250
245
  validated_initialize.protocolVersion,
251
246
  );
252
247
 
253
- // Store negotiated protocol version
254
- this.#negotiated_protocol_versions.set(
255
- session_id,
256
- negotiated_version,
257
- );
258
-
259
248
  // Store client capabilities
260
249
  this.#client_capabilities_map.set(
261
250
  session_id,
@@ -467,7 +456,15 @@ export class McpServer {
467
456
  async ({ name, arguments: args }) => {
468
457
  const tool = this.#tools.get(name);
469
458
  if (!tool) {
470
- throw new McpError(-32601, `Tool ${name} not found`);
459
+ return /** @type {CallToolResult<any>} */ ({
460
+ isError: true,
461
+ content: [
462
+ {
463
+ type: 'text',
464
+ text: `Tool ${name} not found`,
465
+ },
466
+ ],
467
+ });
471
468
  }
472
469
 
473
470
  // Validate input arguments if schema is provided
@@ -478,10 +475,15 @@ export class McpServer {
478
475
  if (validation_result instanceof Promise)
479
476
  validation_result = await validation_result;
480
477
  if (validation_result.issues) {
481
- throw new McpError(
482
- -32602,
483
- `Invalid arguments for tool ${name}: ${JSON.stringify(validation_result.issues)}`,
484
- );
478
+ return /** @type {CallToolResult<any>} */ ({
479
+ isError: true,
480
+ content: [
481
+ {
482
+ type: 'text',
483
+ text: `Invalid arguments for tool ${name}: ${JSON.stringify(validation_result.issues)}`,
484
+ },
485
+ ],
486
+ });
485
487
  }
486
488
  validated_args = validation_result.value;
487
489
  }
@@ -508,10 +510,15 @@ export class McpServer {
508
510
  if (output_validation instanceof Promise)
509
511
  output_validation = await output_validation;
510
512
  if (output_validation.issues) {
511
- throw new McpError(
512
- -32603,
513
- `Tool ${name} returned invalid structured content: ${JSON.stringify(output_validation.issues)}`,
514
- );
513
+ return /** @type {CallToolResult<any>} */ ({
514
+ isError: true,
515
+ content: [
516
+ {
517
+ type: 'text',
518
+ text: `Tool ${name} returned invalid structured content: ${JSON.stringify(output_validation.issues)}`,
519
+ },
520
+ ],
521
+ });
515
522
  }
516
523
  // Update with validated structured content
517
524
  parsed_result.structuredContent = output_validation.value;
@@ -1174,11 +1181,15 @@ export class McpServer {
1174
1181
 
1175
1182
  const sessions = [];
1176
1183
 
1177
- for (let [session_id, session_log_level] of this.#session_log_levels) {
1178
- // Check if the current log level should be sent based on severity
1179
- if (this.#should_log(level, session_log_level)) {
1180
- sessions.push(session_id);
1181
- }
1184
+ const current_session_level = this.#session_log_levels.get(
1185
+ this.#session_id,
1186
+ );
1187
+
1188
+ if (
1189
+ current_session_level &&
1190
+ this.#should_log(level, current_session_level)
1191
+ ) {
1192
+ sessions.push(this.#session_id);
1182
1193
  }
1183
1194
 
1184
1195
  if (sessions.length === 0) return;