vector_mcp 0.3.4 → 0.5.0

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.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +82 -0
  3. data/README.md +147 -337
  4. data/lib/vector_mcp/definitions.rb +30 -0
  5. data/lib/vector_mcp/handlers/core.rb +78 -81
  6. data/lib/vector_mcp/image_util.rb +34 -11
  7. data/lib/vector_mcp/middleware/anonymizer.rb +186 -0
  8. data/lib/vector_mcp/middleware/base.rb +1 -5
  9. data/lib/vector_mcp/middleware/context.rb +11 -1
  10. data/lib/vector_mcp/middleware/hook.rb +7 -24
  11. data/lib/vector_mcp/middleware.rb +26 -9
  12. data/lib/vector_mcp/rails/tool.rb +85 -0
  13. data/lib/vector_mcp/request_context.rb +1 -1
  14. data/lib/vector_mcp/security/auth_manager.rb +12 -13
  15. data/lib/vector_mcp/security/auth_result.rb +33 -0
  16. data/lib/vector_mcp/security/authorization.rb +5 -9
  17. data/lib/vector_mcp/security/middleware.rb +2 -2
  18. data/lib/vector_mcp/security/session_context.rb +11 -27
  19. data/lib/vector_mcp/security/strategies/api_key.rb +1 -5
  20. data/lib/vector_mcp/security/strategies/custom.rb +10 -37
  21. data/lib/vector_mcp/security/strategies/jwt_token.rb +1 -10
  22. data/lib/vector_mcp/server/capabilities.rb +22 -32
  23. data/lib/vector_mcp/server/message_handling.rb +21 -14
  24. data/lib/vector_mcp/server/registry.rb +102 -120
  25. data/lib/vector_mcp/server.rb +98 -57
  26. data/lib/vector_mcp/session.rb +5 -3
  27. data/lib/vector_mcp/token_store.rb +80 -0
  28. data/lib/vector_mcp/tool.rb +221 -0
  29. data/lib/vector_mcp/transport/base_session_manager.rb +1 -17
  30. data/lib/vector_mcp/transport/http_stream/event_store.rb +29 -17
  31. data/lib/vector_mcp/transport/http_stream/session_manager.rb +41 -36
  32. data/lib/vector_mcp/transport/http_stream/stream_handler.rb +132 -47
  33. data/lib/vector_mcp/transport/http_stream.rb +242 -124
  34. data/lib/vector_mcp/util/token_sweeper.rb +74 -0
  35. data/lib/vector_mcp/version.rb +1 -1
  36. data/lib/vector_mcp.rb +8 -8
  37. metadata +8 -10
  38. data/lib/vector_mcp/transport/sse/client_connection.rb +0 -113
  39. data/lib/vector_mcp/transport/sse/message_handler.rb +0 -166
  40. data/lib/vector_mcp/transport/sse/puma_config.rb +0 -77
  41. data/lib/vector_mcp/transport/sse/stream_manager.rb +0 -92
  42. data/lib/vector_mcp/transport/sse.rb +0 -377
  43. data/lib/vector_mcp/transport/sse_session_manager.rb +0 -188
  44. data/lib/vector_mcp/transport/stdio.rb +0 -473
  45. data/lib/vector_mcp/transport/stdio_session_manager.rb +0 -181
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 96c22c8497dcfd618605017a41a11d747e596654d86e856551159303133e0ab9
4
- data.tar.gz: 301099d4a3b6b21c28ad82adf95c77f3469a0c4ba40dbd63f9f4f1060391b37f
3
+ metadata.gz: 8125dfaaa8d0965448eac78401a013a1f5e41292f29141a72c44fca6dbb96cba
4
+ data.tar.gz: cef6523bbd0c43e969102f5776f6bcb5f2e6a9e10507b4faee1839258fe7f39f
5
5
  SHA512:
