Class: Msf::MCP::Middleware::RequestLogger
- Inherits:
-
Object
- Object
- Msf::MCP::Middleware::RequestLogger
- Defined in:
- lib/msf/core/mcp/middleware/request_logger.rb
Overview
Rack middleware that logs MCP HTTP request/response details via Rex logging.
Focuses on the HTTP transport layer: request method, status code, session ID, content type, and round-trip timing. For POST requests it also extracts JSON-RPC fields (method, id, params) and response result/error to provide DEBUG-level visibility into the exchange.
MCP-level business details (tool names, tool durations, and structured results) are handled by the SDK’s around_request callback configured in Server, avoiding duplication.
Instance Method Summary collapse
-
#call(env) ⇒ Array
Process the request, delegating to the next Rack app and logging transport-level details after the response is produced.
-
#initialize(app) ⇒ RequestLogger
constructor
A new instance of RequestLogger.
Constructor Details
#initialize(app) ⇒ RequestLogger
Returns a new instance of RequestLogger.
28 29 30 |
# File 'lib/msf/core/mcp/middleware/request_logger.rb', line 28 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Array
Process the request, delegating to the next Rack app and logging transport-level details after the response is produced.
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/msf/core/mcp/middleware/request_logger.rb', line 39 def call(env) request = Rack::Request.new(env) started_at = Process.clock_gettime(Process::CLOCK_MONOTONIC) response = @app.call(env) elapsed = Process.clock_gettime(Process::CLOCK_MONOTONIC) - started_at log_exchange(request, response, elapsed) response end |