vector_mcp 0.3.0 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 11a17ca5149213858f5ec62dc28a7216cd97103e1cb066a86b96d01cbef808e6
4
- data.tar.gz: c99bcbc2a611c20432b2c401760512cf545e0cfb5329bd74c76c61c806c2c491
3
+ metadata.gz: edd8f7804cea74064b13b6432daa19149d4b2d6c34efbd7ccfbae393870b648a
4
+ data.tar.gz: bd04d07372ef947498c39021adfba055d8030b94bf76b567fc8b5cb73aae994b
5
5
  SHA512:
6
- metadata.gz: 065f397ce2448a4cea13944462b009cd511043e9a3afd85d52641cc8f05607f59d8e0ea0653f1822385f2b95def8e7ddee1bd5117db54430717c6bb20196a958
7
- data.tar.gz: a04b7cd10db5c24f9ab51fb8d4758396675fc24411530ce6a9033629fb66bd0e9974579ffb113c1401d0fe82f4e949073ca1b45d6b899c6502112781e3a5daa4
6
+ metadata.gz: 3a47a3ad028e39de9bd8d4973779040fd0c571067e4c3588ad406d26dd138cdfad06921d497a3922d1eb2406df3ede02379df7f24620539cb1170ac6fdb1bed5
7
+ data.tar.gz: ad1d3d147c3b4ef8624651aeabb0809f689bbfb5c4ae702dcc0c5fa458cc500ff7ffd54e46a4ea02ae995d908af0122f5a88b7ab895eeaab8c1d780e6eec8043
data/CHANGELOG.md ADDED
@@ -0,0 +1,349 @@
1
+ ## [0.3.2] – 2025-07-02
2
+
3
+ ### Added
4
+
5
+ * **Comprehensive Middleware System**: Pluggable hook system for custom behavior around all MCP operations
6
+ * **Hook Points**: Support for all major operations including tools, resources, prompts, sampling, transport, and authentication
7
+ * **Priority-Based Execution**: Control middleware execution order with configurable priorities
8
+ * **Conditional Execution**: Run middleware only for specific operations, users, or conditions
9
+ * **Context Management**: Rich execution context with operation metadata and session information
10
+ * **Error Handling**: Graceful error recovery with middleware-specific error hooks
11
+ * **Built-in Middleware**: PII redaction, request retry, rate limiting, and enhanced logging examples
12
+
13
+ * **Enhanced Examples Organization**: Comprehensive example reorganization for better developer experience
14
+ * **Getting Started Examples**: `examples/getting_started/` with basic server implementations
15
+ * **Core Features Examples**: `examples/core_features/` demonstrating key capabilities
16
+ * **Use Cases Examples**: `examples/use_cases/` with real-world application scenarios
17
+ * **Logging Examples**: `examples/logging/` showcasing structured logging capabilities
18
+ * **Middleware Examples**: `examples/middleware_examples.rb` and `examples/simple_middleware_demo.rb`
19
+
20
+ * **Refactored Logging System**: Enhanced logging architecture with better performance and flexibility
21
+ * **Simplified API**: Streamlined `VectorMCP.logger_for(component)` interface
22
+ * **Performance Improvements**: Optimized log formatting and output handling
23
+ * **Better Component Organization**: Hierarchical logger management with cleaner separation
24
+
25
+ ### Changed
26
+
27
+ * **Middleware Integration**: Core server architecture enhanced to support middleware hooks
28
+ * **Server Methods**: New `use_middleware`, `middleware_stats`, `remove_middleware`, and `clear_middleware` methods
29
+ * **Handler Integration**: All core handlers now support middleware execution around operations
30
+ * **Session Context**: Enhanced session context with middleware metadata and execution tracking
31
+
32
+ * **Example Structure**: Major reorganization of examples for better discoverability
33
+ * **Categorized Examples**: Logical grouping by functionality and use case
34
+ * **Enhanced Documentation**: Each example category includes detailed README files
35
+ * **Use Case Focus**: Real-world scenarios like data analysis, file operations, and web scraping
36
+
37
+ * **Backward Compatibility**: All middleware features are opt-in with zero impact on existing servers
38
+ * **Default Behavior**: Servers without middleware continue working exactly as before
39
+ * **Optional Integration**: Middleware can be added incrementally to existing applications
40
+
41
+ ### Fixed
42
+
43
+ * **Ruby Version Compatibility**: Enhanced support for older Ruby versions
44
+ * **Code Quality**: Multiple bug fixes and improvements identified through expanded test coverage
45
+ * **Performance**: Optimized middleware execution path for minimal overhead when no middleware is registered
46
+
47
+ ### Security
48
+
49
+ * **Middleware Security**: Security-aware middleware execution
50
+ * **Session Context Integration**: Middleware has access to authentication and authorization context
51
+ * **Secure Error Handling**: Middleware errors handled securely without information leakage
52
+ * **Permission-Aware Hooks**: Middleware can respect user permissions and security policies
53
+
54
+ ### Testing
55
+
56
+ * **Comprehensive Middleware Tests**: 50+ tests covering all middleware functionality
57
+ * **Hook Execution Tests**: Verification of all hook types and execution order
58
+ * **Priority and Condition Tests**: Complex scenario testing for middleware orchestration
59
+ * **Integration Tests**: End-to-end testing with real server operations
60
+ * **Performance Tests**: Overhead measurement and resource usage validation
61
+
62
+ ### Technical Details
63
+
64
+ * **API Compatibility**: All middleware features maintain full backward compatibility
65
+ * **Performance**: Minimal overhead when middleware is not used, efficient execution when enabled
66
+ * **Memory Management**: Proper cleanup and resource management for long-running servers
67
+ * **Thread Safety**: Concurrent middleware execution with proper synchronization
68
+
69
+ ## [0.3.1] – 2025-06-25
70
+
71
+ ### Added
72
+ * **Enhanced Structured Logging System**: Production-ready logging framework with comprehensive observability features
73
+ - **Component-Based Logging**: Hierarchical logger system with component-specific configuration (`server`, `transport.stdio`, `security.auth`)
74
+ - **Multiple Output Formats**: Text (with colors) and JSON formatters for different deployment needs
75
+ - **Flexible Configuration**: Support for environment variables, YAML files, and programmatic configuration
76
+ - **Context Management**: Structured context passing with `with_context` blocks and persistent context addition
77
+ - **Performance Measurement**: Built-in `measure` method for operation timing and performance monitoring
78
+ - **Log Level Management**: Component-specific log levels with runtime configuration changes
79
+ - **Legacy Compatibility**: Seamless backward compatibility with existing `VectorMCP.logger` usage
80
+ - **Thread Safety**: Concurrent logging support with proper synchronization
81
+ - **Security Logging**: Dedicated security log level for authentication and authorization events
82
+
83
+ * **Comprehensive Security Framework**: Production-ready authentication and authorization system
84
+ - **Authentication Strategies**: Multiple authentication methods with pluggable architecture
85
+ - **API Key Authentication**: Header and query parameter support with multiple key management
86
+ - **JWT Token Authentication**: JSON Web Token validation with configurable algorithms and secret management
87
+ - **Custom Authentication**: Flexible handler-based authentication for complex integration scenarios
88
+ - **Authorization System**: Fine-grained access control with policy-based permissions
89
+ - **Resource-Level Authorization**: Separate policies for tools, resources, prompts, and roots
90
+ - **Role-Based Access Control**: User role and permission management with session context
91
+ - **Action-Based Permissions**: Granular control over read, write, execute, and administrative actions
92
+ - **Security Middleware**: Comprehensive request processing pipeline
93
+ - **Request Normalization**: Consistent security processing across stdio and SSE transports
94
+ - **Session Context Management**: Secure user session tracking with authentication state
95
+ - **Error Handling**: Secure error responses without information leakage
96
+ - **Transport Integration**: Seamless security across all transport layers
97
+ - **SSE Transport Security**: Full HTTP header and query parameter authentication support
98
+ - **Stdio Transport Security**: Header simulation for desktop application authentication
99
+ - **Rack Environment Processing**: Native HTTP request processing with proper header extraction
100
+
101
+ * **Enhanced Core Handlers**: Security-aware request processing
102
+ - **Tool Execution Security**: Authentication and authorization checks for tool calls
103
+ - **Resource Access Security**: Protected resource reading with access control policies
104
+ - **Backward Compatibility**: Automatic detection of security-aware vs legacy tool handlers
105
+ - **Session Context Injection**: Optional session context parameter for security-aware handlers
106
+
107
+ * **New Security Error Types**: Proper MCP error codes for security scenarios
108
+ - **UnauthorizedError (-32401)**: Authentication required error with proper MCP formatting
109
+ - **ForbiddenError (-32403)**: Authorization failed error for access control violations
110
+
111
+ * **Security Examples and Documentation**
112
+ - **Authentication Example Server** (`examples/auth_server.rb`): Complete demonstration of all security features
113
+ - **Comprehensive Security Guide** (`security/README.md`): 400+ line documentation covering all security aspects
114
+ - **Updated Main Documentation**: Enhanced README with security feature overview and quick start examples
115
+ - **CLAUDE.md Integration**: Updated project documentation with security architecture details
116
+
117
+ ### Fixed
118
+ * Added missing runtime dependencies to gemspec for proper gem installation
119
+ - Added `jwt` gem dependency (~> 2.7) for JWT authentication strategy
120
+ - Added `rack` gem dependency (~> 3.0) for SSE transport
121
+ - Fixed JWT exception handling for compatibility with jwt gem 2.7+
122
+
123
+ ### Changed
124
+ * Enhanced gemspec description for better gem discovery
125
+ * Added CHANGELOG.md to packaged gem files
126
+ * Improved gemspec metadata for RubyGems.org listing
127
+
128
+ * **Opt-In Security Design**: Security features are disabled by default for maximum compatibility
129
+ * Existing servers continue working without modification
130
+ * Security features enabled explicitly via `enable_authentication!` and `enable_authorization!`
131
+ * Zero-configuration default maintains backward compatibility
132
+
133
+ * **Server Architecture Enhancement**: Security integration into core server functionality
134
+ * **Security Middleware Integration**: Built-in security processing pipeline
135
+ * **Strategy Management**: Centralized authentication strategy switching and cleanup
136
+ * **Session Context Tracking**: Per-request security state management
137
+
138
+ * **Enhanced Error Handling**: Security-aware error processing throughout the stack
139
+ * Proper MCP error codes for authentication and authorization failures
140
+ * Secure error messages that don't leak sensitive information
141
+ * Graceful degradation with detailed logging for debugging
142
+
143
+ ### Security
144
+
145
+ * **Defense in Depth**: Multiple security layers following enterprise security principles
146
+ * **Authentication Layer**: Verify user identity before granting access
147
+ * **Authorization Layer**: Fine-grained permission checking for all resources
148
+ * **Transport Security**: Secure communication across all transport mechanisms
149
+ * **Input Validation**: Continued protection against injection attacks via existing schema validation
150
+
151
+ * **Secure Defaults**: Security-first configuration options
152
+ * Authentication disabled by default (explicit opt-in required)
153
+ * Authorization uses allowlist approach (deny by default, explicit permissions required)
154
+ * Secure error handling without information disclosure
155
+ * Automatic session isolation and cleanup
156
+
157
+ * **Enterprise Security Features**: Production-ready security controls
158
+ * **Session Management**: Secure user session tracking with authentication state
159
+ * **Permission Framework**: Flexible role-based and resource-based access control
160
+ * **Error Recovery**: Graceful handling of authentication failures, timeouts, and edge cases
161
+ * **Audit Trail**: Comprehensive logging of authentication and authorization events
162
+
163
+ ### Testing
164
+
165
+ * **Comprehensive Security Test Suite**: 68+ tests covering all security scenarios
166
+ * **Authentication Strategy Tests**: Complete coverage of API key, JWT, and custom authentication
167
+ * **Authorization Policy Tests**: Fine-grained permission testing with edge cases
168
+ * **Transport Security Integration**: End-to-end security testing across stdio and SSE transports
169
+ * **Error Handling Tests**: Security failure scenarios and attack vector validation
170
+ * **Concurrency Tests**: Thread safety and concurrent access security validation
171
+ * **Performance Tests**: Memory management and resource cleanup under load
172
+
173
+ ### Technical Details
174
+
175
+ * **Dependencies**: Optional JWT gem support for JWT authentication strategy
176
+ * **API Compatibility**: All security features maintain full backward compatibility
177
+ * **Performance**: Minimal overhead when security is disabled, efficient processing when enabled
178
+ * **Documentation**: Extensive security documentation with real-world examples and best practices
179
+
180
+ ## [0.3.0] – 2025-06-20
181
+
182
+ ### Added
183
+ * **Comprehensive Input Schema Validation**: Two-layer validation system for enhanced security and developer experience
184
+ - **Schema Validation**: Validates JSON Schema format during tool registration using `json-schema` gem
185
+ - **Input Validation**: Validates user arguments against defined schemas during tool execution
186
+ - Automatic validation for all tools with `input_schema` defined
187
+ - Detailed error messages with specific validation failure details
188
+ - Full backward compatibility - tools without schemas continue working unchanged
189
+ - New `validate_schema_format!` method for registration-time validation
190
+ - Renamed `validate_tool_arguments!` to `validate_input_arguments!` for clarity
191
+
192
+ * **Enhanced Documentation and Examples**
193
+ - Comprehensive README section on automatic input validation with security benefits
194
+ - New `examples/validation_demo.rb` showcasing both validation types
195
+ - Complete `examples/README.md` with descriptions of all example files
196
+ - Updated documentation emphasizing security best practices
197
+
198
+ ### Changed
199
+ * **Method Naming Improvements**: Clarified validation method names
200
+ - `validate_tool_arguments!` → `validate_input_arguments!` (runtime validation)
201
+ - Added `validate_schema_format!` (registration-time validation)
202
+
203
+ ### Security
204
+ * **Injection Attack Prevention**: Centralized validation prevents malformed input from reaching tool handlers
205
+ * **Type Safety**: Ensures all arguments match expected JSON Schema types and constraints
206
+ * **Early Error Detection**: Invalid schemas caught during development, not runtime
207
+
208
+ * **SSE Transport Implementation**: Complete HTTP/Server-Sent Events transport
209
+ - New `VectorMCP::Transport::SSE` class with HTTP server capabilities
210
+ - Puma-based HTTP server with concurrent request handling
211
+ - Bi-directional communication: SSE for server-to-client, HTTP POST for client-to-server
212
+ - Session management with unique session IDs and connection tracking
213
+ - Support for web browsers and HTTP-based MCP clients
214
+ - Configurable host, port, and path prefix options
215
+
216
+ ## [0.3.0] – 2025-06-20
217
+
218
+ ### Added
219
+
220
+ * **Comprehensive Input Schema Validation**: Two-layer validation system for enhanced security and developer experience
221
+ * **Schema Validation**: Validates JSON Schema format during tool registration using `json-schema` gem
222
+ * **Input Validation**: Validates user arguments against defined schemas during tool execution
223
+ * Automatic validation for all tools with `input_schema` defined
224
+ * Detailed error messages with specific validation failure details
225
+ * Full backward compatibility - tools without schemas continue working unchanged
226
+ * New `validate_schema_format!` method for registration-time validation
227
+ * Renamed `validate_tool_arguments!` to `validate_input_arguments!` for clarity
228
+
229
+ * **Enhanced Documentation and Examples**
230
+ * Comprehensive README section on automatic input validation with security benefits
231
+ * New `examples/validation_demo.rb` showcasing both validation types
232
+ * Complete `examples/README.md` with descriptions of all example files
233
+ * Updated documentation emphasizing security best practices
234
+
235
+ ### Changed
236
+
237
+ * **Method Naming Improvements**: Clarified validation method names
238
+ * `validate_tool_arguments!` → `validate_input_arguments!` (runtime validation)
239
+ * Added `validate_schema_format!` (registration-time validation)
240
+
241
+ ### Security
242
+
243
+ * **Injection Attack Prevention**: Centralized validation prevents malformed input from reaching tool handlers
244
+ * **Type Safety**: Ensures all arguments match expected JSON Schema types and constraints
245
+ * **Early Error Detection**: Invalid schemas caught during development, not runtime
246
+
247
+ * **SSE Transport Implementation**: Complete HTTP/Server-Sent Events transport
248
+ * New `VectorMCP::Transport::SSE` class with HTTP server capabilities
249
+ * Puma-based HTTP server with concurrent request handling
250
+ * Bi-directional communication: SSE for server-to-client, HTTP POST for client-to-server
251
+ * Session management with unique session IDs and connection tracking
252
+ * Support for web browsers and HTTP-based MCP clients
253
+ * Configurable host, port, and path prefix options
254
+
255
+ ## [0.2.0] – 2025-05-26
256
+
257
+ ### Added
258
+
259
+ * **MCP Sampling Support**: Full implementation of Model Context Protocol sampling capabilities
260
+ * New `VectorMCP::Sampling::Request` and `VectorMCP::Sampling::Result` classes
261
+ * Session-based sampling with `Session#sample` method
262
+ * Configurable sampling capabilities (methods, features, limits, context inclusion)
263
+ * Support for streaming, tool calls, images, and model preferences
264
+ * Timeout and error handling for sampling requests
265
+
266
+ * **Image Processing Utilities**: Comprehensive image handling capabilities
267
+ * New `VectorMCP::ImageUtil` module with format detection, validation, and conversion
268
+ * Support for JPEG, PNG, GIF, WebP, BMP, and TIFF formats
269
+ * Base64 encoding/decoding with validation
270
+ * Image metadata extraction (dimensions, format, size)
271
+ * MCP-compliant image content generation
272
+ * File-based and binary data image processing
273
+
274
+ * **Enhanced Definitions**: Extended tool, resource, and prompt definitions
275
+ * Image support detection for tools (`Tool#supports_image_input?`)
276
+ * Image resource creation (`Resource.from_image_file`, `Resource.from_image_data`)
277
+ * Image-aware prompts (`Prompt#supports_image_arguments?`, `Prompt.with_image_support`)
278
+ * Enhanced validation and MCP definition generation
279
+
280
+ * **Roots Support**: New MCP roots functionality
281
+ * `VectorMCP::Definitions::Root` class for filesystem root definitions
282
+ * Root registration and validation (`Server#register_root`, `Server#register_root_from_path`)
283
+ * Automatic path validation and security checks
284
+ * List change notifications for roots
285
+
286
+ * **Enhanced Content Utilities**: Improved content processing in `VectorMCP::Util`
287
+ * Automatic image file path detection and processing
288
+ * Binary image data detection and conversion
289
+ * Mixed content array processing with image support
290
+ * Enhanced JSON-RPC ID extraction from malformed messages
291
+
292
+ ### Changed
293
+
294
+ * **Server Architecture Refactoring**: Major code organization improvements
295
+ * Extracted server functionality into focused modules:
296
+ * `VectorMCP::Server::Registry` for tool/resource/prompt management
297
+ * `VectorMCP::Server::Capabilities` for capability negotiation
298
+ * `VectorMCP::Server::MessageHandling` for request/notification processing
299
+ * Reduced main `Server` class from 392 to 159 lines
300
+ * Improved separation of concerns and maintainability
301
+
302
+ * **Enhanced Session Management**: Improved session initialization and state handling
303
+ * Better session lifecycle management
304
+ * Enhanced sampling capabilities integration
305
+ * Improved error handling for uninitialized sessions
306
+
307
+ * **Transport Layer Improvements**: Enhanced stdio transport reliability
308
+ * Better request/response correlation for server-initiated requests
309
+ * Improved error handling and timeout management
310
+ * Enhanced thread safety and resource cleanup
311
+ * Fixed session initialization race conditions
312
+
313
+ * **Error Handling Enhancements**: More robust error management
314
+ * Additional error types for sampling operations
315
+ * Better error context and details
316
+ * Improved protocol error handling
317
+
318
+ ### Fixed
319
+
320
+ * **Code Quality Improvements**: Resolved all Ruby linting violations
321
+ * Fixed method length violations through strategic refactoring
322
+ * Resolved perceived complexity issues by extracting helper methods
323
+ * Eliminated duplicate attribute declarations
324
+ * Fixed parameter list length violations
325
+ * Corrected naming convention violations
326
+ * Removed unused variable assignments
327
+
328
+ * **Session Initialization**: Fixed double initialization bug in stdio transport
329
+ * Resolved race condition causing "Session already initialized" errors
330
+ * Improved session state management across transport layer
331
+ * Fixed integration test failures related to session handling
332
+
333
+ * **Test Suite Stability**: Enhanced test reliability and coverage
334
+ * Fixed integration test failures
335
+ * Improved test isolation and cleanup
336
+ * Enhanced error scenario testing
337
+ * Added comprehensive image processing tests
338
+
339
+ ### Technical Details
340
+
341
+ * **Dependencies**: Added `base64` gem requirement for image processing
342
+ * **API Compatibility**: All changes maintain backward compatibility with existing MCP clients
343
+ * **Performance**: Improved memory usage through better resource management
344
+ * **Security**: Enhanced path validation and traversal protection for roots
345
+ * **Documentation**: Updated README with new features and examples
346
+
347
+ ## [0.1.0] – 2025-05-08
348
+ ### Added
349
+ * First public release: stdio transport, tool/resource registration, JSON-RPC layer…