6
- metadata.gz: 4d464e8ae1e4472eead1580582b2e39dcaadcc5da54087e3022386c05c2dafd0a45f80509a23653273d615a7f739e0cbd8de052acb6d816c1442819bb775b374
7
- data.tar.gz: 26818191d6c915a31562356b3dec35ada9a1e0bd42f662d37e5884ce05ba139bd54f4fe768d6a2b5106de21e97da2b5a3c9970797eb05082256761e82f276238
6
+ metadata.gz: 6dafbddbeeb279f3232ad45c979b94b92266b1c05060f057dd747bc51ad6cc290da9c30886c9d72cee0445554445cf78e963efd354481974b7b875a5c98e0d21
7
+ data.tar.gz: 68003e44e084dc40cef4ae04add212901c65056d5432a18aad00550fc8055537812693b915b1f6b00c7e409178ea0801d54f3c9fc3a350c3cca5c65f9afcf700
data/CHANGELOG.md CHANGED
@@ -1,3 +1,85 @@
1
+ ## [0.5.0] – 2026-04-22
2
+
3
+ ### Added
4
+
5
+ * **Token-Based Field Anonymization**: Added a general-purpose anonymization pipeline that substitutes sensitive string fields with stable opaque tokens before tool results reach the LLM and restores them on inbound tool invocations.
6
+ - `VectorMCP::TokenStore` — thread-safe bidirectional value ↔ token store with idempotent tokenization.
7
+ - `VectorMCP::Util::TokenSweeper` — stateless recursive traversal utility for parsed JSON structures.
8
+ - `VectorMCP::Middleware::Anonymizer` — middleware wiring the store and sweeper with application-supplied field rules and optional atomic-key handling; registers via `anonymizer.install_on(server)`.
9
+
10
+ * **OAuth 2.1 Resource Server mode (HTTP Stream transport)**: `enable_authentication!` now accepts a `resource_metadata_url:` option. When set, unauthenticated requests to `/mcp` return HTTP `401` with a `WWW-Authenticate: Bearer realm="mcp", resource_metadata="<url>"` header (RFC 9728), enabling MCP clients such as Claude Desktop to discover the authorization server and initiate OAuth 2.1 + PKCE flows. Opt-in: when `resource_metadata_url` is not set, the existing JSON-RPC `-32401` behavior is unchanged. See [docs/oauth_resource_server.md](docs/oauth_resource_server.md) and [docs/rails_oauth_integration.md](docs/rails_oauth_integration.md) for end-to-end guidance.
11
+
12
+ ### Changed
13
+
14
+ * **Auth Result Value Object**: Replaced the internal authentication result hashes with a dedicated `AuthResult` value object for clearer, type-safe handoff between auth strategies and the security middleware.
15
+ * **Consolidated Middleware Hook Types**: `HOOK_TYPES` and `HOOK_OPERATION_TYPES` are now derived from a single source of truth, eliminating drift between the two lists.
16
+ * **Puma Thread Pool Tuning**: Standalone HTTP stream transport now configures the Puma thread pool explicitly for more predictable concurrency behavior.
17
+ * **Event Store Offset Tracking**: Replaced the O(n) event store index rebuild with O(1) offset tracking, reducing overhead for sessions with long event histories.
18
+ * **HTTP Stream Request Tracking**: Removed the redundant `@request_mutex` from HTTP stream request tracking and simplified the surrounding locking.
19
+ * **Handlers::Core Cleanup**: Renamed misleading identifiers and removed dead legacy branches in `Handlers::Core`.
20
+ * **General Complexity Reduction**: Reduced accidental complexity across six refactoring targets in the core request path.
21
+
22
+ ### Fixed
23
+
24
+ * **TokenStore Read-After-Write Consistency**: Closed a read-after-write consistency hole in `TokenStore` so concurrent tokenization and resolution no longer race.
25
+
26
+ ## [0.4.0] – 2026-04-10
27
+
28
+ ### Added
29
+
30
+ * **Declarative Tool DSL**: Added `VectorMCP::Tool` for class-based tool definitions.
31
+ - Define tools with `tool_name`, `description`, and `param`
32
+ - Register one or more tool classes with `server.register(MyTool, OtherTool)`
33
+ - Added `:date` and `:datetime` param types with automatic coercion to `Date` and `Time`
34
+
35
+ * **Rack and Rails Integration**: Added first-class mounting support for Rack-based applications.
36
+ - `Server#rack_app` returns a Rack-compatible MCP endpoint without starting Puma
37
+ - Added `VectorMCP::Rails::Tool` for ActiveRecord-backed tools
38
+ - Added `docs/rails-setup-guide.md` with a full Rails integration guide
39
+
40
+ * **Expanded Middleware Lifecycle Hooks**: Middleware can now observe and shape more of the request lifecycle.
41
+ - Added `before_auth`, `after_auth`, and `on_auth_error` hooks
42
+ - Added transport-level `before_request`, `after_response`, and `on_transport_error` hooks
43
+ - Middleware can now mutate params before handlers execute
44
+
45
+ ### Changed
46
+
47
+ * **MCP Protocol Version**: VectorMCP now advertises MCP protocol `2025-11-25` by default.
48
+ - `MCP-Protocol-Version` headers for `2025-11-25`, `2025-03-26`, and `2024-11-05` are accepted for compatibility
49
+
50
+ * **Streamable HTTP Compliance**: HttpStream was updated to align with the MCP 2025-11-25 transport requirements.
51
+ - POST bodies must contain a single JSON-RPC request, notification, or response
52
+ - POST `Accept` validation now enforces `application/json` plus `text/event-stream` when the header is present
53
+ - Notifications now return `202 Accepted`
54
+ - SSE streams now send priming events, retry hints, and comment-based heartbeats
55
+ - Event replay and outbound routing are now scoped to the originating stream
56
+
57
+ * **Ruby Requirement**: Minimum supported Ruby version is now `3.2`.
58
+
59
+ ### Removed
60
+
61
+ * **Stdio Transport**: Removed stdio transport support entirely.
62
+ - Deleted `lib/vector_mcp/transport/stdio.rb` and `lib/vector_mcp/transport/stdio_session_manager.rb`
63
+ - `Server#run` now defaults to `transport: :http_stream`
64
+
65
+ * **Standalone SSE Transport**: Removed the legacy SSE transport implementation.
66
+ - Deleted `lib/vector_mcp/transport/sse.rb`, `lib/vector_mcp/transport/sse_session_manager.rb`, and `lib/vector_mcp/transport/sse/`
67
+ - HttpStream is now the only built-in transport
68
+
69
+ * **Broadcast APIs**: Removed `broadcast_message` and `broadcast_notification` to comply with the no-broadcast delivery rules in the MCP streamable HTTP specification.
70
+
71
+ ### Security
72
+
73
+ * **Safer Origin Defaults**: Default allowed origins are now restricted to localhost and loopback addresses.
74
+ - Explicit wildcard origin configuration still works, but now emits a security warning
75
+
76
+ * **Stronger Path Validation**: `ImageUtil` now canonicalizes file paths and blocks traversal attempts even when no `base_directory` is provided.
77
+
78
+ ### Fixed
79
+
80
+ * **Stream Routing and Replay**: Multiple active SSE streams in the same session now replay and deliver messages to the correct logical stream.
81
+ * **Authorization Context Propagation**: Resolved security context is now stored on the session so middleware and handlers can inspect authenticated state consistently.
82
+
1
83
  ## [0.3.4] – 2026-03-17
2
84
 
3
85
  ### Added