actionmcp 0.2.0 → 0.2.3
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 +133 -30
- data/Rakefile +0 -2
- data/exe/actionmcp_cli +221 -0
- data/lib/action_mcp/capability.rb +52 -0
- data/lib/action_mcp/client.rb +243 -1
- data/lib/action_mcp/configuration.rb +50 -1
- data/lib/action_mcp/content/audio.rb +9 -0
- data/lib/action_mcp/content/image.rb +9 -0
- data/lib/action_mcp/content/resource.rb +13 -0
- data/lib/action_mcp/content/text.rb +7 -0
- data/lib/action_mcp/content.rb +11 -6
- data/lib/action_mcp/engine.rb +34 -0
- data/lib/action_mcp/gem_version.rb +2 -2
- data/lib/action_mcp/integer_array.rb +6 -0
- data/lib/action_mcp/json_rpc/json_rpc_error.rb +21 -0
- data/lib/action_mcp/json_rpc/notification.rb +8 -0
- data/lib/action_mcp/json_rpc/request.rb +14 -0
- data/lib/action_mcp/json_rpc/response.rb +32 -1
- data/lib/action_mcp/json_rpc.rb +1 -6
- data/lib/action_mcp/json_rpc_handler.rb +106 -0
- data/lib/action_mcp/logging.rb +19 -0
- data/lib/action_mcp/prompt.rb +30 -46
- data/lib/action_mcp/prompts_registry.rb +13 -1
- data/lib/action_mcp/registry_base.rb +47 -28
- data/lib/action_mcp/renderable.rb +26 -0
- data/lib/action_mcp/resource.rb +3 -1
- data/lib/action_mcp/server.rb +4 -1
- data/lib/action_mcp/string_array.rb +5 -0
- data/lib/action_mcp/tool.rb +16 -53
- data/lib/action_mcp/tools_registry.rb +14 -1
- data/lib/action_mcp/transport/capabilities.rb +21 -0
- data/lib/action_mcp/transport/messaging.rb +20 -0
- data/lib/action_mcp/transport/prompts.rb +19 -0
- data/lib/action_mcp/transport/sse_client.rb +309 -0
- data/lib/action_mcp/transport/stdio_client.rb +117 -0
- data/lib/action_mcp/transport/tools.rb +20 -0
- data/lib/action_mcp/transport/transport_base.rb +125 -0
- data/lib/action_mcp/transport.rb +1 -235
- data/lib/action_mcp/transport_handler.rb +54 -0
- data/lib/action_mcp/version.rb +4 -5
- data/lib/action_mcp.rb +36 -33
- data/lib/generators/action_mcp/prompt/templates/prompt.rb.erb +3 -1
- data/lib/generators/action_mcp/tool/templates/tool.rb.erb +5 -1
- data/lib/tasks/action_mcp_tasks.rake +28 -5
- metadata +62 -9
- data/exe/action_mcp_stdio +0 -0
- data/lib/action_mcp/railtie.rb +0 -27
- data/lib/action_mcp/resources_bank.rb +0 -94
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.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Abdelkader Boudih
|
8
8
|
bindir: exe
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-
|
10
|
+
date: 2025-03-11 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
|
-
name:
|
13
|
+
name: railties
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
15
15
|
requirements:
|
16
16
|
- - ">="
|
@@ -24,7 +24,21 @@ dependencies:
|
|
24
24
|
- !ruby/object:Gem::Version
|
25
25
|
version: 8.0.1
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
|
-
name:
|
27
|
+
name: activerecord
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 8.0.1
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: 8.0.1
|
40
|
+
- !ruby/object:Gem::Dependency
|
41
|
+
name: actioncable
|
28
42
|
requirement: !ruby/object:Gem::Requirement
|
29
43
|
requirements:
|
30
44
|
- - ">="
|
@@ -51,20 +65,49 @@ dependencies:
|
|
51
65
|
- - ">="
|
52
66
|
- !ruby/object:Gem::Version
|
53
67
|
version: '0'
|
68
|
+
- !ruby/object:Gem::Dependency
|
69
|
+
name: faraday
|
70
|
+
requirement: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - "~>"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '2.0'
|
75
|
+
type: :runtime
|
76
|
+
prerelease: false
|
77
|
+
version_requirements: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - "~>"
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '2.0'
|
82
|
+
- !ruby/object:Gem::Dependency
|
83
|
+
name: zeitwerk
|
84
|
+
requirement: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - "~>"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '2.6'
|
89
|
+
type: :runtime
|
90
|
+
prerelease: false
|
91
|
+
version_requirements: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - "~>"
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '2.6'
|
54
96
|
description: It offers base classes and helpers for creating MCP applications, making
|
55
97
|
it easier to integrate your Ruby/Rails application with the MCP standard
|
56
98
|
email:
|
57
99
|
- terminale@gmail.com
|
58
100
|
executables:
|
59
|
-
-
|
101
|
+
- actionmcp_cli
|
60
102
|
extensions: []
|
61
103
|
extra_rdoc_files: []
|
62
104
|
files:
|
63
105
|
- MIT-LICENSE
|
64
106
|
- README.md
|
65
107
|
- Rakefile
|
66
|
-
- exe/
|
108
|
+
- exe/actionmcp_cli
|
67
109
|
- lib/action_mcp.rb
|
110
|
+
- lib/action_mcp/capability.rb
|
68
111
|
- lib/action_mcp/client.rb
|
69
112
|
- lib/action_mcp/configuration.rb
|
70
113
|
- lib/action_mcp/content.rb
|
@@ -72,6 +115,7 @@ files:
|
|
72
115
|
- lib/action_mcp/content/image.rb
|
73
116
|
- lib/action_mcp/content/resource.rb
|
74
117
|
- lib/action_mcp/content/text.rb
|
118
|
+
- lib/action_mcp/engine.rb
|
75
119
|
- lib/action_mcp/gem_version.rb
|
76
120
|
- lib/action_mcp/integer_array.rb
|
77
121
|
- lib/action_mcp/json_rpc.rb
|
@@ -79,18 +123,26 @@ files:
|
|
79
123
|
- lib/action_mcp/json_rpc/notification.rb
|
80
124
|
- lib/action_mcp/json_rpc/request.rb
|
81
125
|
- lib/action_mcp/json_rpc/response.rb
|
126
|
+
- lib/action_mcp/json_rpc_handler.rb
|
127
|
+
- lib/action_mcp/logging.rb
|
82
128
|
- lib/action_mcp/prompt.rb
|
83
129
|
- lib/action_mcp/prompts_registry.rb
|
84
|
-
- lib/action_mcp/railtie.rb
|
85
130
|
- lib/action_mcp/registry_base.rb
|
86
131
|
- lib/action_mcp/renderable.rb
|
87
132
|
- lib/action_mcp/resource.rb
|
88
|
-
- lib/action_mcp/resources_bank.rb
|
89
133
|
- lib/action_mcp/server.rb
|
90
134
|
- lib/action_mcp/string_array.rb
|
91
135
|
- lib/action_mcp/tool.rb
|
92
136
|
- lib/action_mcp/tools_registry.rb
|
93
137
|
- lib/action_mcp/transport.rb
|
138
|
+
- lib/action_mcp/transport/capabilities.rb
|
139
|
+
- lib/action_mcp/transport/messaging.rb
|
140
|
+
- lib/action_mcp/transport/prompts.rb
|
141
|
+
- lib/action_mcp/transport/sse_client.rb
|
142
|
+
- lib/action_mcp/transport/stdio_client.rb
|
143
|
+
- lib/action_mcp/transport/tools.rb
|
144
|
+
- lib/action_mcp/transport/transport_base.rb
|
145
|
+
- lib/action_mcp/transport_handler.rb
|
94
146
|
- lib/action_mcp/version.rb
|
95
147
|
- lib/actionmcp.rb
|
96
148
|
- lib/generators/action_mcp/install/install_generator.rb
|
@@ -107,6 +159,7 @@ licenses:
|
|
107
159
|
metadata:
|
108
160
|
homepage_uri: https://github.com/seuros/action_mcp
|
109
161
|
source_code_uri: https://github.com/seuros/action_mcp
|
162
|
+
changelog_uri: https://github.com/seuros/action_mcp/blob/master/CHANGELOG.md
|
110
163
|
rubygems_mfa_required: 'true'
|
111
164
|
rdoc_options: []
|
112
165
|
require_paths:
|
@@ -122,7 +175,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
122
175
|
- !ruby/object:Gem::Version
|
123
176
|
version: '0'
|
124
177
|
requirements: []
|
125
|
-
rubygems_version: 3.6.
|
178
|
+
rubygems_version: 3.6.5
|
126
179
|
specification_version: 4
|
127
180
|
summary: Provides essential tooling for building Model Context Protocol (MCP) capable
|
128
181
|
servers
|
data/exe/action_mcp_stdio
DELETED
File without changes
|
data/lib/action_mcp/railtie.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "rails"
|
4
|
-
require "active_model/railtie"
|
5
|
-
|
6
|
-
module ActionMCP
|
7
|
-
class Railtie < Rails::Railtie # :nodoc:
|
8
|
-
# Provide a configuration namespace for ActionMCP
|
9
|
-
config.action_mcp = ActiveSupport::OrderedOptions.new
|
10
|
-
|
11
|
-
config.after_initialize do |app|
|
12
|
-
options = app.config.action_mcp.to_h.symbolize_keys
|
13
|
-
|
14
|
-
# Override the default configuration if specified in the Rails app.
|
15
|
-
ActionMCP.configuration.name = options[:name] if options.key?(:name)
|
16
|
-
ActionMCP.configuration.version = options[:version] if options.key?(:version)
|
17
|
-
ActionMCP.configuration.logging_enabled = options.fetch(:logging_enabled, true)
|
18
|
-
end
|
19
|
-
|
20
|
-
initializer "action_mcp.clear_registry" do |app|
|
21
|
-
app.config.to_prepare do
|
22
|
-
ActionMCP::ToolsRegistry.clear!
|
23
|
-
ActionMCP::PromptsRegistry.clear!
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,94 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module ActionMCP
|
4
|
-
module ResourcesBank
|
5
|
-
@resources = {} # { uri => content_object }
|
6
|
-
@templates = {} # { uri => template_object }
|
7
|
-
@watchers = {} # { source_uri => watcher }
|
8
|
-
|
9
|
-
class << self
|
10
|
-
# Basic resource registration.
|
11
|
-
def register_resource(uri, content)
|
12
|
-
@resources[uri] = content
|
13
|
-
end
|
14
|
-
|
15
|
-
def all_resources
|
16
|
-
@resources.values
|
17
|
-
end
|
18
|
-
|
19
|
-
def read(uri)
|
20
|
-
@resources[uri]
|
21
|
-
end
|
22
|
-
|
23
|
-
def register_template(uri, template)
|
24
|
-
@templates[uri] = template
|
25
|
-
end
|
26
|
-
|
27
|
-
def all_templates
|
28
|
-
@templates.values
|
29
|
-
end
|
30
|
-
|
31
|
-
# Registers a source (file or directory) for resources.
|
32
|
-
#
|
33
|
-
# @param source_uri [String] An identifier for this source.
|
34
|
-
# @param path [String] Filesystem path to the source.
|
35
|
-
# @param watch [Boolean] Whether to watch the source for changes.
|
36
|
-
def register_source(source_uri, path, watch: false)
|
37
|
-
reload_source(source_uri, path) # Initial load
|
38
|
-
|
39
|
-
return unless watch
|
40
|
-
|
41
|
-
require "active_support/evented_file_update_checker"
|
42
|
-
# Watch all files under the given path (recursive)
|
43
|
-
file_paths = Dir.glob("#{path}/**/*")
|
44
|
-
watcher = ActiveSupport::EventedFileUpdateChecker.new(file_paths) do |modified, added, removed|
|
45
|
-
Rails.logger.info("Files changed in #{path} - Modified: #{modified.inspect}, Added: #{added.inspect}, Removed: #{removed.inspect}")
|
46
|
-
# Reload resources for this source when changes occur.
|
47
|
-
reload_source(source_uri, path)
|
48
|
-
end
|
49
|
-
@watchers[source_uri] = { path: path, watcher: watcher }
|
50
|
-
end
|
51
|
-
|
52
|
-
# Unregisters a source and stops watching it.
|
53
|
-
#
|
54
|
-
# @param source_uri [String] The identifier for the source.
|
55
|
-
def unregister_source(source_uri)
|
56
|
-
@watchers.delete(source_uri)
|
57
|
-
# Optionally, remove any resources associated with this source.
|
58
|
-
@resources.reject! { |uri, _| uri.start_with?("#{source_uri}://") }
|
59
|
-
end
|
60
|
-
|
61
|
-
# Reloads (or loads) all resources from the given directory.
|
62
|
-
#
|
63
|
-
# @param source_uri [String] The identifier for the source.
|
64
|
-
# @param path [String] Filesystem path to the source.
|
65
|
-
def reload_source(source_uri, path)
|
66
|
-
Rails.logger.info("Reloading resources from #{path} for #{source_uri}")
|
67
|
-
Dir.glob("#{path}/**/*").each do |file|
|
68
|
-
next unless File.file?(file)
|
69
|
-
|
70
|
-
# Create a resource URI from the source and file path.
|
71
|
-
relative_path = file.sub(%r{\A#{Regexp.escape(path)}/?}, "")
|
72
|
-
resource_uri = "#{source_uri}://#{relative_path}"
|
73
|
-
# For this example, we assume text files.
|
74
|
-
begin
|
75
|
-
text = File.read(file)
|
76
|
-
content = ActionMCP::Content::Text.new(text)
|
77
|
-
register_resource(resource_uri, content)
|
78
|
-
Rails.logger.info("Registered resource: #{resource_uri}")
|
79
|
-
rescue StandardError => e
|
80
|
-
Rails.logger.error("Error reading file #{file}: #{e.message}")
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
# This method should be called periodically (e.g. via a background thread)
|
86
|
-
# to check if any watched files have changed.
|
87
|
-
def run_watchers
|
88
|
-
@watchers.each_value do |data|
|
89
|
-
data[:watcher].execute_if_updated
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|