> ## Documentation Index
> Fetch the complete documentation index at: https://docs.coreflux.org/llms.txt
> Use this file to discover all available pages before exploring further.

# MCP Connectors

> Connect your Coreflux broker to external tools and services through the Model Context Protocol (MCP)

## Plug Your Broker Into Any MCP Tool

MCP (Model Context Protocol) is an open standard that defines how applications communicate with external tool servers. MCP Connectors let your Coreflux broker connect to any MCP-compatible server — file systems, messaging platforms, cloud storage, spreadsheets, and more — and call their tools directly from LoT Actions.

> [!WARNING]
>
> This page is the **MCP client connector** (`DEFINE CONNECTOR … WITH TYPE MCP` and `CALL MCP` from Actions). The broker connects *out* to an external MCP server.
>
> To expose **this broker** as an MCP server for Cursor or Claude Desktop, use the [MCP Server](https://docs.coreflux.org/latest/mqtt-broker/mcp-server.md) (`Mcp.Enabled`). `TYPE MCP_SERVER` was removed. The hosted [documentation MCP](https://docs.coreflux.org/ai/mcp.md) searches docs.coreflux.org and does not control a broker.

> [!NOTE]
>
> A `DEFINE AGENT` gets this connector's tools only through `ADD TOOL "mcp"`, one tool or all of them, and each call needs a rule. Actions call the tools with `CALL MCP` or run an `ADD EVENT` on the connector. See [Agents and MCP Tools](#agents-and-mcp-tools).

> [!TIP]
>
> **Like adding power tools to a workbench.** Each MCP Connector plugs a new tool into your broker — a Slack server for sending messages, a filesystem server for reading logs, a Google Drive server for cloud backups. Once connected, any LoT Action can pick up and use that tool.

***

## Integration Architecture

MCP Connectors allow the Coreflux Broker to connect to external MCP servers as a **client**. This enables LoT Actions to call tools provided by any MCP server—file systems, cloud services, communication platforms, and more.

```mermaid actions={false} theme={"theme":{"light":"css-variables","dark":"css-variables"},"languages":{"custom":["/languages/lot.json"]}}
graph LR
    subgraph mcpServers [External MCP Servers]
        Filesystem[Filesystem Server]
        Slack[Slack Server]
        GDrive[Google Drive]
        Custom[Custom MCP Server]
    end
    
    subgraph broker [Coreflux Broker]
        MCPRoutes[MCP Connectors]
        Actions[LoT Actions]
        Topics[MQTT Topics]
    end
    
    subgraph devices [IoT Layer]
        Sensors[Sensors]
        Actuators[Actuators]
    end
    
    MCPRoutes -->|connects to| Filesystem
    MCPRoutes -->|connects to| Slack
    MCPRoutes -->|connects to| GDrive
    MCPRoutes -->|connects to| Custom
    
    Actions -->|CALL MCP| MCPRoutes
    Actions -->|PUBLISH/KEEP| Topics
    Topics <--> Sensors
    Topics <--> Actuators
```

### How It Works

1. **Define MCP Connectors** - Each connector connects to an external MCP server
2. **Discover Tools** - The broker lists the server's tools as soon as the handshake completes, and again when the server reports that the list changed
3. **Call from Actions** - Use `CALL MCP` in LoT Actions to invoke any tool
4. **Reusable Connections** - Multiple actions can share the same MCP connector

> [!TIP]
>
> **MCP as a Connection Type.** Just like database connectors or REST API connectors, MCP connectors provide a reusable connection that any action can leverage. Define the connector once, use it everywhere.

***

## Basic Syntax

The `MCP` connector type connects your Coreflux broker to an external MCP server, making that server's tools callable from LoT Actions. Each connector manages one MCP server connection, and you can define multiple connectors to connect to different servers simultaneously.

```lot wrap theme={"theme":{"light":"css-variables","dark":"css-variables"},"languages":{"custom":["/languages/lot.json"]}}
DEFINE CONNECTOR MCPFilesystem WITH TYPE MCP
    ADD MCP_CONFIG
        WITH SERVER_COMMAND "npx"
        WITH SERVER_ARGUMENTS "-y, @modelcontextprotocol/server-filesystem, /data"
        WITH CLIENT_NAME "CorefluxFS"
```

Once connected, any LoT Action can use `CALL MCP` to invoke the server's tools — send Slack messages, read and write files, generate spreadsheet reports, or interact with any other MCP-compatible service.

***

## MCP Configuration

### MCP\_CONFIG Parameters

A connector reaches its server in one of two ways. Set `SERVER_COMMAND` and `SERVER_ARGUMENTS` to start a local server process (stdio). Or set `SERVER_URL` to connect to a remote server over HTTP. When `SERVER_URL` is set, `SERVER_COMMAND` and `SERVER_ARGUMENTS` are not needed. Without it, `-addConnector` requires both.

**SERVER\_COMMAND** `string`

MCP server command to execute (e.g., `npx`, `python`, `node`). Required unless `SERVER_URL` is set.

**SERVER\_ARGUMENTS** `string`

Comma-separated server arguments (e.g., `-y, @modelcontextprotocol/server-filesystem`). Required unless `SERVER_URL` is set.

**SERVER\_URL** `string`

URL of a remote MCP server (e.g., `https://mcp.example.com/mcp`). Replaces `SERVER_COMMAND` and `SERVER_ARGUMENTS`. Send a header to that server with `SERVER_HEADER`.

**SERVER\_HEADER** `string`

`WITH SERVER_HEADER "Name" <value>` sends one HTTP header to a server reached with `SERVER_URL`. Repeat the line for each header. The value can be a string or `GET SECRET "..."`. The value is masked in broker logs, the same way as `SERVER_ENV`.

**SERVER\_ENV** `string`

`WITH SERVER_ENV "NAME" <value>` sets one environment variable on the server process. Repeat the line for each variable. The value can be a string, a number, `true`/`false`, `GET ENV "..."`, or `GET SECRET "..."`, resolved when the connector starts. Applies only to a server started with `SERVER_COMMAND`. The value is masked in broker logs.

**CLIENT\_NAME** `string`

MCP client identifier. Default: CorefluxBroker.

***

## Configuration Examples

> [tab] Filesystem Server
>
> Enable LoT Actions to perform file operations:
>
> ```lot wrap theme={"theme":{"light":"css-variables","dark":"css-variables"},"languages":{"custom":["/languages/lot.json"]}}
> DEFINE CONNECTOR MCPFilesystem WITH TYPE MCP
>     ADD MCP_CONFIG
>         WITH SERVER_COMMAND "npx"
>         WITH SERVER_ARGUMENTS "-y, @modelcontextprotocol/server-filesystem, /data"
>         WITH CLIENT_NAME "CorefluxFS"
> ```

> [tab] Custom MCP Server
>
> Connect to a custom MCP server:
>
> ```lot wrap theme={"theme":{"light":"css-variables","dark":"css-variables"},"languages":{"custom":["/languages/lot.json"]}}
> DEFINE CONNECTOR MCPCustom WITH TYPE MCP
>     ADD MCP_CONFIG
>         WITH SERVER_COMMAND "python"
>         WITH SERVER_ARGUMENTS "-m, my_mcp_server"
>         WITH CLIENT_NAME "CorefluxCustom"
> ```

> [tab] Node.js Server
>
> Run a Node.js MCP server:
>
> ```lot wrap theme={"theme":{"light":"css-variables","dark":"css-variables"},"languages":{"custom":["/languages/lot.json"]}}
> DEFINE CONNECTOR MCPNode WITH TYPE MCP
>     ADD MCP_CONFIG
>         WITH SERVER_COMMAND "node"
>         WITH SERVER_ARGUMENTS "/opt/mcp/server.js, --config, /etc/mcp/config.json"
>         WITH CLIENT_NAME "CorefluxNode"
> ```

> [tab] Server Credentials
>
> Pass an API key to a local server as an environment variable. Keep the key in a secret, not in the connector:
>
> ```lot wrap theme={"theme":{"light":"css-variables","dark":"css-variables"},"languages":{"custom":["/languages/lot.json"]}}
> DEFINE CONNECTOR MCPNotion WITH TYPE MCP
>     ADD MCP_CONFIG
>         WITH SERVER_COMMAND "npx"
>         WITH SERVER_ARGUMENTS "-y, @notionhq/notion-mcp-server"
>         WITH SERVER_ENV "NOTION_API_KEY" GET SECRET "NOTION_KEY"
>         WITH SERVER_ENV "NOTION_CACHE_TTL" "300"
> ```

> [tab] Remote Server
>
> Connect to an MCP server over HTTP. No local Node.js or Python is needed. Send a header when the server expects one:
>
> ```lot wrap theme={"theme":{"light":"css-variables","dark":"css-variables"},"languages":{"custom":["/languages/lot.json"]}}
> DEFINE CONNECTOR MCPRemote WITH TYPE MCP
>     ADD MCP_CONFIG
>         WITH SERVER_URL "https://mcp.example.com/mcp"
>         WITH SERVER_HEADER "Authorization" GET SECRET "MCP_TOKEN"
>         WITH CLIENT_NAME "CorefluxRemote"
> ```
>
> The header value is masked in broker logs. Omit `SERVER_HEADER` for a server that accepts unauthenticated calls from the broker's network. For a local process, pass credentials with `SERVER_ENV` instead.

***

## MCP Server Examples

The MCP ecosystem includes servers for various platforms and services. These examples show how to connect popular MCP servers to your Coreflux broker for IoT integration.

> [tab] Node.js Servers (npx)
>
> Node.js-based MCP servers can be run directly using `npx`. These are the most common and include official Anthropic servers.
>
> | Server | LoT Configuration | IoT Use Case |
> | - | - | - |
> | **Filesystem** | `SERVER_COMMAND "npx"` with `SERVER_ARGUMENTS "-y, @modelcontextprotocol/server-filesystem, /data"` | Read sensor logs, manage config files |
> | **Google Drive** | `SERVER_COMMAND "npx"` with `SERVER_ARGUMENTS "-y, @modelcontextprotocol/server-gdrive"` | Cloud backup of IoT data |
> | **Slack** | `SERVER_COMMAND "npx"` with `SERVER_ARGUMENTS "-y, @modelcontextprotocol/server-slack"` | Send alerts to team channels |
> | **Memory** | `SERVER_COMMAND "npx"` with `SERVER_ARGUMENTS "-y, @modelcontextprotocol/server-memory"` | Persist context across AI sessions |
> | **Fetch** | `SERVER_COMMAND "npx"` with `SERVER_ARGUMENTS "-y, @modelcontextprotocol/server-fetch"` | Access external APIs and web data |
> | **Windows Control** | `SERVER_COMMAND "npx"` with `SERVER_ARGUMENTS "-y, mcp-control"` | Automate HMI/SCADA systems |
>
> **Example: Slack Alerts for IoT Events**
>
> ```lot wrap theme={"theme":{"light":"css-variables","dark":"css-variables"},"languages":{"custom":["/languages/lot.json"]}}
> DEFINE CONNECTOR MCPSlack WITH TYPE MCP
>     ADD MCP_CONFIG
>         WITH SERVER_COMMAND "npx"
>         WITH SERVER_ARGUMENTS "-y, @modelcontextprotocol/server-slack"
>         WITH CLIENT_NAME "CorefluxSlack"
> ```

> [tab] Python Servers (uvx)
>
> Python-based MCP servers use `uvx` (the uv package runner). These are common for third-party integrations.
>
> | Server | LoT Configuration | IoT Use Case |
> | - | - | - |
> | **Spotify** | `SERVER_COMMAND "uvx"` with `SERVER_ARGUMENTS "spotify-mcp"` | Smart home audio control |
> | **Excel** | `SERVER_COMMAND "uvx"` with `SERVER_ARGUMENTS "excel-mcp-server"` | Generate reports from sensor data |
>
> **Example: Excel Reports from Sensor Data**
>
> ```lot wrap theme={"theme":{"light":"css-variables","dark":"css-variables"},"languages":{"custom":["/languages/lot.json"]}}
> DEFINE CONNECTOR MCPExcel WITH TYPE MCP
>     ADD MCP_CONFIG
>         WITH SERVER_COMMAND "uvx"
>         WITH SERVER_ARGUMENTS "excel-mcp-server"
>         WITH CLIENT_NAME "CorefluxExcel"
> ```

***

## Calling MCP Tools

Once an MCP connector is defined, you can call its tools from within LoT Actions using the `CALL MCP` syntax. This enables AI-powered automation triggered by MQTT events.

### Basic Syntax

The standard syntax to invoke an MCP tool from an Action:

```lot wrap theme={"theme":{"light":"css-variables","dark":"css-variables"},"languages":{"custom":["/languages/lot.json"]}}
CALL MCP "RouteName.ToolName"
    WITH (arg1 = value1, arg2 = value2)
    RETURN AS {result_variable}
```

| Component | Format | Description |
| - | - | - |
| **Connector.Tool** | `"RouteName.ToolName"` | The name splits at the first dot. `Docs.files.read` is connector `Docs` and tool `files.read` |
| **WITH** | `WITH (name = value, ...)` | Named arguments in parentheses |
| **RETURN AS** | `RETURN AS {varname}` | Capture the result in a variable |

### Return Value

`RETURN AS` always receives a JSON string, also when the call fails. Check `success` before you use `result`:

```json wrap theme={"theme":{"light":"css-variables","dark":"css-variables"},"languages":{"custom":["/languages/lot.json"]}}
{
  "success": true,
  "tool_name": "send-message",
  "route_name": "MCPSlack",
  "timestamp": "2026-10-23T12:00:00.000Z",
  "execution_time_ms": 150,
  "result": { }
}
```

| Field | Description |
| - | - |
| `success` | `false` when the call fails, and when the tool result reports `isError` |
| `tool_name` | The tool that was called |
| `route_name` | The connector that called it |
| `timestamp` | UTC time of the reply |
| `execution_time_ms` | Time the call took, in milliseconds |
| `result` | The MCP tool result in wire form: `content`, `structuredContent`, and `isError` |
| `error` | Why the call failed. Present only when `success` is `false` |

A failed call has `success: false` and an `error` such as `Tool 'X' not found. Available tools: ...`, `MCP client is not connected`, or `MCP route 'X' not found or not an MCP route`.

```lot wrap theme={"theme":{"light":"css-variables","dark":"css-variables"},"languages":{"custom":["/languages/lot.json"]}}
CALL MCP "MCPSlack.send-message"
    WITH (channel = "alerts", message = "Line 2 stopped")
    RETURN AS {reply}
SET "sent" WITH (GET JSON "success" IN {reply} AS BOOL)
IF {sent} EQUALS FALSE THEN
    PUBLISH TOPIC "alerts/slack/error" WITH (GET JSON "error" IN {reply} AS STRING)
END IF
```

### Complete Example

This Action monitors a temperature sensor and uses an MCP tool to send a Slack message when the temperature exceeds a threshold:

```lot wrap theme={"theme":{"light":"css-variables","dark":"css-variables"},"languages":{"custom":["/languages/lot.json"]}}
DEFINE ACTION TemperatureAlert
ON TOPIC "sensors/+/temperature" DO
    SET "temp" WITH (GET JSON "value" IN PAYLOAD AS DOUBLE)
    SET "sensor_id" WITH TOPIC POSITION 2
    
    IF {temp} > 80 THEN
        CALL MCP "MCPSlack.send-message"
            WITH (channel = "alerts", message = "🔥 Sensor " + {sensor_id} + " at " + {temp} + "°C")
            RETURN AS {result}
        
        PUBLISH TOPIC "alerts/temperature/sent" WITH "Sensor: " + {sensor_id} + " Temp: " + {temp} + " Result: " + {result}
    END IF
```

### Syntax Variations

> [accordion] No Arguments
>
> Some tools don't require arguments:
>
> ```lot wrap theme={"theme":{"light":"css-variables","dark":"css-variables"},"languages":{"custom":["/languages/lot.json"]}}
> CALL MCP "MCPSystem.get-status"
>     RETURN AS {status}
> ```

> [accordion] Multiple Arguments
>
> Pass multiple named parameters:
>
> ```lot wrap theme={"theme":{"light":"css-variables","dark":"css-variables"},"languages":{"custom":["/languages/lot.json"]}}
> CALL MCP "MCPFilesystem.write-file"
>     WITH (path = "/data/log.txt", content = {payload}, append = true)
>     RETURN AS {write_result}
> ```

> [accordion] String Concatenation
>
> Build dynamic values using expressions:
>
> ```lot wrap theme={"theme":{"light":"css-variables","dark":"css-variables"},"languages":{"custom":["/languages/lot.json"]}}
> CALL MCP "MCPSlack.send-message"
>     WITH (message = "Device " + {device_id} + " reported: " + {value} + " at " + TIMESTAMP "UTC")
>     RETURN AS {chat_result}
> ```

### Who Can Call Tools

A rule on `$SYS/Coreflux/Routes/<connector>/Tools/<tool>/Call` governs `CALL MCP` for that tool. The tool name is percent-encoded into one topic level when it contains `/`, `+`, `#`, `.`, or `%` (`files/read` is `files%2Fread`). With no matching rule, `CALL MCP` behaves as before: any action that runs it can call any tool on any configured MCP connector.

`$SYS` topics use the `PublishSys` scope:

```lot wrap theme={"theme":{"light":"css-variables","dark":"css-variables"},"languages":{"custom":["/languages/lot.json"]}}
DEFINE RULE DenySlackSend WITH PRIORITY 100 FOR PublishSys TO TOPIC "$SYS/Coreflux/Routes/MCPSlack/Tools/send-message/Call"
    DENY
```

* Only let trusted administrators add MCP connectors. Every tool those servers expose becomes callable from LoT until a rule matches its Call topic.
* Restrict which roles can add or change actions. A role that can deploy actions can reach every tool that has no matching rule.
* An agent's MCP tool call is checked on the same topic, but it needs a rule that allows it: with no matching rule the agent is refused. A rule you write for an agent also decides `CALL MCP` on that tool, so keep the users your Actions run as in it. See [Agents and MCP Tools](#agents-and-mcp-tools).

***

## Run a tool from an event

An `ADD EVENT` on an MCP connector runs that tool and publishes the result to the event's `DESTINATION_TOPIC`. Name the event after the tool. Fire it from an Action with `TRIGGER`.

```lot wrap theme={"theme":{"light":"css-variables","dark":"css-variables"},"languages":{"custom":["/languages/lot.json"]}}
DEFINE CONNECTOR MCPSlack WITH TYPE MCP
    ADD MCP_CONFIG
        WITH SERVER_COMMAND "npx"
        WITH SERVER_ARGUMENTS "-y, @modelcontextprotocol/server-slack"
        WITH CLIENT_NAME "CorefluxSlack"
    ADD EVENT send-message
        WITH DESTINATION_TOPIC "alerts/slack/result"

DEFINE ACTION NotifySlack
ON TOPIC "alerts/slack/request" DO
    TRIGGER "MCPSlack" TO PAYLOAD FOR "send-message"
```

The result published to `alerts/slack/result` is the tool result for that event.

***

## Agents and MCP Tools

Grant a `DEFINE AGENT` the connector's tools with `ADD TOOL "mcp"`. Each granted tool reaches the model as its own function, `mcp__<connector>__<tool>`, with the input schema the server sent.

```lot wrap theme={"theme":{"light":"css-variables","dark":"css-variables"},"languages":{"custom":["/languages/lot.json"]}}
DEFINE CONNECTOR MCPSlack WITH TYPE MCP
    ADD MCP_CONFIG
        WITH SERVER_COMMAND "npx"
        WITH SERVER_ARGUMENTS "-y, @modelcontextprotocol/server-slack"

DEFINE AGENT ShiftReporter
    USES LLM CONNECTOR Claude
    WITH DESCRIPTION "Posts shift summaries to Slack"
    WITH DEFAULT_USER "shift-reporter"
    ADD TOOL "mqtt_read"
        WITH TOPICS "lines/#"
    ADD TOOL "mcp"
        WITH TARGET "MCPSlack.list-channels, MCPSlack.send-message"
        WITH LEVEL "write"

DEFINE RULE ShiftReporterSlack WITH PRIORITY 100 FOR PublishSys TO TOPIC "$SYS/Coreflux/Routes/MCPSlack/Tools/+/Call"
    IF USER IS "shift-reporter" THEN
        ALLOW
    ELSE
        DENY
```

`Claude` is a `TYPE LLM` connector. Create `shift-reporter` with `-addUser` before you add the agent. The agent reads line data and posts with two Slack tools. The tool names come from `$SYS/Coreflux/Routes/MCPSlack/Tools`. Use `"MCPSlack.*"` to grant every tool of the connector.

* **Level** — `"write_confirm"`, the default, waits for an approval on each call. `"write"` runs at once. `"read"` offers only the tools the server marks read-only.
* **Rule** — the agent's call is checked as `PublishSys` on `…/Tools/<tool>/Call`, for the user the task runs as and for `DEFAULT_USER`. With no rule that allows both, the call is refused as `unauthorized`. The example task runs as `shift-reporter` when an Action starts it with `CALL AGENT`. Add the people who ask the agent over MQTT to the rule.
* **Actions** — the rule also decides `CALL MCP` on `MCPSlack` tools. An Action that calls them must run as a user the rule allows.
* **Tool list** — when the server reports a change, or the connector restarts, the agent is rebuilt with the new list before its next run.

`MCP_ROUTES` is legacy. On `DEFINE AGENT`, `WITH MCP_ROUTES "MCPSlack"` is read as `ADD TOOL "mcp"` on `MCPSlack.*` at `write_confirm`. A `TYPE LLM` connector ignores it and logs a warning. Write `ADD TOOL "mcp"` instead. The full reference is [MCP tools](https://docs.coreflux.org/latest/lot-language/agents/syntax.md#mcp-tools) in Agent Syntax.

***

## Tool Discovery

When the handshake with the MCP server completes, the broker lists that server's tools and publishes them to MQTT system topics. It does not wait a fixed 10 seconds. Stopping the connector also closes the MCP server process it started.

When the server sends `notifications/tools/list_changed`, the broker lists the tools again, republishes the retained tool topics, and clears the topics for tools that were removed.

### System Topics

| Topic | Description |
| - | - |
| `$SYS/Coreflux/Routes/{name}/Tools` | Summary of all tools for a connector |
| `$SYS/Coreflux/Routes/{name}/Tools/{tool}` | Detailed info for a specific tool |
| `$SYS/Coreflux/Routes/{name}/Tools/{tool}/Capability` | Call statistics for one tool, updated after every call |

All three are retained. The broker republishes the summary and tool topics with its periodic status updates.

### Tools Summary Payload

Subscribe to the summary topic to see all available tools:

```json wrap theme={"theme":{"light":"css-variables","dark":"css-variables"},"languages":{"custom":["/languages/lot.json"]}}
{
  "route_name": "MCPSlack",
  "route_type": "MCP",
  "total_tools": 8,
  "tools": ["send-message", "list-channels", "get-channel-history", "add-reaction", ...],
  "capability_overview": {
    "total_executions": 42,
    "fast_tools": 3,
    "reliable_tools": 5,
    "avg_reliability": 97.5
  },
  "timestamp": "2026-10-23T12:00:00.000Z"
}
```

`fast_tools` counts tools rated `FAST`. `reliable_tools` counts tools rated `EXCELLENT`. The summary also includes `tool_entries`.

### Individual Tool Payload

Each tool publishes its description, parameters, and call statistics:

```json wrap theme={"theme":{"light":"css-variables","dark":"css-variables"},"languages":{"custom":["/languages/lot.json"]}}
{
  "name": "send-message",
  "description": "Send a message to a Slack channel",
  "parameters": {
    "channel": { "type": "string", "description": "Channel name or ID" },
    "message": { "type": "string", "description": "Message text" }
  },
  "route_name": "MCPSlack",
  "tool_type": "MCP",
  "capability": {
    "execution_count": 42,
    "average_latency_ms": 150.25,
    "min_latency_ms": 90,
    "max_latency_ms": 420,
    "success_count": 41,
    "failure_count": 1,
    "reliability_percent": 97.62,
    "performance_rating": "MEDIUM",
    "reliability_rating": "EXCELLENT",
    "first_executed": "2026-10-23T08:00:00.000Z",
    "last_executed": "2026-10-23T11:59:00.000Z",
    "last_error": ""
  },
  "timestamp": "2026-10-23T12:00:00.000Z"
}
```

Each tool topic also carries the original tool `name`, `topic_segment`, `required`, `read_only`, the full `inputSchema`, and `function_name`.

A tool name that contains `/`, `+`, `#`, `.`, or `%` is percent-encoded into one topic level. `files/read` is published at `Tools/files%2Fread`, and `CALL MCP` still addresses it as `Docs.files.read` (connector `Docs`, tool `files.read`).

Each parameter in `parameters` carries only `type` and `description`. An `array` parameter also carries `items`, which defaults to `{ "type": "string" }`. `inputSchema` is the tool's full input schema, and `required` is included on the same topic.

A tool that has never been called shows `0` counts, `UNKNOWN` ratings, and `never` for both dates. The first publish after discovery also carries `usage_example` (a ready `CALL MCP` block) and `trigger_example` (`TRIGGER "MCPSlack" TO PAYLOAD FOR "send-message"`). The periodic republish leaves them out.

### Capability Payload

`…/Tools/{tool}/Capability` is published after every call to that tool:

| Field | Description |
| - | - |
| `tool_name`, `route_name` | The tool and its connector |
| `execution_count`, `success_count`, `failure_count` | Calls since the connector started |
| `average_latency_ms`, `min_latency_ms`, `max_latency_ms` | Call time in milliseconds |
| `reliability_percent` | Share of calls that succeeded |
| `performance_rating` | `FAST` (under 100 ms), `MEDIUM` (under 500 ms), `SLOW` (under 2,000 ms), or `VERY_SLOW` |
| `reliability_rating` | `EXCELLENT` (95% or more), `GOOD` (85% or more), `FAIR` (70% or more), or `POOR` |
| `first_executed`, `last_executed` | UTC times of the first and latest call |
| `last_error` | Error of the latest failed call |
| `timestamp` | UTC time of this publish |

### Subscribing to Tool Discovery

Use MQTT Explorer or any MQTT client to discover available tools:

| What to Find | Topic Pattern |
| - | - |
| All tools for a specific connector | `$SYS/Coreflux/Routes/MCPSlack/Tools` |
| Details for a specific tool | `$SYS/Coreflux/Routes/MCPSlack/Tools/send-message` |
| Call statistics for a specific tool | `$SYS/Coreflux/Routes/MCPSlack/Tools/send-message/Capability` |
| All tools across all MCP connectors | `$SYS/Coreflux/Routes/+/Tools/#` |

> [!NOTE]
>
> Tool discovery topics are **retained messages**, so the information is immediately available when you subscribe—you don't need to wait for the next update.

***

## Use Cases

> [accordion] Alerting and Notifications
>
> Connect to Slack, email, or other messaging MCP servers to send alerts directly from LoT Actions. When a sensor crosses a threshold, the Action calls the messaging tool — no external middleware needed.

> [accordion] File and Data Management
>
> Use filesystem MCP servers to read configuration files, write sensor logs, or manage data exports. LoT Actions can read a config file at startup or append readings to a log file on every event.

> [accordion] Cloud Integration
>
> Connect to Google Drive, Excel, or other cloud MCP servers to back up IoT data, generate reports from sensor readings, or sync configurations with cloud storage.

> [accordion] External Automation
>
> Use Windows Control or custom MCP servers to automate HMI/SCADA interfaces, trigger external scripts, or interact with desktop applications as part of your IoT workflow.

***

## Best Practices

> [accordion] Security Considerations
>
> * A rule on `$SYS/Coreflux/Routes/<connector>/Tools/<tool>/Call` governs `CALL MCP`. With no matching rule, any action can call any tool on a configured MCP connector. See [Who Can Call Tools](#who-can-call-tools)
> * `SERVER_COMMAND` starts any program on the broker host. Only let trusted administrators add MCP connectors. Stopping the connector closes that process
> * Pass server credentials with `SERVER_ENV` or `SERVER_HEADER` and `GET SECRET`, never as plain text in the connector. Both values are masked in broker logs
> * A `SERVER_URL` with no `SERVER_HEADER` sends no credential. Do not expose a remote MCP server that needs no key outside a trusted network
> * Monitor MCP tool calls through logging
> * Implement rate limiting for MCP requests

> [accordion] Resource Management
>
> * Configure appropriate timeouts for MCP operations
> * Limit concurrent MCP connections if needed
> * Monitor memory usage of MCP server processes

> [accordion] Error Handling
>
> * Implement graceful fallbacks when the MCP server is unavailable
> * Log MCP communication errors for debugging
> * Set up alerts for repeated failures

***

## Troubleshooting

> [accordion] MCP Server Won't Start
>
> * Verify SERVER\_COMMAND path is correct
> * Check SERVER\_ARGUMENTS syntax (comma-separated)
> * Ensure required packages are installed (npx, node, python)
> * Check system PATH includes required executables

> [accordion] Connection Timeout
>
> * Verify MCP server is running and responsive
> * Check network/firewall settings
> * Increase timeout values if server startup is slow
> * Check server logs for errors

> [accordion] Tool Execution Fails
>
> * Verify the requested tool is available
> * Check permissions for the operation
> * Review server logs for detailed error messages
> * Ensure broker has required access rights

***

## Next Steps

> [card] [REST API Connectors](https://docs.coreflux.org/latest/connectors/rest-api/overview)
>
> Connect to external REST APIs.

> [card] [Python Integration](https://docs.coreflux.org/latest/lot-language/actions/python-integration.md)
>
> Add custom AI/ML logic with Python.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.