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 +4 -4
- data/app/controllers/action_mcp/application_controller.rb +22 -8
- data/lib/action_mcp/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b2ba13241313978eedd0619b256d320728391aa9afaa899b6299e65e54867358
|
4
|
+
data.tar.gz: 6bfc9173a29184139f7b9f0ceb543a56da3a557d3c633abae09e8bdc4c8465ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
39
|
-
|
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
|
145
|
-
return render_not_acceptable(
|
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?
|
data/lib/action_mcp/version.rb
CHANGED