{"id":50749656,"url":"https://github.com/n-car/node-red-contrib-rpc-toolkit","last_synced_at":"2026-06-11T00:02:53.906Z","repository":{"id":326225551,"uuid":"1104582941","full_name":"n-car/node-red-contrib-rpc-toolkit","owner":"n-car","description":"Node-RED nodes for JSON-RPC communication with support for introspection, schema and middleware integration","archived":false,"fork":false,"pushed_at":"2026-06-10T23:00:00.000Z","size":235,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-10T23:22:12.309Z","etag":null,"topics":["json-rpc2","node-red-contrib"],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/n-car.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-11-26T12:06:41.000Z","updated_at":"2026-06-10T22:58:13.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/n-car/node-red-contrib-rpc-toolkit","commit_stats":null,"previous_names":["n-car/node-red-contrib-rpc-toolkit"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/n-car/node-red-contrib-rpc-toolkit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/n-car%2Fnode-red-contrib-rpc-toolkit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/n-car%2Fnode-red-contrib-rpc-toolkit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/n-car%2Fnode-red-contrib-rpc-toolkit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/n-car%2Fnode-red-contrib-rpc-toolkit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/n-car","download_url":"https://codeload.github.com/n-car/node-red-contrib-rpc-toolkit/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/n-car%2Fnode-red-contrib-rpc-toolkit/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34175888,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-10T02:00:07.152Z","response_time":89,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["json-rpc2","node-red-contrib"],"created_at":"2026-06-11T00:02:53.320Z","updated_at":"2026-06-11T00:02:53.894Z","avatar_url":"https://github.com/n-car.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# node-red-contrib-rpc-toolkit\n\n[![npm version](https://badge.fury.io/js/node-red-contrib-rpc-toolkit.svg)](https://www.npmjs.com/package/node-red-contrib-rpc-toolkit)\n[![License](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)\n[![Node-RED](https://img.shields.io/badge/Node--RED-%3E%3D3.0.0-red.svg)](https://nodered.org/)\n\nJSON-RPC 2.0 client and server nodes for Node-RED. Build powerful automation flows with RPC communication to Express, PHP, .NET, Arduino, and ESP32 devices.\n\n![Node-RED RPC Toolkit](https://raw.githubusercontent.com/n-car/node-red-contrib-rpc-toolkit/main/docs/images/banner.png)\n\n## 🎯 Features\n\n### Core Nodes\n- **RPC Server** - Expose Node-RED flows as RPC methods via HTTP\n- **RPC Client** - Call remote RPC servers (Express, PHP, .NET, Arduino)\n- **RPC Method** - Register method handlers in flows\n- **RPC Request** - Parse incoming RPC requests\n- **RPC Response** - Send RPC responses\n\n### Advanced Features\n- ✅ **JSON-RPC 2.0 Compliance** - Full specification support\n- ✅ **Introspection API** - Discover methods with `__rpc.*` (listMethods, describe, version, capabilities)\n- ✅ **Cross-Platform** - Works with entire RPC Toolkit ecosystem\n- ✅ **Safe Mode** - Type-safe serialization with prefixes\n- ✅ **Batch Requests** - Process multiple requests efficiently\n- ✅ **Schema Support** - JSON Schema validation and exposition\n- ✅ **Error Handling** - Structured error responses\n- ✅ **Authentication** - JWT and custom auth support\n- ✅ **CORS** - Cross-origin resource sharing\n- ✅ **Rate Limiting** - Protect your endpoints\n- ✅ **Logging** - Built-in debug and logging\n\n## 📦 Installation\n\n### Via Node-RED Palette Manager\n1. Open Node-RED\n2. Go to **Menu → Manage Palette**\n3. Click **Install** tab\n4. Search for `node-red-contrib-rpc-toolkit`\n5. Click **Install**\n\n### Via npm\n```bash\ncd ~/.node-red\nnpm install node-red-contrib-rpc-toolkit\n```\n\n### Via command line\n```bash\nnpm install -g node-red-contrib-rpc-toolkit\n```\n\nThen restart Node-RED.\n\n## 🚀 Quick Start\n\n### Example 1: Simple RPC Server\n\nCreate a flow that exposes a `ping` method:\n\n```\n[RPC Server] → [RPC Method: \"ping\"] → [Function: return \"pong\"] → [RPC Response]\n```\n\n**Configuration:**\n1. Add **RPC Server** node, set port `1880`, endpoint `/rpc`\n2. Add **RPC Method** node, set name `ping`\n3. Add **Function** node with: `msg.payload = \"pong\"; return msg;`\n4. Connect to **RPC Response** node\n\n**Test:**\n```bash\ncurl -X POST http://localhost:1880/rpc \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"jsonrpc\":\"2.0\",\"method\":\"ping\",\"id\":1}'\n```\n\n**Response:**\n```json\n{\"jsonrpc\":\"2.0\",\"result\":\"pong\",\"id\":1}\n```\n\n### Call Arduino/ESP32\n\n```\n[Inject] → [RPC Client] → [Debug]\n```\n\n**RPC Client Configuration:**\n- Server URL: `http://192.168.1.100:8080`\n- Method: `readTemp`\n- Timeout: `5000` ms\n\n**Output:** `msg.payload = 25.5`\n\n**Discover Arduino methods:**\n\n```javascript\n// Use RPC Client node to call introspection\n// Method: __rpc.listMethods\n// Output: [\"readTemp\", \"setLED\", \"readSensors\", ...]\n\n// Get method details\n// Method: __rpc.describe\n// Params: {\"method\": \"readTemp\"}\n// Output: {\"name\":\"readTemp\",\"description\":\"Read temperature sensor\",\"exposeSchema\":true}\n```\n\n### Example 3: IoT Sensor Hub\n\n```\n[RPC Method: \"getAllSensors\"]\n  ↓\n[MQTT In] → [Parse Sensors] → [Format Response]\n  ↓\n[RPC Response]\n```\n\nRegister method that aggregates data from multiple sensors via MQTT.\n\n## 📚 Node Documentation\n\n### RPC Server Node\n\nCreates an HTTP server that handles JSON-RPC 2.0 requests.\n\n**Properties:**\n- **Port** - Server port (default: `1880`)\n- **Endpoint** - URL path (default: `/rpc`)\n- **Safe Mode** - Always enabled for Node-RED servers to guarantee type-safe serialization\n- **CORS** - Enable cross-origin requests\n- **Auth** - Enable authentication\n- **Rate Limit** - Requests per minute\n\n**Output:** Emits events for monitoring\n\n### RPC Client Node\n\nCalls remote RPC servers.\n\n**Properties:**\n- **Server URL** - Target server (e.g., `http://localhost:3000/rpc`)\n- **Method** - RPC method name\n- **Timeout** - Request timeout in ms\n- **Auth Token** - Optional authentication\n- **Safe Mode** - Enabled by default; disable only when calling legacy servers that do not support RPC Toolkit safe serialization\n\n**Input:** `msg.payload` = method parameters\n**Output:** `msg.payload` = result or error\n\n### RPC Method Node\n\nRegisters a method handler in the RPC server.\n\n**Properties:**\n- **Server** - Link to RPC Server node\n- **Method Name** - Name of the method (e.g., `getStatus`)\n- **Description** - Human-readable description of the method (optional)\n- **Expose Schema** - Allow introspection via `__rpc.describe` (checkbox)\n- **Validate Schema** - Enable JSON Schema validation (checkbox)\n- **Schema** - Optional JSON Schema for validation\n\n**Outputs:**\n- **Output 1** - Emits RPC parameters for processing (includes `msg.rpc.id` / `methodNodeId`)\n- **Output 2** - Emits immediate errors raised by the method node\n\n**Response Handling:** Send the final result (or error) to an **RPC Response** node to reply to the caller. Keep `msg.rpc` intact so the pending request can be matched.\n\n**Introspection Support:**\nWhen \"Expose Schema\" is enabled, clients can discover this method via:\n- `__rpc.listMethods` - Lists all method names\n- `__rpc.describe` - Gets method description and schema info\n- `__rpc.describeAll` - Gets all methods with public schemas\n\n### RPC Request Node\n\nParses incoming RPC request from HTTP.\n\n**Output:**\n- `msg.payload` - Method parameters\n- `msg.rpc.method` - Method name\n- `msg.rpc.id` - Request ID\n- `msg.rpc.jsonrpc` - Protocol version\n\n### RPC Response Node\n\nSends RPC response back to client.\n\n**Input:**\n- `msg.payload` - Result to return\n- `msg.rpc.id` - Request ID (from RPC Request)\n- `msg.rpc.methodNodeId` - Method node reference (added automatically)\n- `msg.error` - Error object (if error occurred)\n\n**Notes:**\n- Every RPC Method flow must end with an **RPC Response** node (or equivalent) to send the result back.\n- The **RPC Method** node automatically attaches `msg.rpc.methodNodeId` and `msg.rpc.id` so the response can be routed back to the correct pending request.\n- Set `msg.error` to return an RPC error response; otherwise `msg.payload` is used as the successful result.\n\n## 🎨 Example Flows\n\n### Introspection API Discovery\n\nDiscover available methods from any RPC client:\n\n```bash\n# List all available methods\ncurl -X POST http://localhost:1880/rpc \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"jsonrpc\":\"2.0\",\"method\":\"__rpc.listMethods\",\"id\":1}'\n\n# Response: {\"jsonrpc\":\"2.0\",\"result\":[\"ping\",\"add\",\"getUser\"],\"id\":1}\n\n# Get method description\ncurl -X POST http://localhost:1880/rpc \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"jsonrpc\":\"2.0\",\"method\":\"__rpc.describe\",\"params\":{\"method\":\"add\"},\"id\":2}'\n\n# Response: {\"jsonrpc\":\"2.0\",\"result\":{\"name\":\"add\",\"description\":\"Add two numbers\",\"exposeSchema\":true,\"schema\":{...}},\"id\":2}\n\n# Get all public methods with schemas\ncurl -X POST http://localhost:1880/rpc \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"jsonrpc\":\"2.0\",\"method\":\"__rpc.describeAll\",\"id\":3}'\n\n# Get server version and capabilities\ncurl -X POST http://localhost:1880/rpc \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"jsonrpc\":\"2.0\",\"method\":\"__rpc.version\",\"id\":4}'\n\n# Response: {\"jsonrpc\":\"2.0\",\"result\":{\"toolkit\":\"rpc-express-toolkit\",\"version\":\"4.3.3\",\"nodeVersion\":\"v18.0.0\"},\"id\":4}\n\ncurl -X POST http://localhost:1880/rpc \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"jsonrpc\":\"2.0\",\"method\":\"__rpc.capabilities\",\"id\":5}'\n\n# Response: {\"jsonrpc\":\"2.0\",\"result\":{\"batch\":true,\"introspection\":true,\"validation\":true,\"safeMode\":true,\"methodCount\":5},\"id\":5}\n```\n\n**Built-in introspection methods:**\n- `__rpc.listMethods` - Returns array of all method names (excludes `__rpc.*` methods)\n- `__rpc.describe` - Returns `{name, description, exposeSchema, schema}` for a specific method\n- `__rpc.describeAll` - Returns array of all methods with `exposeSchema: true`\n- `__rpc.version` - Returns toolkit version and Node.js version info\n- `__rpc.capabilities` - Returns server features (batch, introspection, validation, etc.)\n\n**Register methods with schema exposition:**\n\n```\n[RPC Method]\n  Method Name: \"add\"\n  Description: \"Add two numbers\"\n  ☑ Expose Schema\n  ☑ Validate Schema\n  Properties:\n    - a: number (required)\n    - b: number (required)\n```\n\n### Home Automation Hub\n\nControl smart devices via RPC:\n\n```json\n[\n  {\n    \"id\": \"server1\",\n    \"type\": \"rpc-server\",\n    \"name\": \"Home Hub\",\n    \"port\": 1880,\n    \"endpoint\": \"/rpc\",\n    \"cors\": true\n  },\n  {\n    \"id\": \"method1\",\n    \"type\": \"rpc-method\",\n    \"name\": \"setLight\",\n    \"server\": \"server1\",\n    \"wires\": [[\"mqtt1\"]]\n  },\n  {\n    \"id\": \"mqtt1\",\n    \"type\": \"mqtt out\",\n    \"topic\": \"home/light/set\",\n    \"wires\": [[\"response1\"]]\n  },\n  {\n    \"id\": \"response1\",\n    \"type\": \"rpc-response\"\n  }\n]\n```\n\n**Usage:**\n```javascript\n// From browser or mobile app\nconst client = new RpcClient('http://home-hub:1880/rpc');\nawait client.call('setLight', { room: 'bedroom', state: true });\n```\n\n### Multi-Device Orchestration\n\nCall multiple devices in parallel:\n\n```\n[Inject]\n  ↓\n[RPC Batch]\n  ├→ [RPC Client: Arduino 1] → readTemp\n  ├→ [RPC Client: Arduino 2] → readHumidity\n  └→ [RPC Client: ESP32] → readPressure\n  ↓\n[Join] → [Function: aggregate] → [Dashboard]\n```\n\n### Database Query Service\n\n```\n[RPC Method: \"getUser\"]\n  ↓\n[SQL Query]\n  ↓\n[Transform Data]\n  ↓\n[RPC Response]\n```\n\n### ESP32 Bridge\n\nForward requests to ESP32 devices:\n\n```\n[RPC Server :1880]\n  ↓\n[RPC Method: \"device.*\"]\n  ↓\n[Switch: by method]\n  ├→ device.led → [RPC Client: ESP32 :8080]\n  ├→ device.temp → [RPC Client: ESP32 :8080]\n  └→ device.status → [RPC Client: ESP32 :8080]\n  ↓\n[RPC Response]\n```\n\n## 🔧 Configuration Examples\n\n### Enable Authentication\n\n```javascript\n// In RPC Server node settings\n{\n  \"auth\": {\n    \"enabled\": true,\n    \"secret\": \"your-jwt-secret\",\n    \"validateToken\": function(token) {\n      // Validate JWT or custom token\n      return isValidToken(token);\n    }\n  }\n}\n```\n\n### Enable Rate Limiting\n\n```javascript\n{\n  \"rateLimit\": {\n    \"enabled\": true,\n    \"maxRequests\": 100,\n    \"windowMs\": 60000  // 1 minute\n  }\n}\n```\n\n### Custom Error Handling\n\n```javascript\n// In Function node before RPC Response\nif (error) {\n  msg.error = {\n    code: -32000,\n    message: \"Custom error message\",\n    data: { details: \"...\" }\n  };\n}\nreturn msg;\n```\n\n## 🌐 Cross-Platform Integration\n\nAll introspection methods work seamlessly across platforms!\n\n### Call PHP Server\n\n```javascript\n// RPC Client node → PHP backend\n{\n  \"url\": \"http://api.example.com/rpc\",\n  \"method\": \"user.create\",\n  \"params\": {\n    \"name\": \"John\",\n    \"email\": \"john@example.com\"\n  }\n}\n\n// Discover PHP methods\n{\n  \"method\": \"__rpc.listMethods\"  // Works on PHP server too!\n}\n```\n\n### Call .NET Service\n\n```javascript\n// RPC Client node → .NET microservice\n{\n  \"url\": \"http://services.example.com:5000/api/rpc\",\n  \"method\": \"order.process\",\n  \"params\": {\n    \"orderId\": 12345\n  }\n}\n\n// Get .NET method schema\n{\n  \"method\": \"__rpc.describe\",\n  \"params\": {\"method\": \"order.process\"}\n}\n```\n\n### Call Arduino/ESP32\n\n```javascript\n// RPC Client node → ESP32 device\n{\n  \"url\": \"http://192.168.1.100:8080\",\n  \"method\": \"readSensors\",\n  \"params\": {}\n}\n\n// Check ESP32 capabilities\n{\n  \"method\": \"__rpc.capabilities\"\n}\n// Result: {\"batch\":true,\"introspection\":true,\"safeMode\":true,\"methodCount\":5,\"maxMethods\":8}\n```\n\n### Dashboard Integration\n\nUse with **node-red-dashboard**:\n\n```\n[UI Button: \"Read Temp\"]\n  ↓\n[RPC Client: ESP32]\n  ↓\n[UI Chart: Temperature]\n```\n\n## 📊 Monitoring \u0026 Debugging\n\n### Enable Logging\n\nSet log level in RPC Server node:\n- **Error** - Only errors\n- **Warn** - Warnings and errors\n- **Info** - General information\n- **Debug** - Detailed debugging\n\n### View RPC Traffic\n\nConnect **Debug** nodes to RPC Server output:\n\n```\n[RPC Server]\n  ↓ (events)\n[Debug: \"RPC Traffic\"]\n```\n\nShows all incoming requests and responses.\n\n### Metrics\n\nRPC Server emits metrics:\n- `msg.rpc.metrics.requestCount`\n- `msg.rpc.metrics.errorCount`\n- `msg.rpc.metrics.avgResponseTime`\n\n## 🔗 Compatible Projects\n\nThis toolkit works seamlessly with:\n- ✅ **[rpc-express-toolkit](https://github.com/n-car/rpc-express-toolkit)** - Node.js/Express\n- ✅ **[rpc-php-toolkit](https://github.com/n-car/rpc-php-toolkit)** - PHP\n- ✅ **[rpc-dotnet-toolkit](https://github.com/n-car/rpc-dotnet-toolkit)** - .NET\n- ✅ **[rpc-arduino-toolkit](https://github.com/n-car/rpc-arduino-toolkit)** - Arduino/ESP32\n\n## 🎯 Use Cases\n\n### IoT \u0026 Home Automation\n- Smart home control hub\n- Sensor data aggregation\n- Device orchestration\n- Real-time monitoring\n\n### Microservices\n- Service orchestration\n- API gateway\n- Event-driven workflows\n- Data transformation\n\n### Industrial Automation\n- PLC communication\n- SCADA integration\n- Equipment monitoring\n- Process control\n\n### Prototyping\n- Rapid API development\n- Mock servers\n- Testing tools\n- Demo systems\n\n## 📖 API Reference\n\n### Safe Mode\n\nEnable type-safe serialization:\n\n**Server:**\n```javascript\n{\n  \"safeMode\": true\n}\n```\n\n**Client:**\n```javascript\n{\n  \"safeMode\": true\n}\n```\n\n**Behavior:**\n- Strings: `\"hello\"` → `\"S:hello\"`\n- Dates: ISO string → `\"D:2025-11-26T10:30:00Z\"`\n- BigInt: `9007199254740992` → `\"9007199254740992n\"`\n\n### Batch Requests\n\nSend multiple requests at once:\n\n```javascript\n// msg.payload\n[\n  {\"method\": \"readTemp\", \"id\": 1},\n  {\"method\": \"readHumidity\", \"id\": 2},\n  {\"method\": \"readPressure\", \"id\": 3}\n]\n```\n\n### Notifications\n\nFire-and-forget (no response):\n\n```javascript\n// RPC Client with no response expected\n{\n  \"method\": \"log.event\",\n  \"params\": {\"level\": \"info\", \"msg\": \"User login\"},\n  \"notification\": true  // No ID, no response\n}\n```\n\n## 🛠️ Development\n\n### Clone Repository\n\n```bash\ngit clone https://github.com/n-car/node-red-contrib-rpc-toolkit.git\ncd node-red-contrib-rpc-toolkit\nnpm install\n```\n\n### Link for Development\n\n```bash\nnpm link\ncd ~/.node-red\nnpm link node-red-contrib-rpc-toolkit\n```\n\n### Run Tests\n\n```bash\nnpm test\n```\n\n## 🔗 Related Projects\n\n- [rpc-express-toolkit](https://github.com/n-car/rpc-express-toolkit) - Node.js/Express implementation\n- [rpc-php-toolkit](https://github.com/n-car/rpc-php-toolkit) - PHP implementation\n- [rpc-dotnet-toolkit](https://github.com/n-car/rpc-dotnet-toolkit) - .NET implementation\n- [rpc-arduino-toolkit](https://github.com/n-car/rpc-arduino-toolkit) - Arduino/ESP32 implementation\n- [rpc-java-toolkit](https://github.com/n-car/rpc-java-toolkit) - Java \u0026 Android implementation\n\n## 🤝 Contributing\n\nContributions are welcome! Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details.\n\n## 📄 License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## 🙏 Acknowledgments\n\n- Built on [rpc-express-toolkit](https://github.com/n-car/rpc-express-toolkit)\n- Compatible with the entire RPC Toolkit ecosystem\n- Inspired by the Node-RED community\n\n---\n\n**node-red-contrib-rpc-toolkit** - Bring JSON-RPC 2.0 to your Node-RED flows.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fn-car%2Fnode-red-contrib-rpc-toolkit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fn-car%2Fnode-red-contrib-rpc-toolkit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fn-car%2Fnode-red-contrib-rpc-toolkit/lists"}