mirror of
https://github.com/angular/angular.git
synced 2026-11-22 22:55:25 -05:00
refactor(core): update WebMCP tool declaration APIs to include outputSchema
Update `ToolDescriptor`, `declareExperimentalWebMcpTool`, and `provideExperimentalWebMcpTools` to explicitly support the `outputSchema` property. This allows tools to specify their expected return format using standard JSON Schema syntax, ensuring that AI agents know exactly how to interpret the tool execution results.
This commit is contained in:
committed by
Jessica Janiuk
parent
f82d8215f9
commit
ec0f0583c3
@@ -2157,9 +2157,10 @@ export abstract class ViewRef extends ChangeDetectorRef {
|
||||
export type WebMcpClient = ToolExecuteCallbackOptions;
|
||||
|
||||
// @public
|
||||
export interface WebMcpToolDescriptor<InputSchema extends object = object> extends Omit<ModelContextTool, 'execute'> {
|
||||
export interface WebMcpToolDescriptor<InputSchema extends object = object, OutputSchema extends object = object> extends Omit<ModelContextTool, 'execute'> {
|
||||
execute: WebMcpToolExecute<InputSchema>;
|
||||
inputSchema?: InputSchema;
|
||||
outputSchema?: OutputSchema;
|
||||
}
|
||||
|
||||
// @public
|
||||
|
||||
@@ -41,16 +41,25 @@ export type Execute<InputSchema extends object = object> =
|
||||
*
|
||||
* @experimental 22.0
|
||||
*/
|
||||
export interface ToolDescriptor<InputSchema extends object = object> extends Omit<
|
||||
ModelContextTool,
|
||||
'execute'
|
||||
> {
|
||||
export interface ToolDescriptor<
|
||||
InputSchema extends object = object,
|
||||
OutputSchema extends object = object,
|
||||
> extends Omit<ModelContextTool, 'execute'> {
|
||||
/**
|
||||
* 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<InputSchema>;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user