From 719f4c5f4bdc5f64c467641d41a5e1a99e9e625d Mon Sep 17 00:00:00 2001 From: Simon Emms Date: Sun, 28 Jun 2026 21:22:59 +0000 Subject: [PATCH] feat: add call mcp server to schema Signed-off-by: Simon Emms --- constants.go | 1 + definitions.go | 146 +++++++++++++++++++++++++++++++++++++- definitions_test.go | 4 +- schema.json | 167 ++++++++++++++++++++++++++++++++++++++++++++ schema.yaml | 120 +++++++++++++++++++++++++++++++ 5 files changed, 435 insertions(+), 3 deletions(-) diff --git a/constants.go b/constants.go index 92c1046..1db5eb5 100644 --- a/constants.go +++ b/constants.go @@ -123,4 +123,5 @@ const ( propThen = "then" propWorkflowType = "workflowType" propVersion = "version" + propHttp = "http" ) diff --git a/definitions.go b/definitions.go index e4326ad..e07edec 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{ + 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.", + OneOf: []*jsonschema.Schema{ + { + Type: typeObject, + AdditionalProperties: falseSchema(), + }, + { + Type: typeString, + }, + }, + }, + "timeout": { + Title: "McpCallTimeout", + Description: "The duration after which the MCP call times out.", + Ref: SchemaRef("duration"), + }, + "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.", + }, + }, + }, + }, + }, + }, + }, + }, + }, }, } 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/schema.json b/schema.json index 8bc006c..3a413d1 100644 --- a/schema.json +++ b/schema.json @@ -344,6 +344,173 @@ } } ] + }, + { + "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": { + "title": "McpMethodParameters", + "description": "The MCP method parameters.", + "oneOf": [ + { + "type": "object", + "additionalProperties": false + }, + { + "type": "string" + } + ] + }, + "timeout": { + "$ref": "#/$defs/duration", + "title": "McpCallTimeout", + "description": "The duration after which the MCP call times out." + }, + "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 + } + } + } + ] } ] }, diff --git a/schema.yaml b/schema.yaml index 15944dc..028c02d 100644 --- a/schema.yaml +++ b/schema.yaml @@ -161,6 +161,126 @@ $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: + description: The MCP method parameters. + oneOf: + - additionalProperties: false + type: object + - type: string + title: McpMethodParameters + timeout: + $ref: '#/$defs/duration' + 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