Method: ActionMCP::ApplicationController#destroy
- Defined in:
- app/controllers/action_mcp/application_controller.rb
#destroy ⇒ Object
Handles DELETE requests for session termination (2025-03-26 spec). <rails-lens:routes:begin> ROUTE: /, name: mcp_delete, via: DELETE <rails-lens:routes:end>
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'app/controllers/action_mcp/application_controller.rb', line 106 def destroy session_id_from_header = extract_session_id return render_bad_request("Mcp-Session-Id header is required for DELETE requests.") unless session_id_from_header session = Server.session_store.load_session(session_id_from_header) if session.nil? return render_not_found("Session not found.") elsif session.status == "closed" return head :no_content end # Authenticate the request via gateway authenticate_gateway! return if performed? begin session.close! Rails.logger.info "Unified DELETE: Terminated session: #{session.id}" if ActionMCP.configuration.verbose_logging head :no_content rescue StandardError => e Rails.logger.error "Unified DELETE: Error terminating session #{session.id}: #{e.class} - #{e.}" render_internal_server_error("Failed to terminate session.") end end |