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 or an object 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 default `protocolVersion` to the used version.<br>*Can be an object or a direct runtime expression.* |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is protocolVersion a required parameter if I use initialize? If so, can we rephrase?

Suggested change
| parameters | `map` <br> `string` | `no` | The parameters for the MCP RPC method. For the `initialize` method, runtimes must default `protocolVersion` to the used version.<br>*Can be an object or a direct runtime expression.* |
| 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.<br>*Can be an object or a runtime expression.* |

Also, if the user does not provide it, I understand from your writing that the runtime will append this parameter. It comes from where?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the initialization phase MUST be the first interaction between MCP client and server, and include 'protocolVersion'. The client sends its supported version in the initialize request, and if the server supports it, it responds with the same version. It should be mentioned in the MCP client's specification. I assume if the runtime supports MCP, it should have the supported version. Do you suggest changing any part?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should enforce a minimum protocol version that runtimes MUST implement.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest to support the latest version (i.e., 2025-06-18) or the one before that (2025-03-26).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 for the latest version.


> [!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 only supports MCP over HTTP transport mechanism and not STDIO (communication over standard in and standard out).

###### 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 informationin 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-03-26'
capabilities:
roots:
listChanged: true
clientInfo:
name: 'ExampleClient'
version: '1.0.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'
```
```
3 changes: 2 additions & 1 deletion dsl.md
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,7 @@ Serverless Workflow DSL is designed to seamlessly interact with a variety of ser
- [**AsyncAPI**](dsl-reference.md#asyncapi-call): Facilitates interaction with asynchronous messaging protocols. AsyncAPI is designed for event-driven architectures, allowing workflows to publish and subscribe to events.
- [**OpenAPI**](dsl-reference.md#openapi-call): Enables communication with services that provide OpenAPI specifications, which is useful for defining and consuming RESTful APIs.
- [**A2A**](dsl-reference.md#a2a-call): Enables interaction with A2A servers (agents described by A2A).
- [**MCP**](dsl-reference.md#mcp-call): Enables interaction with MCP servers.

Runtimes **must** raise an error with type `https://serverlessworkflow.io/spec/1.0.0/errors/communication` if and when a problem occurs during a call.

Expand Down Expand Up @@ -815,4 +816,4 @@ sampleOAuth2:

These authentication schemes can be defined globally in the authentication section or associated with specific endpoints. They provide secure access to resources while ensuring proper authorization and identity verification.

See the [DSL reference](dsl-reference.md#authentication) for more details about authentication.
See the [DSL reference](dsl-reference.md#authentication) for more details about authentication.
37 changes: 36 additions & 1 deletion 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 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 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.