Commit 8be2248
Address WebSocket flexibility feedback and add plugin to main README
This commit addresses reviewer @h3xxit's feedback that the WebSocket implementation was "too restrictive" by implementing maximum flexibility to work with ANY WebSocket endpoint.
Key Changes:
- **Flexible Message Templating**: Added `message` field (Union[str, Dict[str, Any]]) with ${arg_name} placeholder support
- Dict templates: Support structured messages like JSON-RPC, chat protocols
- String templates: Support text-based protocols like IoT commands
- No template (default): Sends arguments as-is in JSON for maximum compatibility
- **Flexible Response Handling**: Added `response_format` field (Optional["json", "text", "raw"])
- No format (default): Returns raw response without processing
- Works with any WebSocket response structure
- **Removed Restrictive Fields**:
- Removed `request_data_format`, `request_data_template`, `message_format`
- No longer enforces specific request/response structure
- **Implementation**:
- Added `_substitute_placeholders()` method for recursive template substitution
- Updated `_format_tool_call_message()` to use template or send args as-is
- Updated `call_tool()` to return raw responses by default
- **Testing**: Updated all 9 tests to reflect new flexibility approach
- **Documentation**:
- Updated README to emphasize "maximum flexibility" principle
- Added examples showing no template, dict template, and string template usage
- Added WebSocket entry to main README plugin table
Philosophy: "Talk to as many WebSocket endpoints as possible" - UTCP should adapt to existing endpoints, not require endpoints to adapt to UTCP.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>1 parent 86389da commit 8be2248
5 files changed
Lines changed: 837 additions & 1083 deletions
File tree
- plugins/communication_protocols/websocket
- src/utcp_websocket
- tests
0 commit comments