diff --git a/constants.go b/constants.go index f3ddb9d..86a0b74 100644 --- a/constants.go +++ b/constants.go @@ -111,7 +111,6 @@ const ( propRetryPolicy = "retryPolicy" propTaskQueue = "taskQueue" propType = "type" - propScheduleWorkflowName = "scheduleWorkflowName" propScheduleWorkflowType = "scheduleWorkflowType" propScheduleID = "scheduleId" propScheduleInput = "scheduleInput" @@ -124,4 +123,5 @@ const ( propThen = "then" propWorkflowType = "workflowType" propVersion = "version" + propHttp = "http" ) diff --git a/definitions.go b/definitions.go index 2186942..7fcd14a 100644 --- a/definitions.go +++ b/definitions.go @@ -187,7 +187,7 @@ var callTaskDefinition = &jsonschema.Schema{ Properties: map[string]*jsonschema.Schema{ propCall: { Type: typeString, - Const: utils.Ptr[any]("http"), + Const: utils.Ptr[any](propHttp), }, propWith: { Type: typeObject, @@ -254,6 +254,150 @@ var callTaskDefinition = &jsonschema.Schema{ }, }, }, + { + Type: typeObject, + Title: "CallMCP", + Description: "Defines the MCP call to perform.", + UnevaluatedProperties: falseSchema(), + Required: []string{propCall, propWith}, + AllOf: []*jsonschema.Schema{ + {Ref: SchemaRef("taskBase")}, + { + Properties: map[string]*jsonschema.Schema{ + propCall: { + Type: typeString, + Const: utils.Ptr[any]("mcp"), + }, + propWith: { + Type: typeObject, + Title: "MCPArguments", + Description: "The MCP call arguments.", + UnevaluatedProperties: falseSchema(), + Required: []string{propMethod, "transport"}, + Properties: map[string]*jsonschema.Schema{ + "protocolVersion": { + Type: typeString, + Default: json.RawMessage(`"2025-06-18"`), + Title: "McpProtocolVersion", + Description: "The version of the MCP protocol to use.", + }, + propMethod: { + Type: typeString, + Enum: []any{ + "tools/list", + "tools/call", + "prompts/list", + "prompts/get", + "resources/list", + "resources/read", + "resources/templates/list", + }, + Title: "McpMethod", + Description: "The MCP method to call.", + }, + "parameters": { + Title: "McpMethodParameters", + Description: "The MCP method parameters.", + Type: typeObject, + AdditionalProperties: trueSchema(), + }, + "timeout": { + Title: "McpCallTimeout", + Description: "The duration after which the MCP call times out.", + Ref: SchemaRef("duration"), + Default: json.RawMessage(`{"seconds": 30}`), + }, + "transport": { + Type: typeObject, + Title: "McpCallTransport", + Description: "The transport to use to perform the MCP call.", + Properties: map[string]*jsonschema.Schema{ + propHttp: { + Type: typeObject, + Title: "McpHttpTransport", + Description: "The definition of the HTTP transport to use.", + Required: []string{"endpoint"}, + Properties: map[string]*jsonschema.Schema{ + "endpoint": { + Ref: SchemaRef("endpoint"), + Title: "McpHttpTransportEndpoint", + Description: "The MCP server endpoint to connect to.", + }, + "headers": { + Type: typeObject, + AdditionalProperties: &jsonschema.Schema{ + Type: typeString, + }, + Title: "McpHttpTransportHeaders", + Description: "A key/value mapping of the HTTP headers to send with requests, if any.", + }, + }, + }, + "stdio": { + Type: typeObject, + Title: "McpStdioTransport", + Description: "The definition of the STDIO transport to use.", + Required: []string{"command"}, + Properties: map[string]*jsonschema.Schema{ + "command": { + Type: typeString, + Title: "McpStdioTransportCommand", + Description: "The command used to run the MCP server.", + }, + "arguments": { + Type: typeArray, + Items: &jsonschema.Schema{ + Type: typeString, + }, + Title: "McpStdioTransportArguments", + Description: "An optional list of arguments to pass to the command.", + }, + "environment": { + Type: typeObject, + AdditionalProperties: &jsonschema.Schema{ + Type: typeString, + }, + Title: "McpStdioTransportEnvironment", + Description: "A key/value mapping, if any, of environment variables used to configure the MCP server.", + }, + }, + }, + "options": { + Type: typeObject, + AdditionalProperties: &jsonschema.Schema{ + Type: typeObject, + }, + }, + }, + OneOf: []*jsonschema.Schema{ + {Required: []string{propHttp}}, + {Required: []string{"stdio"}}, + }, + }, + "client": { + Type: typeObject, + Title: "McpClient", + Description: "Describes the client used to perform the MCP call.", + Required: []string{propName, propVersion}, + Properties: map[string]*jsonschema.Schema{ + propName: { + Type: typeString, + Title: "McpClientName", + Description: "The name of the client used to connect to the MCP server.", + }, + propVersion: { + Type: typeString, + Title: "McpClientVersion", + Description: "The version of the client used to connect to the MCP server.", + }, + }, + }, + }, + }, + }, + }, + }, + }, }, } @@ -420,13 +564,6 @@ var documentMetadataDefinition = &jsonschema.Schema{ "Defaults to document.workflowType; required when every top-level task is a Do task.", MinLength: utils.Ptr(1), }, - propScheduleWorkflowName: { - Type: typeString, - Title: "ScheduleWorkflowName", - Description: "Deprecated: use scheduleWorkflowType.", - MinLength: utils.Ptr(1), - Deprecated: true, - }, propScheduleID: { Type: typeString, Title: "ScheduleID", diff --git a/definitions_test.go b/definitions_test.go index 181d306..ce24cc9 100644 --- a/definitions_test.go +++ b/definitions_test.go @@ -246,11 +246,11 @@ func TestCallTaskDefinitionVariants(t *testing.T) { consts = append(consts, callConst(s)) } - for _, want := range []string{"activity", "grpc", "http"} { + for _, want := range []string{"activity", "grpc", "http", "mcp"} { assert.True(t, slices.Contains(consts, want), "callTask should support %q", want) } - for _, absent := range []string{"asyncapi", "openapi", "mcp", "a2a"} { + for _, absent := range []string{"asyncapi", "openapi", "a2a"} { assert.False(t, slices.Contains(consts, absent), "callTask must not support %q", absent) } } diff --git a/metadata_test.go b/metadata_test.go index 6405269..f9b6622 100644 --- a/metadata_test.go +++ b/metadata_test.go @@ -158,7 +158,6 @@ func TestDocumentMetadataDefinitionShape(t *testing.T) { for _, key := range []string{ propCanMaxHistory, - propScheduleWorkflowName, propScheduleWorkflowType, propScheduleID, propScheduleInput, @@ -168,8 +167,6 @@ func TestDocumentMetadataDefinitionShape(t *testing.T) { } assert.Equal(t, typeInteger, def.Properties[propCanMaxHistory].Type) - assert.Equal(t, typeString, def.Properties[propScheduleWorkflowName].Type) - assert.True(t, def.Properties[propScheduleWorkflowName].Deprecated, "scheduleWorkflowName is a deprecated alias") assert.Equal(t, typeString, def.Properties[propScheduleWorkflowType].Type) assert.False(t, def.Properties[propScheduleWorkflowType].Deprecated) assert.Equal(t, typeString, def.Properties[propScheduleID].Type) @@ -227,10 +224,6 @@ func TestDocumentMetadata_Validation(t *testing.T) { expectError bool }{ // ---- valid cases ---- - { - name: "scheduleWorkflowName string is accepted", - meta: map[string]any{"scheduleWorkflowName": testWorkflowType}, - }, { name: "scheduleWorkflowType string is accepted", meta: map[string]any{propScheduleWorkflowType: testWorkflowType}, @@ -269,11 +262,6 @@ func TestDocumentMetadata_Validation(t *testing.T) { }, // ---- invalid cases ---- - { - name: "scheduleWorkflowName as integer is rejected", - meta: map[string]any{"scheduleWorkflowName": 42}, - expectError: true, - }, { name: "scheduleWorkflowType as integer is rejected", meta: map[string]any{propScheduleWorkflowType: 42}, diff --git a/schema.json b/schema.json index 24a1879..cc031bc 100644 --- a/schema.json +++ b/schema.json @@ -344,6 +344,175 @@ } } ] + }, + { + "type": "object", + "title": "CallMCP", + "description": "Defines the MCP call to perform.", + "required": [ + "call", + "with" + ], + "unevaluatedProperties": false, + "allOf": [ + { + "$ref": "#/$defs/taskBase" + }, + { + "properties": { + "call": { + "type": "string", + "const": "mcp" + }, + "with": { + "type": "object", + "properties": { + "client": { + "type": "object", + "properties": { + "name": { + "type": "string", + "title": "McpClientName", + "description": "The name of the client used to connect to the MCP server." + }, + "version": { + "type": "string", + "title": "McpClientVersion", + "description": "The version of the client used to connect to the MCP server." + } + }, + "title": "McpClient", + "description": "Describes the client used to perform the MCP call.", + "required": [ + "name", + "version" + ] + }, + "method": { + "type": "string", + "title": "McpMethod", + "description": "The MCP method to call.", + "enum": [ + "tools/list", + "tools/call", + "prompts/list", + "prompts/get", + "resources/list", + "resources/read", + "resources/templates/list" + ] + }, + "parameters": { + "type": "object", + "title": "McpMethodParameters", + "description": "The MCP method parameters.", + "additionalProperties": true + }, + "protocolVersion": { + "type": "string", + "title": "McpProtocolVersion", + "description": "The version of the MCP protocol to use.", + "default": "2025-06-18" + }, + "timeout": { + "$ref": "#/$defs/duration", + "title": "McpCallTimeout", + "description": "The duration after which the MCP call times out.", + "default": { + "seconds": 30 + } + }, + "transport": { + "type": "object", + "properties": { + "http": { + "type": "object", + "properties": { + "endpoint": { + "$ref": "#/$defs/endpoint", + "title": "McpHttpTransportEndpoint", + "description": "The MCP server endpoint to connect to." + }, + "headers": { + "type": "object", + "title": "McpHttpTransportHeaders", + "description": "A key/value mapping of the HTTP headers to send with requests, if any.", + "additionalProperties": { + "type": "string" + } + } + }, + "title": "McpHttpTransport", + "description": "The definition of the HTTP transport to use.", + "required": [ + "endpoint" + ] + }, + "options": { + "type": "object", + "additionalProperties": { + "type": "object" + } + }, + "stdio": { + "type": "object", + "properties": { + "arguments": { + "type": "array", + "items": { + "type": "string" + }, + "title": "McpStdioTransportArguments", + "description": "An optional list of arguments to pass to the command." + }, + "command": { + "type": "string", + "title": "McpStdioTransportCommand", + "description": "The command used to run the MCP server." + }, + "environment": { + "type": "object", + "title": "McpStdioTransportEnvironment", + "description": "A key/value mapping, if any, of environment variables used to configure the MCP server.", + "additionalProperties": { + "type": "string" + } + } + }, + "title": "McpStdioTransport", + "description": "The definition of the STDIO transport to use.", + "required": [ + "command" + ] + } + }, + "title": "McpCallTransport", + "description": "The transport to use to perform the MCP call.", + "oneOf": [ + { + "required": [ + "http" + ] + }, + { + "required": [ + "stdio" + ] + } + ] + } + }, + "title": "MCPArguments", + "description": "The MCP call arguments.", + "required": [ + "method", + "transport" + ], + "unevaluatedProperties": false + } + } + } + ] } ] }, @@ -517,13 +686,6 @@ "title": "ScheduleInput", "description": "Set the input." }, - "scheduleWorkflowName": { - "type": "string", - "title": "ScheduleWorkflowName", - "description": "Deprecated: use scheduleWorkflowType.", - "deprecated": true, - "minLength": 1 - }, "scheduleWorkflowType": { "type": "string", "title": "ScheduleWorkflowType", diff --git a/schema.yaml b/schema.yaml index 22414d6..6cefff9 100644 --- a/schema.yaml +++ b/schema.yaml @@ -161,6 +161,131 @@ $defs: title: CallHTTP type: object unevaluatedProperties: false + - allOf: + - $ref: '#/$defs/taskBase' + - properties: + call: + const: mcp + type: string + with: + description: The MCP call arguments. + properties: + client: + description: Describes the client used to perform the MCP call. + properties: + name: + description: The name of the client used to connect to the MCP + server. + title: McpClientName + type: string + version: + description: The version of the client used to connect to the + MCP server. + title: McpClientVersion + type: string + required: + - name + - version + title: McpClient + type: object + method: + description: The MCP method to call. + enum: + - tools/list + - tools/call + - prompts/list + - prompts/get + - resources/list + - resources/read + - resources/templates/list + title: McpMethod + type: string + parameters: + additionalProperties: true + description: The MCP method parameters. + title: McpMethodParameters + type: object + protocolVersion: + default: "2025-06-18" + description: The version of the MCP protocol to use. + title: McpProtocolVersion + type: string + timeout: + $ref: '#/$defs/duration' + default: + seconds: 30 + description: The duration after which the MCP call times out. + title: McpCallTimeout + transport: + description: The transport to use to perform the MCP call. + oneOf: + - required: + - http + - required: + - stdio + properties: + http: + description: The definition of the HTTP transport to use. + properties: + endpoint: + $ref: '#/$defs/endpoint' + description: The MCP server endpoint to connect to. + title: McpHttpTransportEndpoint + headers: + additionalProperties: + type: string + description: A key/value mapping of the HTTP headers to send + with requests, if any. + title: McpHttpTransportHeaders + type: object + required: + - endpoint + title: McpHttpTransport + type: object + options: + additionalProperties: + type: object + type: object + stdio: + description: The definition of the STDIO transport to use. + properties: + arguments: + description: An optional list of arguments to pass to the + command. + items: + type: string + title: McpStdioTransportArguments + type: array + command: + description: The command used to run the MCP server. + title: McpStdioTransportCommand + type: string + environment: + additionalProperties: + type: string + description: A key/value mapping, if any, of environment variables + used to configure the MCP server. + title: McpStdioTransportEnvironment + type: object + required: + - command + title: McpStdioTransport + type: object + title: McpCallTransport + type: object + required: + - method + - transport + title: MCPArguments + type: object + unevaluatedProperties: false + description: Defines the MCP call to perform. + required: + - call + - with + title: CallMCP + type: object + unevaluatedProperties: false title: CallTask commonMetadata: additionalProperties: true @@ -305,12 +430,6 @@ $defs: description: Set the input. title: ScheduleInput type: array - scheduleWorkflowName: - deprecated: true - description: 'Deprecated: use scheduleWorkflowType.' - minLength: 1 - title: ScheduleWorkflowName - type: string scheduleWorkflowType: description: 'The workflow type the schedule starts: the document.workflowType or a top-level Do task. Defaults to document.workflowType; required when diff --git a/schema_test.go b/schema_test.go index b21b7a4..986249c 100644 --- a/schema_test.go +++ b/schema_test.go @@ -107,10 +107,10 @@ func TestSchema_ScheduleNeedsNoWorkflowKey(t *testing.T) { resolved := resolvedTestSchema(t) for name, meta := range map[string]map[string]any{ - "no document.metadata": nil, - "metadata without a key": {propScheduleID: "my-schedule"}, - "the workflow type key": {propScheduleWorkflowType: testWorkflowType}, - "the deprecated alias": {propScheduleWorkflowName: testWorkflowType}, + "no document.metadata": nil, + "metadata without a key": {propScheduleID: "my-schedule"}, + "the workflow type key": {propScheduleWorkflowType: testWorkflowType}, + "the old key, now unlisted": {"scheduleWorkflowName": testWorkflowType}, } { t.Run(name, func(t *testing.T) { doc := minimalWorkflow()