Class: VectorMCP::Middleware::Base
- Inherits:
-
Object
- Object
- VectorMCP::Middleware::Base
- Defined in:
- lib/vector_mcp/middleware/base.rb
Overview
Base class for all middleware implementations Provides common functionality and hook method templates
Instance Method Summary collapse
-
#after_auth(context) ⇒ Object
Called after successful authentication.
-
#after_prompt_get(context) ⇒ Object
Called after successful prompt get.
-
#after_resource_read(context) ⇒ Object
Called after successful resource read.
-
#after_response(context) ⇒ Object
Called after successful response.
-
#after_sampling_response(context) ⇒ Object
Called after successful sampling response.
-
#after_tool_call(context) ⇒ Object
Called after successful tool execution.
-
#before_auth(context) ⇒ Object
Called before authentication.
-
#before_prompt_get(context) ⇒ Object
Called before prompt get.
-
#before_request(context) ⇒ Object
Called before any request processing.
-
#before_resource_read(context) ⇒ Object
Called before resource read.
-
#before_sampling_request(context) ⇒ Object
Called before sampling request.
-
#before_tool_call(context) ⇒ Object
Called before tool execution.
-
#call(hook_type, context) ⇒ Object
Generic hook dispatcher - override specific hook methods instead.
-
#initialize(config = {}) ⇒ Base
constructor
Initialize middleware with optional configuration.
-
#on_auth_error(context) ⇒ Object
Called when authentication fails.
-
#on_prompt_error(context) ⇒ Object
Called when prompt get fails.
-
#on_resource_error(context) ⇒ Object
Called when resource read fails.
-
#on_sampling_error(context) ⇒ Object
Called when sampling fails.
-
#on_tool_error(context) ⇒ Object
Called when tool execution fails.
-
#on_transport_error(context) ⇒ Object
Called when transport error occurs.
Constructor Details
#initialize(config = {}) ⇒ Base
Initialize middleware with optional configuration
10 11 12 13 |
# File 'lib/vector_mcp/middleware/base.rb', line 10 def initialize(config = {}) @config = config @logger = VectorMCP.logger_for("middleware.#{self.class.name.split("::").last.downcase}") end |
Instance Method Details
#after_auth(context) ⇒ Object
Called after successful authentication
138 139 140 |
# File 'lib/vector_mcp/middleware/base.rb', line 138 def after_auth(context) # Override in subclasses end |
#after_prompt_get(context) ⇒ Object
Called after successful prompt get
78 79 80 |
# File 'lib/vector_mcp/middleware/base.rb', line 78 def after_prompt_get(context) # Override in subclasses end |
#after_resource_read(context) ⇒ Object
Called after successful resource read
58 59 60 |
# File 'lib/vector_mcp/middleware/base.rb', line 58 def after_resource_read(context) # Override in subclasses end |
#after_response(context) ⇒ Object
Called after successful response
118 119 120 |
# File 'lib/vector_mcp/middleware/base.rb', line 118 def after_response(context) # Override in subclasses end |
#after_sampling_response(context) ⇒ Object
Called after successful sampling response
98 99 100 |
# File 'lib/vector_mcp/middleware/base.rb', line 98 def after_sampling_response(context) # Override in subclasses end |
#after_tool_call(context) ⇒ Object
Called after successful tool execution
38 39 40 |
# File 'lib/vector_mcp/middleware/base.rb', line 38 def after_tool_call(context) # Override in subclasses end |
#before_auth(context) ⇒ Object
Called before authentication
132 133 134 |
# File 'lib/vector_mcp/middleware/base.rb', line 132 def before_auth(context) # Override in subclasses end |
#before_prompt_get(context) ⇒ Object
Called before prompt get
72 73 74 |
# File 'lib/vector_mcp/middleware/base.rb', line 72 def before_prompt_get(context) # Override in subclasses end |
#before_request(context) ⇒ Object
Called before any request processing
112 113 114 |
# File 'lib/vector_mcp/middleware/base.rb', line 112 def before_request(context) # Override in subclasses end |
#before_resource_read(context) ⇒ Object
Called before resource read
52 53 54 |
# File 'lib/vector_mcp/middleware/base.rb', line 52 def before_resource_read(context) # Override in subclasses end |
#before_sampling_request(context) ⇒ Object
Called before sampling request
92 93 94 |
# File 'lib/vector_mcp/middleware/base.rb', line 92 def before_sampling_request(context) # Override in subclasses end |
#before_tool_call(context) ⇒ Object
Called before tool execution
32 33 34 |
# File 'lib/vector_mcp/middleware/base.rb', line 32 def before_tool_call(context) # Override in subclasses end |
#call(hook_type, context) ⇒ Object
Generic hook dispatcher - override specific hook methods instead
18 19 20 21 22 23 24 25 26 |
# File 'lib/vector_mcp/middleware/base.rb', line 18 def call(hook_type, context) @logger.debug("Executing middleware hook") do { middleware: self.class.name, hook_type: hook_type, operation: context.operation_name } end end |
#on_auth_error(context) ⇒ Object
Called when authentication fails
144 145 146 |
# File 'lib/vector_mcp/middleware/base.rb', line 144 def on_auth_error(context) # Override in subclasses end |
#on_prompt_error(context) ⇒ Object
Called when prompt get fails
84 85 86 |
# File 'lib/vector_mcp/middleware/base.rb', line 84 def on_prompt_error(context) # Override in subclasses end |
#on_resource_error(context) ⇒ Object
Called when resource read fails
64 65 66 |
# File 'lib/vector_mcp/middleware/base.rb', line 64 def on_resource_error(context) # Override in subclasses end |
#on_sampling_error(context) ⇒ Object
Called when sampling fails
104 105 106 |
# File 'lib/vector_mcp/middleware/base.rb', line 104 def on_sampling_error(context) # Override in subclasses end |
#on_tool_error(context) ⇒ Object
Called when tool execution fails
44 45 46 |
# File 'lib/vector_mcp/middleware/base.rb', line 44 def on_tool_error(context) # Override in subclasses end |
#on_transport_error(context) ⇒ Object
Called when transport error occurs
124 125 126 |
# File 'lib/vector_mcp/middleware/base.rb', line 124 def on_transport_error(context) # Override in subclasses end |