tmcp 1.15.3 → 1.15.4
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 +1 -1
- package/src/index.js +27 -9
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -467,7 +467,15 @@ export class McpServer {
|
|
|
467
467
|
async ({ name, arguments: args }) => {
|
|
468
468
|
const tool = this.#tools.get(name);
|
|
469
469
|
if (!tool) {
|
|
470
|
-
|
|
470
|
+
return /** @type {CallToolResult<any>} */ ({
|
|
471
|
+
isError: true,
|
|
472
|
+
content: [
|
|
473
|
+
{
|
|
474
|
+
type: 'text',
|
|
475
|
+
text: `Tool ${name} not found`,
|
|
476
|
+
},
|
|
477
|
+
],
|
|
478
|
+
});
|
|
471
479
|
}
|
|
472
480
|
|
|
473
481
|
// Validate input arguments if schema is provided
|
|
@@ -478,10 +486,15 @@ export class McpServer {
|
|
|
478
486
|
if (validation_result instanceof Promise)
|
|
479
487
|
validation_result = await validation_result;
|
|
480
488
|
if (validation_result.issues) {
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
489
|
+
return /** @type {CallToolResult<any>} */ ({
|
|
490
|
+
isError: true,
|
|
491
|
+
content: [
|
|
492
|
+
{
|
|
493
|
+
type: 'text',
|
|
494
|
+
text: `Invalid arguments for tool ${name}: ${JSON.stringify(validation_result.issues)}`,
|
|
495
|
+
},
|
|
496
|
+
],
|
|
497
|
+
});
|
|
485
498
|
}
|
|
486
499
|
validated_args = validation_result.value;
|
|
487
500
|
}
|
|
@@ -508,10 +521,15 @@ export class McpServer {
|
|
|
508
521
|
if (output_validation instanceof Promise)
|
|
509
522
|
output_validation = await output_validation;
|
|
510
523
|
if (output_validation.issues) {
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
524
|
+
return /** @type {CallToolResult<any>} */ ({
|
|
525
|
+
isError: true,
|
|
526
|
+
content: [
|
|
527
|
+
{
|
|
528
|
+
type: 'text',
|
|
529
|
+
text: `Tool ${name} returned invalid structured content: ${JSON.stringify(output_validation.issues)}`,
|
|
530
|
+
},
|
|
531
|
+
],
|
|
532
|
+
});
|
|
515
533
|
}
|
|
516
534
|
// Update with validated structured content
|
|
517
535
|
parsed_result.structuredContent = output_validation.value;
|