MCP Client
The ai/mcpClient component: v0.36.0+ an MCP (Model Context Protocol) client node that connects to a remote MCP server, invokes the specified tool, and writes the result to the message for downstream nodes. It can also register itself as an MCPToolProvider in the RuleConfig UDF, so agents can call remote tools via ai/agent's self mode.
# Dual Role
The MCP client can be used in two ways inside a rule chain:
- Direct invocation: as a rule chain node, calls the specified remote MCP tool on
OnMsg - Tool provider: at startup, auto-discovers all tools of the remote MCP server and registers them as an
MCPToolProviderfor agent MCP tools (server: "self")
# Configuration
| Field | Type | Description | Default |
|---|---|---|---|
| server | string | MCP server address. Supports HTTP URLs (http:///https://) and stdio commands | required |
| toolName | string | Remote tool name to invoke. Supports ${metadata.xxx} and ${msg.xxx} expressions. Empty = taken from metadata.mcpToolName | |
| args | string | Tool arguments JSON template. Supports ${msg.xxx} and ${metadata.xxx} expressions. Empty = the message body JSON | |
| toolFilter | []string | Tool filter (affects MCPToolProvider registration only); empty or ["*"] = register all tools |
# Execution Result
- The tool result is written to
msg.Dataand passed downstream via theSuccessrelation - On failure, the error is passed via the
Failurerelation
# Configuration Examples
# Invoking a Remote Tool Directly
{
"id": "s1",
"type": "ai/mcpClient",
"name": "Get Weather",
"configuration": {
"server": "http://localhost:8080/mcp",
"toolName": "get_weather",
"args": "{\"city\": \"${msg.city}\", \"unit\": \"celsius\"}"
}
}
2
3
4
5
6
7
8
9
10
# Dynamic Tool Name (from Message Metadata)
{
"id": "s1",
"type": "ai/mcpClient",
"name": "MCP Tool Call",
"configuration": {
"server": "http://localhost:8080/mcp",
"toolName": "${metadata.mcpToolName}",
"args": ""
}
}
2
3
4
5
6
7
8
9
10
When toolName is empty, the component reads the tool name from msg.Metadata["mcpToolName"]. When args is empty, the JSON in msg.Data is used as the tool arguments.
# Stdio Mode (Local Process)
{
"id": "s1",
"type": "ai/mcpClient",
"name": "Local MCP Tool",
"configuration": {
"server": "mcp-server --port 8080",
"toolName": "search",
"args": "{\"query\": \"${msg.query}\"}"
}
}
2
3
4
5
6
7
8
9
10
When server is not an HTTP URL, the component parses it as a command line and communicates with the MCP service over stdio.
# As the Agent's Tool Provider
At startup (Start()), the MCP client connects to the remote server, discovers tools, and registers them as an MCPToolProvider. Once configured in a rule chain, agents can use these remote tools in self mode:
{
"tools": [
{
"type": "mcp",
"config": {
"server": "self",
"tools": ["get_weather", "search"]
}
}
]
}
2
3
4
5
6
7
8
9
10
11
toolFilter controls which tools are registered into the MCPToolProvider:
{
"toolFilter": ["get_weather", "search"]
}
2
3
# Application Example
{
"ruleChain": {
"id": "mcp-demo",
"name": "MCP Invocation Demo",
"root": true
},
"metadata": {
"firstNodeIndex": 0,
"nodes": [
{
"id": "node_mcp",
"type": "ai/mcpClient",
"name": "Call Remote Tool",
"configuration": {
"server": "http://localhost:8080/mcp",
"toolName": "get_weather",
"args": "{\"city\": \"${msg.city}\"}"
}
},
{
"id": "node_log",
"type": "log",
"name": "Log Result",
"configuration": {
"jsScript": "return 'Weather result: ' + msg.data;"
}
}
],
"connections": [
{"fromId": "node_mcp", "toId": "node_log", "type": "Success"}
]
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33