Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 68 additions & 1 deletion dsl-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
+ [HTTP](#http-call)
+ [OpenAPI](#openapi-call)
+ [A2A](#a2a-call)
+ [MCP](#mcp-call)
- [Do](#do)
- [Emit](#emit)
- [For](#for)
Expand Down Expand Up @@ -322,6 +323,7 @@ Serverless Workflow defines several default functions that **MUST** be supported
- [HTTP](#http-call)
- [OpenAPI](#openapi-call)
- [A2A](#a2a-call)
- [MCP](#mcp-call)

##### AsyncAPI Call

Expand Down Expand Up @@ -527,6 +529,71 @@ do:
text: Generate the Q1 sales report.
```

##### MCP Call

The [MCP Call](#mcp-call) enables workflows to interact with MCP servers that are used by AI agents (https://modelcontextprotocol.io/).

###### Properties

| Name | Type | Required | Description|
|:--|:---:|:---:|:---|
| method | `string` | `yes` | The MCP JSON-RPC method to send.<br>*Supported values are: `initialize`, `notifications/initialized`, `prompts/list`, `prompts/get`, `notifications/prompts/list_changed`, `resources/list`, `resources/read`, `resources/templates/list`, `notifications/resources/list_changed`, `tools/list`, `tools/call`, `notifications/tools/list_changed`, `logging/setLevel`, and `notifications/message`* |
| server | `string`\|[`endpoint`](#endpoint) | `yes` | An URI, an object (for HTTP) or a filename (for STDIO) that describes the MCP server to call.<br>|
| parameters | `map` <br> `string` | `no` | The parameters for the MCP RPC method. For the `initialize` method, runtimes must set the `protocolVersion` parameter to the used version. Runtimes must implement the MCP specification version of 2025-06-18. <br>*Can be an object or a runtime expression.* |

> [!NOTE]
> On success the output is the JSON-RPC result. On failure runtimes must raise an error with type [https://serverlessworkflow.io/spec/1.0.0/errors/runtime](https://github.com/serverlessworkflow/specification/blob/main/dsl-reference.md#standard-error-types).
>
> This call supports MCP over both HTTP and STDIO (communication over standard in and standard out) transport mechanisms.

###### Examples

This example shows an initialization phase as the first interaction between MCP client and server. The client sends its supported version, capabilities, and implementation information in the initialize request. The server MUST respond with its own capabilities and information including the supported version.

```yaml
document:
dsl: '1.0.1'
namespace: test
name: mcp-example
version: '0.1.0'
do:
- GenerateReport:
call: mcp
with:
method: initialize
server:
endpoint: https://example.com/mcp
parameters:
protocolVersion: '2025-06-18'
capabilities:
roots:
listChanged: true
clientInfo:
name: 'ExampleClient'
version: '0.1.0'
```

The following example showcases a prompts/list request by the client to retrieve available prompts from the MCP server.

```yaml
document:
dsl: '1.0.1'
namespace: test
name: mcp-example
version: '0.1.0'
do:
- GenerateReport:
call: mcp
with:
method: prompts/get
server:
endpoint: https://example.com/mcp
parameters:
name: "code_review"
arguments:
code: "def hello():\n print('world')"
```

#### Do

Serves as a fundamental building block within workflows, enabling the sequential execution of multiple subtasks. By defining a series of subtasks to perform in sequence, the Do task facilitates the efficient execution of complex operations, ensuring that each subtask is completed before the next one begins.
Expand Down Expand Up @@ -2706,4 +2773,4 @@ References a workflow definition.
name: greet
namespace: samples
version: '0.1.0-rc2'
```
```
20 changes: 20 additions & 0 deletions examples/call-mcp-1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
document:
dsl: '1.0.1'
namespace: test
name: mcp-example
version: '0.1.0'
do:
- GenerateReport:
call: mcp
with:
method: initialize
server:
endpoint: https://example.com/mcp
parameters:
protocolVersion: '2025-06-18'
capabilities:
roots:
listChanged: true
clientInfo:
name: 'ExampleClient'
version: '0.1.0'
16 changes: 16 additions & 0 deletions examples/call-mcp-2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
document:
dsl: '1.0.1'
namespace: test
name: mcp-example
version: '0.1.0'
do:
- GenerateReport:
call: mcp
with:
method: prompts/get
server:
endpoint: https://example.com/mcp
parameters:
name: "code_review"
arguments:
code: "def hello():\n print('world')"
39 changes: 37 additions & 2 deletions schema/workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,41 @@ $defs:
description: The parameters object to send with the A2A method.
required: [ method ]
unevaluatedProperties: false
- title: CallMCP
description: Defines the MCP call to perform.
type: object
unevaluatedProperties: false
required: [ call, with ]
allOf:
- $ref: '#/$defs/taskBase'
- properties:
call:
type: string
const: mcp
with:
type: object
title: MCPArguments
description: The MCP call arguments.
properties:
server:
title: MCPServer
description: The MCP server endpoint (HTTP or STDIO) to send the request to.
$ref: '#/$defs/endpoint'
method:
type: string
title: WithMCPMethod
description: The MCP method to send.
enum: [ 'initialize', 'notifications/initialized', 'prompts/list', 'prompts/get', 'notifications/prompts/list_changed', 'resources/list', 'resources/read', 'resources/templates/list', 'notifications/resources/list_changed', 'tools/list', 'tools/call', 'notifications/tools/list_changed', 'logging/setLevel', 'notifications/message' ]
parameters:
oneOf:
- type: object
minProperties: 1
additionalProperties: true
- type: string
title: WithMCPParameters
description: The parameters object to send with the MCP method.
required: [ method, server ]
unevaluatedProperties: false
- title: CallFunction
description: Defines the function call to perform.
type: object
Expand All @@ -484,7 +519,7 @@ $defs:
call:
type: string
not:
enum: ["asyncapi", "grpc", "http", "openapi", "a2a"]
enum: ["asyncapi", "grpc", "http", "openapi", "a2a", "mcp"]
description: The name of the function to call.
with:
type: object
Expand Down Expand Up @@ -1823,4 +1858,4 @@ $defs:
export:
$ref: '#/$defs/export'
title: SubscriptionIteratorExport
description: An object, if any, used to customize the content of the workflow context.
description: An object, if any, used to customize the content of the workflow context.
Loading