mcp-rails 0.4.11 → 0.4.13
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/lib/mcp/rails/version.rb +1 -1
- data/tasks/mcp/rails_tasks.rake +9 -0
- data/test/support/mcp/rails/test_helper.rb +101 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bf51fdbb5772ee9c2542229bd4190fe9843c75da61b4905f9c1c8acf4ba7c8ac
|
4
|
+
data.tar.gz: e876eb8e23970e633c04b640e5f1beeeded11b429d8ad0e32592b6a07de27892
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ddcd5c71daa86a8cb46f0c61d9ea884ef3ac16ef14fbc255b6d1afcf6c6e459b8b3f6cb9ef2010af4ee7513b787c13b3a4cc1788e9ed9f3e1239a06b6b7ff33
|
7
|
+
data.tar.gz: 80b2fc90891808c2e1191e825246a8c10c4ba7de57f294077e7734fb25f05110b0b58bddc62bc3d2183be4a226fe179be58846ef3b4bf3b9cf3545d29c0039d2
|
data/lib/mcp/rails/version.rb
CHANGED
@@ -0,0 +1,101 @@
|
|
1
|
+
module MCP
|
2
|
+
module Rails
|
3
|
+
module TestHelper
|
4
|
+
def self.included(base)
|
5
|
+
base.setup do
|
6
|
+
@temp_dir = Dir.mktmpdir nil, ::Rails.root.join("tmp")
|
7
|
+
@key_path = File.join(@temp_dir, "bypass_key.txt")
|
8
|
+
@output_dir = @temp_dir
|
9
|
+
|
10
|
+
@old_mcp_configuration = MCP::Rails.configuration
|
11
|
+
|
12
|
+
@new_mcp_configuration = MCP::Rails::Configuration.new
|
13
|
+
@old_mcp_configuration.engine_configurations.each do |name, config|
|
14
|
+
@new_mcp_configuration.register_engine name, env_vars: config.env_vars
|
15
|
+
end
|
16
|
+
@new_mcp_configuration.bypass_key_path = @key_path
|
17
|
+
@new_mcp_configuration.output_directory = @output_dir
|
18
|
+
MCP::Rails.configuration = @new_mcp_configuration
|
19
|
+
|
20
|
+
@generator = MCP::Rails::ServerGenerator
|
21
|
+
@server_files = @generator.generate_files(@new_mcp_configuration)
|
22
|
+
end
|
23
|
+
|
24
|
+
base.teardown do
|
25
|
+
FileUtils.remove_entry @temp_dir
|
26
|
+
MCP::Rails.configuration = @old_mcp_configuration
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def mcp_servers
|
31
|
+
@mcp_servers = @server_files.map do |file|
|
32
|
+
require file
|
33
|
+
at_exit { MCP.instance_variable_set(:@server, nil) }
|
34
|
+
initialize_server(MCP.server)
|
35
|
+
MCP.server
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def mcp_server(name: "mcp-server")
|
40
|
+
mcp_servers.find { |server| server.name == name }
|
41
|
+
end
|
42
|
+
|
43
|
+
def mcp_tool_list(server)
|
44
|
+
request = {
|
45
|
+
jsonrpc: MCP::Constants::JSON_RPC_VERSION,
|
46
|
+
method: MCP::Constants::RequestMethods::TOOLS_LIST,
|
47
|
+
id: 1
|
48
|
+
}
|
49
|
+
|
50
|
+
send_request(server, request)
|
51
|
+
end
|
52
|
+
|
53
|
+
def mcp_tool_call(server, name, arguments = {})
|
54
|
+
request = {
|
55
|
+
jsonrpc: MCP::Constants::JSON_RPC_VERSION,
|
56
|
+
id: 1,
|
57
|
+
method: MCP::Constants::RequestMethods::TOOLS_CALL,
|
58
|
+
params: {
|
59
|
+
name: name,
|
60
|
+
arguments: arguments.merge({ test_context: self })
|
61
|
+
}
|
62
|
+
}
|
63
|
+
send_request(server, request)
|
64
|
+
end
|
65
|
+
|
66
|
+
def mcp_response_body
|
67
|
+
JSON.parse(response.body).dig("data")
|
68
|
+
end
|
69
|
+
|
70
|
+
private
|
71
|
+
|
72
|
+
def send_request(server, request)
|
73
|
+
response = server.send(:handle_request, request)
|
74
|
+
raise "Request failed: #{response}" unless response.dig(:result, :isError) == false
|
75
|
+
response
|
76
|
+
end
|
77
|
+
|
78
|
+
def initialize_server(server)
|
79
|
+
init_request = {
|
80
|
+
jsonrpc: MCP::Constants::JSON_RPC_VERSION,
|
81
|
+
method: "initialize",
|
82
|
+
params: {
|
83
|
+
protocolVersion: MCP::Constants::PROTOCOL_VERSION,
|
84
|
+
capabilities: {}
|
85
|
+
},
|
86
|
+
id: 1
|
87
|
+
}
|
88
|
+
initialize_response = server.send(:handle_request, init_request)
|
89
|
+
|
90
|
+
init_notification = {
|
91
|
+
jsonrpc: MCP::Constants::JSON_RPC_VERSION,
|
92
|
+
method: "notifications/initialized",
|
93
|
+
id: 2
|
94
|
+
}
|
95
|
+
server.send(:handle_request, init_notification)
|
96
|
+
|
97
|
+
initialize_response
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mcp-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tonksthebear
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-03-
|
10
|
+
date: 2025-03-16 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: mcp-rb
|
@@ -99,6 +99,8 @@ files:
|
|
99
99
|
- lib/mcp/rails/server_generator/route_collector.rb
|
100
100
|
- lib/mcp/rails/server_generator/server_writer.rb
|
101
101
|
- lib/mcp/rails/version.rb
|
102
|
+
- tasks/mcp/rails_tasks.rake
|
103
|
+
- test/support/mcp/rails/test_helper.rb
|
102
104
|
homepage: https://github.com/Tonksthebear/mcp-rails
|
103
105
|
licenses:
|
104
106
|
- MIT
|
@@ -120,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
122
|
- !ruby/object:Gem::Version
|
121
123
|
version: '0'
|
122
124
|
requirements: []
|
123
|
-
rubygems_version: 3.6.
|
125
|
+
rubygems_version: 3.6.2
|
124
126
|
specification_version: 4
|
125
127
|
summary: MCP Integration for Rails
|
126
128
|
test_files: []
|