node-red-contrib-mcp-protocol 0.1.2
Node-RED component for MCP protocol communication
Node-RED MCP Protocol Component
A Node-RED component for communicating with devices using the MCP protocol.
Features
- Receive data from MCP protocol servers
- Send data to MCP protocol servers
- Configurable data formats (string, JSON, buffer)
- Automatic reconnection on connection loss
- Support for authentication
Installation
Local Installation
To install the node in your Node-RED installation:
cd ~/.node-red
npm install /path/to/node-red-contrib-mcp-protocol
Global Installation
To install the node globally:
npm install -g /path/to/node-red-contrib-mcp-protocol
Usage
Configuration
- Add an MCP configuration node
- Configure the host and port for your MCP server
- Optionally set the device ID and authentication key if required by your MCP server
Receiving Data
- Add an "MCP In" node to your flow
- Configure it to use your MCP configuration
- Select the output format (Auto-detect, String, Buffer, or JSON)
- Connect the output to other nodes in your flow
Sending Data
- Add an "MCP Out" node to your flow
- Configure it to use your MCP configuration
- Select the input format (Auto-convert, String, Buffer, or JSON)
- Connect other nodes to the input of the MCP Out node
Example Flow
[
{
"id": "f6f2187d.f17ca8",
"type": "mcp-in",
"z": "2b9467.5f69d7cc",
"name": "MCP Receiver",
"server": "3fa97a8a.3b9946",
"topic": "mcp/data",
"dataType": "json",
"x": 270,
"y": 180,
"wires": [
[
"25f5d5dd.2d836a"
]
]
},
{
"id": "25f5d5dd.2d836a",
"type": "debug",
"z": "2b9467.5f69d7cc",
"name": "MCP Data",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"x": 460,
"y": 180,
"wires": []
},
{
"id": "3fa97a8a.3b9946",
"type": "mcp-config",
"name": "MCP Server",
"host": "192.168.1.100",
"port": "1234",
"reconnectTimeout": "5000",
"mcpVersion": "1.0",
"deviceId": "node-red-client",
"authKey": ""
}
]
Customizing the MCP Protocol
The current implementation uses a simplified version of the MCP protocol with newline-delimited messages. To customize for your specific MCP protocol implementation:
- Modify the
processBuffer
method inmcp-config.js
to match your protocol's message format - Adjust the authentication mechanism in the
connect
method if needed - Update the data processing in
mcp-in.js
andmcp-out.js
to handle your specific data formats
License
MIT License
Copyright (c) 2025 Hindurable
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.