Module: ActionMCP::Server::MessagingService
- Includes:
- BaseMessaging
- Included in:
- TransportHandler
- Defined in:
- lib/action_mcp/server/messaging_service.rb
Instance Attribute Summary collapse
-
#messaging_mode ⇒ Object
Returns the value of attribute messaging_mode.
Instance Method Summary collapse
- #send_jsonrpc_error(request_id, symbol, message, data = nil) ⇒ Object
- #send_jsonrpc_notification(method, params = nil) ⇒ Object
- #send_jsonrpc_request(method, params: nil, id: SecureRandom.uuid_v7) ⇒ Object
- #send_jsonrpc_response(request_id, result: nil, error: nil) ⇒ Object
- #send_logging_message_notification(level:, data:, logger: nil) ⇒ Object
- #send_progress_notification(progressToken:, progress:, total: nil, message: nil, **options) ⇒ Object
- #send_prompts_list_changed_notification ⇒ Object
- #send_resource_updated_notification(uri) ⇒ Object
-
#send_resources_list_changed_notification ⇒ Object
Specific notifications.
- #send_tools_list_changed_notification ⇒ Object
Instance Attribute Details
#messaging_mode ⇒ Object
Returns the value of attribute messaging_mode.
8 9 10 |
# File 'lib/action_mcp/server/messaging_service.rb', line 8 def messaging_mode @messaging_mode end |
Instance Method Details
#send_jsonrpc_error(request_id, symbol, message, data = nil) ⇒ Object
25 26 27 28 |
# File 'lib/action_mcp/server/messaging_service.rb', line 25 def send_jsonrpc_error(request_id, symbol, , data = nil) error = JSON_RPC::JsonRpcError.new(symbol, message: , data: data) send_jsonrpc_response(request_id, error: error) end |
#send_jsonrpc_notification(method, params = nil) ⇒ Object
21 22 23 |
# File 'lib/action_mcp/server/messaging_service.rb', line 21 def send_jsonrpc_notification(method, params = nil) (:notification, method: method, params: params) end |
#send_jsonrpc_request(method, params: nil, id: SecureRandom.uuid_v7) ⇒ Object
10 11 12 |
# File 'lib/action_mcp/server/messaging_service.rb', line 10 def send_jsonrpc_request(method, params: nil, id: SecureRandom.uuid_v7) (:request, method: method, params: params, id: id) end |
#send_jsonrpc_response(request_id, result: nil, error: nil) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/action_mcp/server/messaging_service.rb', line 14 def send_jsonrpc_response(request_id, result: nil, error: nil) args = { id: request_id } args[:result] = result unless result.nil? args[:error] = error unless error.nil? (:response, **args) end |
#send_logging_message_notification(level:, data:, logger: nil) ⇒ Object
47 48 49 50 51 |
# File 'lib/action_mcp/server/messaging_service.rb', line 47 def (level:, data:, logger: nil) params = { level: level, data: data } params[:logger] = logger if logger.present? send_jsonrpc_notification("notifications/logging/message", params) end |
#send_progress_notification(progressToken:, progress:, total: nil, message: nil, **options) ⇒ Object
53 54 55 56 57 58 59 |
# File 'lib/action_mcp/server/messaging_service.rb', line 53 def send_progress_notification(progressToken:, progress:, total: nil, message: nil, **) params = { progressToken: progressToken, progress: progress } params[:total] = total unless total.nil? params[:message] = if .present? params.merge!() if .any? send_jsonrpc_notification("notifications/progress", params) end |
#send_prompts_list_changed_notification ⇒ Object
43 44 45 |
# File 'lib/action_mcp/server/messaging_service.rb', line 43 def send_prompts_list_changed_notification send_jsonrpc_notification("notifications/prompts/list_changed") end |
#send_resource_updated_notification(uri) ⇒ Object
35 36 37 |
# File 'lib/action_mcp/server/messaging_service.rb', line 35 def send_resource_updated_notification(uri) send_jsonrpc_notification("notifications/resources/updated", { uri: uri }) end |
#send_resources_list_changed_notification ⇒ Object
Specific notifications
31 32 33 |
# File 'lib/action_mcp/server/messaging_service.rb', line 31 def send_resources_list_changed_notification send_jsonrpc_notification("notifications/resources/list_changed") end |
#send_tools_list_changed_notification ⇒ Object
39 40 41 |
# File 'lib/action_mcp/server/messaging_service.rb', line 39 def send_tools_list_changed_notification send_jsonrpc_notification("notifications/tools/list_changed") end |