explicit 0.2.18 → 0.2.19
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/explicit/mcp_server/request.rb +5 -3
- data/lib/explicit/mcp_server/router.rb +23 -8
- data/lib/explicit/mcp_server.rb +1 -3
- data/lib/explicit/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: 2be9f58389c8a9d5478bf8c0604b89ce308d90ad44e1f053ed9ad6565dd85ecb
|
4
|
+
data.tar.gz: cb2aa01a9ae758d3247db1f5379456f4c9711a4153fd965bb1baf9bf459f0518
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c726fe0a4e25152e827c478628562c7af69e263af082229af8b6de361a1144f44bb8799f7ed3b78a95899594fe18867e1f3bdaca882c722a54f393477f6985de
|
7
|
+
data.tar.gz: 564654b46d1681986dbbf4c8cfd1da706606c9290332230a507ad5cac21a5d845b9f96a92b0fcb0012205d8721fc59a77810962ccd4641c8c951e5d0543a919c
|
@@ -3,7 +3,7 @@
|
|
3
3
|
require "rack/utils"
|
4
4
|
|
5
5
|
module Explicit::MCPServer
|
6
|
-
Request = ::Data.define(:id, :method, :params, :host, :headers) do
|
6
|
+
Request = ::Data.define(:id, :method, :params, :host, :headers, :rack_env) do
|
7
7
|
def self.from_rack_env(env)
|
8
8
|
headers = env.each_with_object({}) do |(key, value), hash|
|
9
9
|
if key.start_with?("HTTP_") && key != "HTTP_HOST"
|
@@ -19,7 +19,8 @@ module Explicit::MCPServer
|
|
19
19
|
method: body["method"],
|
20
20
|
params: body["params"],
|
21
21
|
host: env["HTTP_HOST"],
|
22
|
-
headers
|
22
|
+
headers:,
|
23
|
+
rack_env: env
|
23
24
|
)
|
24
25
|
rescue ::JSON::ParserError
|
25
26
|
new(
|
@@ -27,7 +28,8 @@ module Explicit::MCPServer
|
|
27
28
|
method: nil,
|
28
29
|
params: nil,
|
29
30
|
host: env["HTTP_HOST"],
|
30
|
-
headers
|
31
|
+
headers:,
|
32
|
+
rack_env: env
|
31
33
|
)
|
32
34
|
end
|
33
35
|
|
@@ -53,8 +53,6 @@ class Explicit::MCPServer::Router
|
|
53
53
|
return request.error({ code: -32602, message: "tool not found" })
|
54
54
|
end
|
55
55
|
|
56
|
-
session = ::ActionDispatch::Integration::Session.new(::Rails.application)
|
57
|
-
session.host = request.host
|
58
56
|
route = tool.request.routes.first
|
59
57
|
|
60
58
|
path = [
|
@@ -62,23 +60,40 @@ class Explicit::MCPServer::Router
|
|
62
60
|
route.replace_path_params(arguments)
|
63
61
|
].compact_blank.join
|
64
62
|
|
65
|
-
|
63
|
+
body_content, querystring =
|
66
64
|
if route.accepts_request_body?
|
67
|
-
[
|
65
|
+
[arguments.to_json, ""]
|
68
66
|
else
|
69
|
-
["
|
67
|
+
["", arguments.to_query]
|
70
68
|
end
|
71
69
|
|
72
|
-
|
70
|
+
rack_input = ::StringIO.new(body_content)
|
71
|
+
rack_input.rewind
|
72
|
+
|
73
|
+
env = request.rack_env.merge({
|
74
|
+
"REQUEST_METHOD" => route.method.to_s.upcase,
|
75
|
+
"PATH_INFO" => path,
|
76
|
+
"rack.input" => rack_input,
|
77
|
+
"CONTENT_TYPE" => "application/json",
|
78
|
+
"CONTENT_LENGTH" => body_content.bytesize.to_s,
|
79
|
+
"QUERY_STRING" => querystring
|
80
|
+
})
|
81
|
+
|
82
|
+
request.headers.each do |key, value|
|
83
|
+
env["HTTP_#{key.upcase.tr('-', '_')}"] = value
|
84
|
+
end
|
85
|
+
|
86
|
+
status, headers, body = Rails.application.call(env)
|
87
|
+
response = ::ActionDispatch::Response.new(status, headers, body)
|
73
88
|
|
74
89
|
request.result({
|
75
90
|
content: [
|
76
91
|
{
|
77
92
|
type: "text",
|
78
|
-
text:
|
93
|
+
text: response.body
|
79
94
|
}
|
80
95
|
],
|
81
|
-
isError:
|
96
|
+
isError: response.status < 200 || response.status > 299
|
82
97
|
})
|
83
98
|
end
|
84
99
|
end
|
data/lib/explicit/mcp_server.rb
CHANGED
@@ -6,9 +6,7 @@ module Explicit::MCPServer
|
|
6
6
|
def new(&block)
|
7
7
|
engine = ::Class.new(::Rails::Engine)
|
8
8
|
|
9
|
-
builder = Builder.new.tap
|
10
|
-
builder.instance_eval(&block)
|
11
|
-
end
|
9
|
+
builder = Builder.new.tap { _1.instance_eval(&block) }
|
12
10
|
|
13
11
|
if builder.get_name.blank?
|
14
12
|
raise <<~TEXT
|
data/lib/explicit/version.rb
CHANGED