actionmcp 0.14.0 → 0.16.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.
- checksums.yaml +4 -4
- data/README.md +152 -148
- data/Rakefile +1 -1
- data/app/controllers/action_mcp/{application_controller.rb → mcp_controller.rb} +3 -1
- data/app/controllers/action_mcp/messages_controller.rb +7 -5
- data/app/controllers/action_mcp/sse_controller.rb +19 -13
- data/app/models/action_mcp/session/message.rb +95 -90
- data/app/models/action_mcp/session/resource.rb +10 -6
- data/app/models/action_mcp/session/subscription.rb +9 -5
- data/app/models/action_mcp/session.rb +22 -13
- data/app/models/action_mcp.rb +2 -0
- data/config/routes.rb +2 -0
- data/db/migrate/20250308122801_create_action_mcp_sessions.rb +12 -10
- data/db/migrate/20250314230152_add_is_ping_to_session_message.rb +2 -0
- data/db/migrate/20250316005021_create_action_mcp_session_subscriptions.rb +3 -1
- data/db/migrate/20250316005649_create_action_mcp_session_resources.rb +4 -2
- data/exe/actionmcp_cli +57 -55
- data/lib/action_mcp/base_json_rpc_handler.rb +97 -0
- data/lib/action_mcp/callbacks.rb +122 -0
- data/lib/action_mcp/capability.rb +6 -3
- data/lib/action_mcp/client.rb +20 -26
- data/lib/action_mcp/client_json_rpc_handler.rb +69 -0
- data/lib/action_mcp/configuration.rb +8 -8
- data/lib/action_mcp/gem_version.rb +2 -0
- data/lib/action_mcp/instrumentation/controller_runtime.rb +38 -0
- data/lib/action_mcp/instrumentation/instrumentation.rb +26 -0
- data/lib/action_mcp/instrumentation/log_subscriber.rb +39 -0
- data/lib/action_mcp/instrumentation/resource_instrumentation.rb +40 -0
- data/lib/action_mcp/json_rpc/response.rb +18 -2
- data/lib/action_mcp/json_rpc_handler.rb +93 -21
- data/lib/action_mcp/log_subscriber.rb +28 -0
- data/lib/action_mcp/logging.rb +1 -3
- data/lib/action_mcp/prompt.rb +15 -6
- data/lib/action_mcp/prompt_response.rb +1 -1
- data/lib/action_mcp/prompts_registry.rb +1 -0
- data/lib/action_mcp/registry_base.rb +1 -0
- data/lib/action_mcp/resource_callbacks.rb +156 -0
- data/lib/action_mcp/resource_template.rb +18 -19
- data/lib/action_mcp/resource_templates_registry.rb +19 -25
- data/lib/action_mcp/sampling_request.rb +113 -0
- data/lib/action_mcp/server.rb +4 -1
- data/lib/action_mcp/server_json_rpc_handler.rb +90 -0
- data/lib/action_mcp/test_helper.rb +6 -2
- data/lib/action_mcp/tool.rb +12 -3
- data/lib/action_mcp/tool_response.rb +3 -2
- data/lib/action_mcp/transport/capabilities.rb +5 -1
- data/lib/action_mcp/transport/messaging.rb +2 -0
- data/lib/action_mcp/transport/prompts.rb +2 -0
- data/lib/action_mcp/transport/resources.rb +23 -6
- data/lib/action_mcp/transport/roots.rb +11 -0
- data/lib/action_mcp/transport/sampling.rb +14 -0
- data/lib/action_mcp/transport/sse_client.rb +11 -15
- data/lib/action_mcp/transport/stdio_client.rb +12 -14
- data/lib/action_mcp/transport/tools.rb +2 -0
- data/lib/action_mcp/transport/transport_base.rb +16 -15
- data/lib/action_mcp/transport.rb +2 -0
- data/lib/action_mcp/transport_handler.rb +3 -0
- data/lib/action_mcp/version.rb +1 -1
- data/lib/action_mcp.rb +8 -2
- data/lib/generators/action_mcp/install/install_generator.rb +4 -1
- data/lib/generators/action_mcp/install/templates/application_mcp_res_template.rb +2 -0
- data/lib/generators/action_mcp/resource_template/resource_template_generator.rb +2 -0
- data/lib/generators/action_mcp/resource_template/templates/resource_template.rb.erb +1 -1
- data/lib/tasks/action_mcp_tasks.rake +11 -6
- metadata +27 -14
data/lib/action_mcp.rb
CHANGED
@@ -9,6 +9,7 @@ require "active_record/railtie"
|
|
9
9
|
require "action_controller/railtie"
|
10
10
|
require "action_cable/engine"
|
11
11
|
require "action_mcp/configuration"
|
12
|
+
require "action_mcp/log_subscriber"
|
12
13
|
require "action_mcp/engine"
|
13
14
|
require "zeitwerk"
|
14
15
|
|
@@ -29,11 +30,12 @@ end.setup
|
|
29
30
|
|
30
31
|
module ActionMCP
|
31
32
|
require_relative "action_mcp/version"
|
32
|
-
|
33
|
-
PROTOCOL_VERSION =
|
33
|
+
include Logging
|
34
|
+
PROTOCOL_VERSION = "2024-11-05"
|
34
35
|
|
35
36
|
class << self
|
36
37
|
attr_accessor :server
|
38
|
+
|
37
39
|
# Returns the configuration instance.
|
38
40
|
#
|
39
41
|
# @return [Configuration] the configuration instance
|
@@ -83,3 +85,7 @@ module ActionMCP
|
|
83
85
|
ActiveModel::Type.register(:string_array, StringArray)
|
84
86
|
ActiveModel::Type.register(:integer_array, IntegerArray)
|
85
87
|
end
|
88
|
+
|
89
|
+
ActiveSupport.on_load(:action_mcp) do
|
90
|
+
self.logger = ::Rails.logger
|
91
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "rails/generators"
|
2
4
|
|
3
5
|
module ActionMcp
|
@@ -14,7 +16,8 @@ module ActionMcp
|
|
14
16
|
end
|
15
17
|
|
16
18
|
def create_mcp_resource_template_file
|
17
|
-
template "application_mcp_res_template.rb",
|
19
|
+
template "application_mcp_res_template.rb",
|
20
|
+
File.join("app/mcp/resource_templates", "application_mcp_res_template.rb")
|
18
21
|
end
|
19
22
|
end
|
20
23
|
end
|
@@ -8,7 +8,7 @@ class <%= class_name %> < ApplicationMCPResTemplate
|
|
8
8
|
description: "Product identifier",
|
9
9
|
required: true
|
10
10
|
|
11
|
-
def
|
11
|
+
def resolve
|
12
12
|
# Fetch the product from the database or api or whatever
|
13
13
|
# Ruby Magic here
|
14
14
|
if (product = Product.find_by(id: product_id))
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
namespace :action_mcp do
|
2
4
|
# bin/rails action_mcp:list_tools
|
3
5
|
desc "List all tools with their names and descriptions"
|
@@ -9,7 +11,8 @@ namespace :action_mcp do
|
|
9
11
|
puts "\e[34m---------------\e[0m" # Blue
|
10
12
|
ActionMCP::Tool.descendants.each do |tool|
|
11
13
|
next if tool.abstract?
|
12
|
-
|
14
|
+
|
15
|
+
puts "\e[34m#{tool.capability_name}:\e[0m #{tool.description}" # Blue name
|
13
16
|
end
|
14
17
|
puts "\n"
|
15
18
|
end
|
@@ -24,7 +27,8 @@ namespace :action_mcp do
|
|
24
27
|
puts "\e[32m-----------------\e[0m" # Red
|
25
28
|
ActionMCP::Prompt.descendants.each do |prompt|
|
26
29
|
next if prompt.abstract?
|
27
|
-
|
30
|
+
|
31
|
+
puts "\e[32m#{prompt.capability_name}:\e[0m #{prompt.description}" # Red name
|
28
32
|
end
|
29
33
|
puts "\n"
|
30
34
|
end
|
@@ -35,17 +39,18 @@ namespace :action_mcp do
|
|
35
39
|
# Ensure Rails eager loads all classes
|
36
40
|
Rails.application.eager_load!
|
37
41
|
|
38
|
-
puts "\e[33mACTION MCP RESOURCES\e[0m"
|
39
|
-
puts "\e[33m--------------------\e[0m"
|
42
|
+
puts "\e[33mACTION MCP RESOURCES\e[0m" # Yellow
|
43
|
+
puts "\e[33m--------------------\e[0m" # Yellow
|
40
44
|
ActionMCP::ResourceTemplate.descendants.each do |resource|
|
41
45
|
next if resource.abstract?
|
42
|
-
|
46
|
+
|
47
|
+
puts "\e[33m#{resource.capability_name}:\e[0m #{resource.description}" # Yellow name
|
43
48
|
end
|
44
49
|
puts "\n"
|
45
50
|
end
|
46
51
|
|
47
52
|
desc "List all tools and prompts with their names and descriptions"
|
48
|
-
task list: [
|
53
|
+
task list: %i[list_tools list_prompts list_resources] do
|
49
54
|
# This task lists all tools, prompts, and resources
|
50
55
|
end
|
51
56
|
end
|
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: actionmcp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.16.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Abdelkader Boudih
|
8
8
|
bindir: exe
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-03-
|
10
|
+
date: 2025-03-20 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
|
-
name:
|
13
|
+
name: actioncable
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
15
15
|
requirements:
|
16
16
|
- - ">="
|
@@ -38,19 +38,19 @@ dependencies:
|
|
38
38
|
- !ruby/object:Gem::Version
|
39
39
|
version: 8.0.1
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
|
-
name:
|
41
|
+
name: faraday
|
42
42
|
requirement: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
|
-
- - "
|
44
|
+
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version:
|
46
|
+
version: '2.0'
|
47
47
|
type: :runtime
|
48
48
|
prerelease: false
|
49
49
|
version_requirements: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
|
-
- - "
|
51
|
+
- - "~>"
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version:
|
53
|
+
version: '2.0'
|
54
54
|
- !ruby/object:Gem::Dependency
|
55
55
|
name: multi_json
|
56
56
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,19 +66,19 @@ dependencies:
|
|
66
66
|
- !ruby/object:Gem::Version
|
67
67
|
version: '0'
|
68
68
|
- !ruby/object:Gem::Dependency
|
69
|
-
name:
|
69
|
+
name: railties
|
70
70
|
requirement: !ruby/object:Gem::Requirement
|
71
71
|
requirements:
|
72
|
-
- - "
|
72
|
+
- - ">="
|
73
73
|
- !ruby/object:Gem::Version
|
74
|
-
version:
|
74
|
+
version: 8.0.1
|
75
75
|
type: :runtime
|
76
76
|
prerelease: false
|
77
77
|
version_requirements: !ruby/object:Gem::Requirement
|
78
78
|
requirements:
|
79
|
-
- - "
|
79
|
+
- - ">="
|
80
80
|
- !ruby/object:Gem::Version
|
81
|
-
version:
|
81
|
+
version: 8.0.1
|
82
82
|
- !ruby/object:Gem::Dependency
|
83
83
|
name: zeitwerk
|
84
84
|
requirement: !ruby/object:Gem::Requirement
|
@@ -105,7 +105,7 @@ files:
|
|
105
105
|
- MIT-LICENSE
|
106
106
|
- README.md
|
107
107
|
- Rakefile
|
108
|
-
- app/controllers/action_mcp/
|
108
|
+
- app/controllers/action_mcp/mcp_controller.rb
|
109
109
|
- app/controllers/action_mcp/messages_controller.rb
|
110
110
|
- app/controllers/action_mcp/sse_controller.rb
|
111
111
|
- app/models/action_mcp.rb
|
@@ -121,8 +121,11 @@ files:
|
|
121
121
|
- db/migrate/20250316005649_create_action_mcp_session_resources.rb
|
122
122
|
- exe/actionmcp_cli
|
123
123
|
- lib/action_mcp.rb
|
124
|
+
- lib/action_mcp/base_json_rpc_handler.rb
|
125
|
+
- lib/action_mcp/callbacks.rb
|
124
126
|
- lib/action_mcp/capability.rb
|
125
127
|
- lib/action_mcp/client.rb
|
128
|
+
- lib/action_mcp/client_json_rpc_handler.rb
|
126
129
|
- lib/action_mcp/configuration.rb
|
127
130
|
- lib/action_mcp/content.rb
|
128
131
|
- lib/action_mcp/content/audio.rb
|
@@ -131,6 +134,10 @@ files:
|
|
131
134
|
- lib/action_mcp/content/text.rb
|
132
135
|
- lib/action_mcp/engine.rb
|
133
136
|
- lib/action_mcp/gem_version.rb
|
137
|
+
- lib/action_mcp/instrumentation/controller_runtime.rb
|
138
|
+
- lib/action_mcp/instrumentation/instrumentation.rb
|
139
|
+
- lib/action_mcp/instrumentation/log_subscriber.rb
|
140
|
+
- lib/action_mcp/instrumentation/resource_instrumentation.rb
|
134
141
|
- lib/action_mcp/integer_array.rb
|
135
142
|
- lib/action_mcp/json_rpc.rb
|
136
143
|
- lib/action_mcp/json_rpc/json_rpc_error.rb
|
@@ -138,6 +145,7 @@ files:
|
|
138
145
|
- lib/action_mcp/json_rpc/request.rb
|
139
146
|
- lib/action_mcp/json_rpc/response.rb
|
140
147
|
- lib/action_mcp/json_rpc_handler.rb
|
148
|
+
- lib/action_mcp/log_subscriber.rb
|
141
149
|
- lib/action_mcp/logging.rb
|
142
150
|
- lib/action_mcp/prompt.rb
|
143
151
|
- lib/action_mcp/prompt_response.rb
|
@@ -145,9 +153,12 @@ files:
|
|
145
153
|
- lib/action_mcp/registry_base.rb
|
146
154
|
- lib/action_mcp/renderable.rb
|
147
155
|
- lib/action_mcp/resource.rb
|
156
|
+
- lib/action_mcp/resource_callbacks.rb
|
148
157
|
- lib/action_mcp/resource_template.rb
|
149
158
|
- lib/action_mcp/resource_templates_registry.rb
|
159
|
+
- lib/action_mcp/sampling_request.rb
|
150
160
|
- lib/action_mcp/server.rb
|
161
|
+
- lib/action_mcp/server_json_rpc_handler.rb
|
151
162
|
- lib/action_mcp/string_array.rb
|
152
163
|
- lib/action_mcp/test_helper.rb
|
153
164
|
- lib/action_mcp/tool.rb
|
@@ -159,6 +170,8 @@ files:
|
|
159
170
|
- lib/action_mcp/transport/notifications.rb
|
160
171
|
- lib/action_mcp/transport/prompts.rb
|
161
172
|
- lib/action_mcp/transport/resources.rb
|
173
|
+
- lib/action_mcp/transport/roots.rb
|
174
|
+
- lib/action_mcp/transport/sampling.rb
|
162
175
|
- lib/action_mcp/transport/sse_client.rb
|
163
176
|
- lib/action_mcp/transport/stdio_client.rb
|
164
177
|
- lib/action_mcp/transport/tools.rb
|