actionmcp 0.200.0 → 0.200.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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7dac4b9579940d54637f45cb616df8e38aab4ea042a259c86da2ecc469f56a10
|
|
4
|
+
data.tar.gz: 1192d89e7a2e058e61ba666062bebde24477b17d0a8b72a4ccbf59d49baad166
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f84277e60ce16d683d82401db10537ebf01d37e9d7d2cba25b423fdeac1a3b2d251e9226ec83f18fea1df00efaa560bfbb3626466415a24900aacadb650c221a
|
|
7
|
+
data.tar.gz: 71ee7caf64872c3a05ae25cb70c07af01f86a433f43206a139d48d86199d2dc0fec297efd73f65818aa66a114a76544dcdd3e9f3f0ff3eeb5929e6bc1a1d1e6a
|
|
@@ -69,8 +69,8 @@ module ActionMCP
|
|
|
69
69
|
# Convert string payloads to JSON
|
|
70
70
|
if payload.is_a?(String)
|
|
71
71
|
begin
|
|
72
|
-
@data =
|
|
73
|
-
rescue
|
|
72
|
+
@data = MultiJSON.parse(payload)
|
|
73
|
+
rescue MultiJSON::ParseError
|
|
74
74
|
# Handle invalid JSON by creating an error object
|
|
75
75
|
self.message_json = { "error" => "Invalid JSON", "raw" => payload }
|
|
76
76
|
self.message_type = "invalid_json"
|
|
@@ -27,7 +27,6 @@
|
|
|
27
27
|
#
|
|
28
28
|
# [callbacks]
|
|
29
29
|
# before_create = [{ method = "initialize_registries" }, { method = "set_server_info", if = ["proc"] }, { method = "set_server_capabilities", if = ["proc"] }]
|
|
30
|
-
# after_initialize = [{ method = "proc" }]
|
|
31
30
|
#
|
|
32
31
|
# notes = ["messages:N_PLUS_ONE", "subscriptions:N_PLUS_ONE", "tasks:N_PLUS_ONE", "client_capabilities:NOT_NULL", "client_info:NOT_NULL", "prompt_registry:NOT_NULL", "protocol_version:NOT_NULL", "resource_registry:NOT_NULL", "server_capabilities:NOT_NULL", "server_info:NOT_NULL", "tool_registry:NOT_NULL", "id:LIMIT", "protocol_version:LIMIT", "role:LIMIT", "status:LIMIT", "status:INDEX"]
|
|
33
32
|
# <rails-lens:schema:end>
|
|
@@ -38,10 +37,6 @@ module ActionMCP
|
|
|
38
37
|
# such as client and server capabilities, protocol version, and session status.
|
|
39
38
|
# It also manages the association with messages and subscriptions related to the session.
|
|
40
39
|
class Session < ApplicationRecord
|
|
41
|
-
after_initialize do
|
|
42
|
-
self.consents = {} if consents == "{}" || consents.nil?
|
|
43
|
-
end
|
|
44
|
-
|
|
45
40
|
include MCPConsoleHelpers
|
|
46
41
|
attribute :id, :string, default: -> { SecureRandom.hex(16) }
|
|
47
42
|
has_many :messages,
|
|
@@ -89,7 +84,7 @@ module ActionMCP
|
|
|
89
84
|
if data.is_a?(JSON_RPC::Request) || data.is_a?(JSON_RPC::Response) || data.is_a?(JSON_RPC::Notification)
|
|
90
85
|
data = data.to_json
|
|
91
86
|
end
|
|
92
|
-
data =
|
|
87
|
+
data = MultiJSON.generate(data) if data.is_a?(Hash)
|
|
93
88
|
|
|
94
89
|
messages.create!(data: data, direction: writer_role)
|
|
95
90
|
end
|
|
@@ -363,33 +358,34 @@ module ActionMCP
|
|
|
363
358
|
# Consent management methods as per MCP specification
|
|
364
359
|
# These methods manage user consents for tools and resources
|
|
365
360
|
|
|
361
|
+
def consents
|
|
362
|
+
value = super
|
|
363
|
+
return {} if value.nil? || value == ""
|
|
364
|
+
|
|
365
|
+
value.is_a?(String) ? JSON.parse(value) : value
|
|
366
|
+
end
|
|
367
|
+
|
|
366
368
|
# Checks if consent has been granted for a specific key
|
|
367
369
|
# @param key [String] The consent key (e.g., tool name or resource URI)
|
|
368
370
|
# @return [Boolean] true if consent is granted, false otherwise
|
|
369
371
|
def consent_granted_for?(key)
|
|
370
|
-
|
|
371
|
-
consents_hash&.key?(key) && consents_hash[key] == true
|
|
372
|
+
consents[key] == true
|
|
372
373
|
end
|
|
373
374
|
|
|
374
375
|
# Grants consent for a specific key
|
|
375
376
|
# @param key [String] The consent key to grant
|
|
376
377
|
# @return [Boolean] true if saved successfully
|
|
377
378
|
def grant_consent(key)
|
|
378
|
-
|
|
379
|
-
self.consents ||= {}
|
|
380
|
-
self.consents[key] = true
|
|
381
|
-
save!
|
|
379
|
+
update!(consents: consents.merge(key => true))
|
|
382
380
|
end
|
|
383
381
|
|
|
384
382
|
# Revokes consent for a specific key
|
|
385
383
|
# @param key [String] The consent key to revoke
|
|
386
384
|
# @return [void]
|
|
387
385
|
def revoke_consent(key)
|
|
388
|
-
|
|
389
|
-
return unless consents&.key?(key)
|
|
386
|
+
return unless consents.key?(key)
|
|
390
387
|
|
|
391
|
-
consents.
|
|
392
|
-
save!
|
|
388
|
+
update!(consents: consents.except(key))
|
|
393
389
|
end
|
|
394
390
|
|
|
395
391
|
private
|
data/lib/action_mcp/content.rb
CHANGED
data/lib/action_mcp/resource.rb
CHANGED
|
@@ -24,7 +24,7 @@ module ActionMCP
|
|
|
24
24
|
pretty = json_normalise(line)
|
|
25
25
|
log_with_tags("MCP", "RX") { ActionMCP.logger.debug("#{GREEN_RX}#{pretty}#{CLR}") }
|
|
26
26
|
super
|
|
27
|
-
rescue
|
|
27
|
+
rescue MultiJSON::ParseError => e
|
|
28
28
|
log_with_tags("MCP", "RX") { ActionMCP.logger.warn("#{YELLOW_ERR}Bad JSON → #{e.message}#{CLR}") }
|
|
29
29
|
raise
|
|
30
30
|
rescue StandardError => e
|
|
@@ -57,7 +57,7 @@ module ActionMCP
|
|
|
57
57
|
|
|
58
58
|
# Accepts String, Hash, or any #to_json‑able object.
|
|
59
59
|
def json_normalise(obj)
|
|
60
|
-
str = obj.is_a?(String) ? obj.strip :
|
|
60
|
+
str = obj.is_a?(String) ? obj.strip : MultiJSON.generate(obj)
|
|
61
61
|
str.empty? ? "<empty frame>" : str
|
|
62
62
|
end
|
|
63
63
|
end
|
data/lib/action_mcp/version.rb
CHANGED
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.200.
|
|
4
|
+
version: 0.200.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Abdelkader Boudih
|
|
@@ -99,14 +99,14 @@ dependencies:
|
|
|
99
99
|
requirements:
|
|
100
100
|
- - ">="
|
|
101
101
|
- !ruby/object:Gem::Version
|
|
102
|
-
version: '
|
|
102
|
+
version: '1.21'
|
|
103
103
|
type: :runtime
|
|
104
104
|
prerelease: false
|
|
105
105
|
version_requirements: !ruby/object:Gem::Requirement
|
|
106
106
|
requirements:
|
|
107
107
|
- - ">="
|
|
108
108
|
- !ruby/object:Gem::Version
|
|
109
|
-
version: '
|
|
109
|
+
version: '1.21'
|
|
110
110
|
- !ruby/object:Gem::Dependency
|
|
111
111
|
name: railties
|
|
112
112
|
requirement: !ruby/object:Gem::Requirement
|