Skip to content

MCP Plugin

The MCP Plugin acts as a mediator between the Brain framework and an MCP server. It connects to an MCP serverβ€”either locally via stdio or remotely via SSEβ€”retrieves available tools and converts them into actions that the Brain Framework can execute. The actions are generated dynamically based on the MCP server’s capabilities.

There are two ways to configure the plugin:

  • Stdio Mode: For local MCP servers using process-based communication.
  • SSE Mode: For remote MCP servers using Server-Sent Events.

Installation

Install the plugin:

Terminal window
npm i @iqai/plugin-mcp

Configuration

Configure the plugin with the following parameters:

Param NameDescriptionRequired
nameName of the MCP pluginYes
descriptionDescription of the pluginYes
transportTransport configuration object (see below)Yes

Transport Configuration

Configure the plugin for either stdio or sse modes.

Stdio Mode

Use stdio mode when you want to run a local MCP server as a separate process.

Param NameDescription
modeMust be set to "stdio"
commandCommand to run the local MCP server process
argsArguments for the local MCP server process (string list)

SSE Mode

Use sse mode to connect to a remote MCP server via Server-Sent Events. (Note: Authentication is not supported for SSE mode at this time.)

Param NameDescription
modeMust be set to "sse"
serverUrlThe base URL of the remote MCP server
headersHeaders to include (if any) in the request to the remote server

Usage

Import and initialize the plugin using the createMcpPlugin method.

For a Local MCP Server (Stdio Mode)

import { createMcpPlugin } from "@iqai/plugin-mcp";
// Initialize the plugin with stdio configuration
const pluginFs = await createMcpPlugin({
name: "file-system",
description: "File system MCP server",
transport: {
mode: "stdio",
command: "npx",
args: [
"-y",
"@modelcontextprotocol/server-filesystem",
"/home/user/",
"/home/user/Desktop",
],
}
});

For a Remote MCP Server (SSE Mode)

import { createMcpPlugin } from "@iqai/plugin-mcp";
// Initialize the plugin with sse configuration
const plugin = await createMcpPlugin({
name: "remote-mcp-tools",
description: "Remote MCP server tools",
transport: {
mode: "sse",
serverUrl: "YOUR_SERVER_URL",
headers: {}
}
});

Once initialized, the plugin dynamically generates actions based on the MCP server’s available tools, prompts, and resources.


πŸ”„ Automatic Tool Chaining

The plugin features automatic tool chaining, which enables more powerful interactions between tools:

  • When a tool returns a file path, the system can automatically use filesystem tools if available to read the content
  • Structured data outputs from one tool can serve as inputs to another tool
  • Complex workflows can be automated without requiring explicit tool invocation for each step

For example, if a tool generates a code file and returns its path, the system will automatically detect this and can:

  1. Read the file content using filesystem tools if available by a plugin or via filesystem mcp server.
  2. Present the code with proper formatting
  3. Suggest further actions based on the file type

Error Handling

The plugin manages various error scenarios, such as:

  • Connection failures to the MCP server.
  • Invalid tool, prompt, or resource requests.
  • Network errors or unexpected server responses.

Errors are logged and relayed as informative messages to the Brain UI.


Security Considerations

For SSE mode:

  • Ensure you are connecting to a trusted MCP server.
  • Use HTTPS endpoints for secure communication.
  • Validate all configuration parameters to avoid misconfigurations.

Learn More About MCP

For more details on the Model Context Protocol and available server implementations, check out these resources: