diff --git a/goldens/public-api/core/index.api.md b/goldens/public-api/core/index.api.md index e8e5b42d383..51c1675b460 100644 --- a/goldens/public-api/core/index.api.md +++ b/goldens/public-api/core/index.api.md @@ -2157,9 +2157,10 @@ export abstract class ViewRef extends ChangeDetectorRef { export type WebMcpClient = ToolExecuteCallbackOptions; // @public -export interface WebMcpToolDescriptor extends Omit { +export interface WebMcpToolDescriptor extends Omit { execute: WebMcpToolExecute; inputSchema?: InputSchema; + outputSchema?: OutputSchema; } // @public diff --git a/packages/core/src/webmcp/types.ts b/packages/core/src/webmcp/types.ts index bdab6dfabfc..8f08a3652a3 100644 --- a/packages/core/src/webmcp/types.ts +++ b/packages/core/src/webmcp/types.ts @@ -41,16 +41,25 @@ export type Execute = * * @experimental 22.0 */ -export interface ToolDescriptor extends Omit< - ModelContextTool, - 'execute' -> { +export interface ToolDescriptor< + InputSchema extends object = object, + OutputSchema extends object = object, +> extends Omit { /** * A schema which describes the input arguments expected by the {@link execute} function * which the agent must provide. */ inputSchema?: InputSchema; + /** + * A schema which describes the format of the output data. + * + * Note: This schema is used purely for metadata purposes to inform AI agents of the expected + * output format. Angular does not validate that the return value of `execute` strictly adheres + * to this schema. + */ + outputSchema?: OutputSchema; + /** The callback function which implements this tool. */ execute: Execute; } diff --git a/packages/core/test/webmcp/declare_tool_spec.ts b/packages/core/test/webmcp/declare_tool_spec.ts index bc105695b0f..9831a0a957f 100644 --- a/packages/core/test/webmcp/declare_tool_spec.ts +++ b/packages/core/test/webmcp/declare_tool_spec.ts @@ -230,6 +230,12 @@ describe('declareExperimentalWebMcpTool', () => { required: ['foo'], additionalProperties: false, }, + outputSchema: { + type: 'object', + properties: { + success: {type: 'boolean'}, + }, + }, execute: (args) => { // Verify assignability. const _assignable: {foo?: string; bar?: number} = args;