File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed
Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ export class ListDatabasesTool extends MongoDBToolBase {
1111 public name = "list-databases";
1212 protected description = "List all databases for a MongoDB connection";
1313 protected argsShape = {};
14- protected override outputSchema = ListDatabasesOutputSchema;
14+ protected override uiOutputSchema = ListDatabasesOutputSchema;
1515 static operationType: OperationType = "metadata";
1616
1717 protected async execute(): Promise<CallToolResult> {
Original file line number Diff line number Diff line change @@ -282,6 +282,9 @@ export abstract class ToolBase {
282282 /**
283283 * Optional Zod schema defining the tool's structured output.
284284 *
285+ * This schema is registered with the MCP server and used to validate
286+ * `structuredContent` in the tool's response.
287+ *
285288 * @example
286289 * ```typescript
287290 * protected outputSchema = {
@@ -300,6 +303,12 @@ export abstract class ToolBase {
300303 */
301304 protected outputSchema?: ZodRawShape;
302305
306+ /**
307+ * Optional Zod schema for structured output when mcpUI feature is enabled.
308+ * Takes precedence over `outputSchema` when defined and mcpUI is active.
309+ */
310+ protected uiOutputSchema?: ZodRawShape;
311+
303312 private registeredTool: RegisteredTool | undefined;
304313
305314 protected get annotations(): ToolAnnotations {
@@ -525,7 +534,9 @@ export abstract class ToolBase {
525534 {
526535 description: this.description,
527536 inputSchema: this.argsShape,
528- outputSchema: this.outputSchema,
537+ outputSchema: this.isFeatureEnabled("mcpUI")
538+ ? (this.uiOutputSchema ?? this.outputSchema)
539+ : this.outputSchema,
529540 annotations: this.annotations,
530541 },
531542 callback
You can’t perform that action at this time.
0 commit comments