actionmcp 0.50.3 → 0.50.4

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: 7c5d576f3bc8c02f3682c056b8145b9af5ad85ad581a131b4bb7dccdd14b0531
4
- data.tar.gz: 8233276b69f4033c8b62a015f3960ef8503f16344f3be0c17106441994146d9d
3
+ metadata.gz: b2ba13241313978eedd0619b256d320728391aa9afaa899b6299e65e54867358
4
+ data.tar.gz: 6bfc9173a29184139f7b9f0ceb543a56da3a557d3c633abae09e8bdc4c8465ee
5
5
  SHA512:
6
- metadata.gz: 5c20d55384bd4b62831f6613c0aecd1e32ffdd4fe2918f315b512fd43ec7065c9ecd8c3a5d62a5c578c868a6c3de8a4989ae54dd9563d58c0b9570affad1833b
7
- data.tar.gz: da098c411863f6f033ed88aa31cf8745548bd32ec7b9074c9db789e46c065bdf3243e4a596a05459626c484c7a44a3913f6591e90e15c90d7eea51d3609e5482
6
+ metadata.gz: 77740b75ca3ec92fdb1eff6ecbfe1020113093899652b5cee0a56fbfbbe0c40c93e26f82803df732f33464e5cf532018901118cc6092d3e204001c490966b36f
7
+ data.tar.gz: c4ddcadeac684c84116e7f6fe04dff67b6f9749425bd4d5901471affacc2bfb1bb644e6a3d955718bd0ae6a788af0fd7981df621a2f15f4e372510b809190710
@@ -30,15 +30,11 @@ module ActionMCP
30
30
  @session_key ||= "action_mcp-sessions-#{mcp_session.id}"
31
31
  end
32
32
 
33
- # --- MCP UnifiedController actions ---
34
-
35
33
  # Handles GET requests for establishing server-initiated SSE streams (2025-03-26 spec).
36
34
  # @route GET /
37
35
  def show
38
- if ActionMCP.configuration.post_response_preference == :sse
39
- unless request.accepts.any? { |type| type.to_s == "text/event-stream" }
40
- return render_not_acceptable("Client must accept 'text/event-stream' for GET requests.")
41
- end
36
+ unless request.accepts.any? { |type| type.to_s == "text/event-stream" }
37
+ return render_not_acceptable("Client must accept 'text/event-stream' for GET requests.")
42
38
  end
43
39
 
44
40
  session_id_from_header = extract_session_id
@@ -141,8 +137,8 @@ module ActionMCP
141
137
  # Handles POST requests containing client JSON-RPC messages according to 2025-03-26 spec.
142
138
  # @route POST /mcp
143
139
  def create
144
- unless accepts_valid_content_types?
145
- return render_not_acceptable("Client must accept 'application/json' and 'text/event-stream'")
140
+ unless post_accept_headers_valid?
141
+ return render_not_acceptable(post_accept_headers_error_message)
146
142
  end
147
143
 
148
144
  is_initialize_request = check_if_initialize_request(jsonrpc_params)
@@ -231,6 +227,24 @@ module ActionMCP
231
227
  request.accepts.any? { |type| type.to_s == "text/event-stream" }
232
228
  end
233
229
 
230
+ # Checks if the Accept headers for POST are valid according to server preference.
231
+ def post_accept_headers_valid?
232
+ if ActionMCP.configuration.post_response_preference == :sse
233
+ accepts_valid_content_types?
234
+ else
235
+ request.accepts.any? { |type| type.to_s == "application/json" }
236
+ end
237
+ end
238
+
239
+ # Returns the appropriate error message for POST Accept header validation.
240
+ def post_accept_headers_error_message
241
+ if ActionMCP.configuration.post_response_preference == :sse
242
+ "Client must accept 'application/json' and 'text/event-stream'"
243
+ else
244
+ "Client must accept 'application/json'"
245
+ end
246
+ end
247
+
234
248
  # Checks if the parsed body represents an 'initialize' request.
235
249
  def check_if_initialize_request(payload)
236
250
  return false unless payload.is_a?(JSON_RPC::Request) && !jsonrpc_params_batch?
@@ -2,7 +2,7 @@
2
2
 
3
3
  require_relative "gem_version"
4
4
  module ActionMCP
5
- VERSION = "0.50.3"
5
+ VERSION = "0.50.4"
6
6
 
7
7
  class << self
8
8
  alias version gem_version
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: actionmcp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.50.3
4
+ version: 0.50.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Abdelkader Boudih