rails-profiler 0.44.19 → 0.44.20
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/CHANGELOG.md +13 -0
- data/lib/profiler/mcp/server.rb +1 -1
- data/lib/profiler/mcp/tools/clear_profiles.rb +4 -1
- data/lib/profiler/mcp/tools/explain_query.rb +36 -8
- data/lib/profiler/mcp/tools/get_profile_detail.rb +5 -4
- data/lib/profiler/mcp/tools/query_console_profiles.rb +1 -1
- data/lib/profiler/mcp/tools/query_jobs.rb +1 -1
- data/lib/profiler/mcp/tools/query_mailers.rb +1 -1
- data/lib/profiler/mcp/tools/query_profiles.rb +1 -1
- data/lib/profiler/mcp/tools/query_test_profiles.rb +1 -1
- data/lib/profiler/mcp/tools/set_env_var.rb +9 -4
- data/lib/profiler/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: 12ce9dde45b6c00f05d7496da2b765adbb843bc7e35cd956f9294a88bc06f34d
|
|
4
|
+
data.tar.gz: 6a114fab97682f2375bb1d778016d1279ba5f00cbcc5a43ca61767b9fedcb220
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 60573fb7ef5502e652815f5101cb111775e4bd16a9a2cd9f18f90f19542c95080548b24a84a130cce667510d421ae1d68fcf2aa4ec4d6bca3733330587d62781
|
|
7
|
+
data.tar.gz: a7af8dd153a21e6a47d86f7eceb3085313bfe2953d68b76a817c21a9d57f87e352c017b47454beb5045a706e36b7fb25e4fb509a326e8740f41dac995528b201
|
data/CHANGELOG.md
CHANGED
|
@@ -19,6 +19,19 @@ every commit of every tag interval is accounted for one way or the other.
|
|
|
19
19
|
|
|
20
20
|
## [Unreleased]
|
|
21
21
|
|
|
22
|
+
## [0.44.20] - 2026-10-25
|
|
23
|
+
|
|
24
|
+
<!-- stamped -->
|
|
25
|
+
|
|
26
|
+
### Fixed
|
|
27
|
+
|
|
28
|
+
- **MCP:** Clamp negative, zero, and oversized `limit` parameters in `query_profiles`, `query_jobs`, `query_mailers`, `query_console_profiles`, and `query_test_profiles` tools to the valid range `[1, 500]` to prevent invalid queries and unexpected behavior.
|
|
29
|
+
- **MCP:** Implement `'latest'` token support in `explain_query` tool, matching the behavior of `analyze_queries` and `get_profile` tools.
|
|
30
|
+
- **MCP:** Fix `related_jobs` section in `get_profile_detail` to read parent and child jobs from the correct storage (slave or local) instead of always reading from master storage.
|
|
31
|
+
- **MCP:** Return JSON-RPC error -32002 for unknown resource URIs instead of returning a success response with "Resource not found" text.
|
|
32
|
+
- **MCP:** Add `error: true` flag consistently to all validation error responses in `clear_profiles`, `explain_query`, and other tools for proper error handling by clients.
|
|
33
|
+
- **MCP:** Align `set_env_var` empty value handling with `EnvVarsController#update`: empty values now delete the environment variable and override, consistent between local and slave operations.
|
|
34
|
+
|
|
22
35
|
## [0.44.19] - 2026-10-25
|
|
23
36
|
|
|
24
37
|
<!-- stamped -->
|
data/lib/profiler/mcp/server.rb
CHANGED
|
@@ -54,7 +54,7 @@ module Profiler
|
|
|
54
54
|
@server.resources_read_handler do |params|
|
|
55
55
|
uri = params[:uri]
|
|
56
56
|
handler = @resource_handlers[uri]
|
|
57
|
-
next
|
|
57
|
+
next nil unless handler
|
|
58
58
|
|
|
59
59
|
begin
|
|
60
60
|
result = handler.call
|
|
@@ -10,7 +10,10 @@ module Profiler
|
|
|
10
10
|
type = params["type"]
|
|
11
11
|
|
|
12
12
|
if type && !%w[http job test console].include?(type)
|
|
13
|
-
return
|
|
13
|
+
return ::MCP::Tool::Response.new(
|
|
14
|
+
[{ type: "text", text: "Error: type must be 'http', 'job', 'test', or 'console'" }],
|
|
15
|
+
error: true
|
|
16
|
+
)
|
|
14
17
|
end
|
|
15
18
|
|
|
16
19
|
if (proxy = MCP::SlaveSupport.with_slave_proxy(params))
|
|
@@ -13,24 +13,46 @@ module Profiler
|
|
|
13
13
|
query_index = params["query_index"]
|
|
14
14
|
|
|
15
15
|
unless token
|
|
16
|
-
return
|
|
16
|
+
return ::MCP::Tool::Response.new(
|
|
17
|
+
[{ type: "text", text: "Error: token parameter is required" }],
|
|
18
|
+
error: true
|
|
19
|
+
)
|
|
17
20
|
end
|
|
18
21
|
|
|
19
22
|
if query_index.nil?
|
|
20
|
-
return
|
|
23
|
+
return ::MCP::Tool::Response.new(
|
|
24
|
+
[{ type: "text", text: "Error: query_index parameter is required" }],
|
|
25
|
+
error: true
|
|
26
|
+
)
|
|
21
27
|
end
|
|
22
28
|
|
|
23
29
|
if (proxy = MCP::SlaveSupport.with_slave_proxy(params))
|
|
24
30
|
result = proxy.post_json("/_profiler/api/explain", { token: token, query_index: query_index.to_i })
|
|
25
|
-
|
|
26
|
-
|
|
31
|
+
if result["error"]
|
|
32
|
+
return ::MCP::Tool::Response.new(
|
|
33
|
+
[{ type: "text", text: "Error: #{result["error"]}" }],
|
|
34
|
+
error: true
|
|
35
|
+
)
|
|
36
|
+
end
|
|
37
|
+
return [{ type: "text", text: result.inspect }]
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
storage = MCP::SlaveSupport.resolve_storage(params)
|
|
41
|
+
resolved_token = if token == "latest"
|
|
42
|
+
latest = storage.list(limit: 1).first
|
|
43
|
+
latest ? latest.token : token
|
|
44
|
+
else
|
|
45
|
+
token
|
|
27
46
|
end
|
|
28
47
|
|
|
29
48
|
if (reason = Profiler::ExplainRunner.refusal)
|
|
30
|
-
return
|
|
49
|
+
return ::MCP::Tool::Response.new(
|
|
50
|
+
[{ type: "text", text: "Error: #{reason}" }],
|
|
51
|
+
error: true
|
|
52
|
+
)
|
|
31
53
|
end
|
|
32
54
|
|
|
33
|
-
data = Profiler::ExplainRunner.run(
|
|
55
|
+
data = Profiler::ExplainRunner.run(resolved_token, query_index.to_i)
|
|
34
56
|
|
|
35
57
|
lines = []
|
|
36
58
|
lines << "# EXPLAIN ANALYZE - Query ##{query_index}"
|
|
@@ -48,10 +70,16 @@ module Profiler
|
|
|
48
70
|
|
|
49
71
|
[{ type: "text", text: lines.join("\n") }]
|
|
50
72
|
rescue Profiler::ExplainRunner::RefusedError => e
|
|
51
|
-
|
|
73
|
+
::MCP::Tool::Response.new(
|
|
74
|
+
[{ type: "text", text: "Error: #{e.message}" }],
|
|
75
|
+
error: true
|
|
76
|
+
)
|
|
52
77
|
rescue Profiler::Error => e
|
|
53
78
|
# The profiler's own refusals (unknown, offline or refused slave) carry a message made for the caller.
|
|
54
|
-
|
|
79
|
+
::MCP::Tool::Response.new(
|
|
80
|
+
[{ type: "text", text: "Error: #{e.message}" }],
|
|
81
|
+
error: true
|
|
82
|
+
)
|
|
55
83
|
rescue StandardError => e
|
|
56
84
|
# The database's message carries the SQL, and sometimes a path: the log only.
|
|
57
85
|
Profiler.log_error("MCP explain_query: failed for query #{query_index.to_i} of profile #{token.to_s.inspect}", e)
|
|
@@ -79,7 +79,7 @@ module Profiler
|
|
|
79
79
|
lines += section_logs(profile, params) if want.("logs")
|
|
80
80
|
lines += section_env(profile, params) if want.("env")
|
|
81
81
|
lines += section_i18n(profile) if want.("i18n")
|
|
82
|
-
lines += section_related_jobs(profile)
|
|
82
|
+
lines += section_related_jobs(profile, params) if want.("related_jobs")
|
|
83
83
|
lines.join("\n")
|
|
84
84
|
end
|
|
85
85
|
|
|
@@ -622,12 +622,13 @@ module Profiler
|
|
|
622
622
|
lines
|
|
623
623
|
end
|
|
624
624
|
|
|
625
|
-
def self.section_related_jobs(profile)
|
|
625
|
+
def self.section_related_jobs(profile, params = {})
|
|
626
|
+
storage = MCP::SlaveSupport.resolve_storage(params)
|
|
626
627
|
lines = []
|
|
627
628
|
|
|
628
629
|
# Parent info
|
|
629
630
|
if profile.parent_token
|
|
630
|
-
parent =
|
|
631
|
+
parent = storage.load(profile.parent_token)
|
|
631
632
|
if parent
|
|
632
633
|
lines << "## Triggered By"
|
|
633
634
|
if parent.profile_type == "job"
|
|
@@ -649,7 +650,7 @@ module Profiler
|
|
|
649
650
|
end
|
|
650
651
|
|
|
651
652
|
# Child jobs
|
|
652
|
-
child_jobs =
|
|
653
|
+
child_jobs = storage.find_by_parent(profile.token).select { |p| p.profile_type == "job" }
|
|
653
654
|
return lines if child_jobs.empty?
|
|
654
655
|
|
|
655
656
|
lines << "## Child Jobs (#{child_jobs.size})"
|
|
@@ -9,7 +9,7 @@ module Profiler
|
|
|
9
9
|
ALL_FIELDS = %w[time expression return_value status duration queries token].freeze
|
|
10
10
|
|
|
11
11
|
def self.call(params)
|
|
12
|
-
limit = params["limit"]&.to_i || 20
|
|
12
|
+
limit = [[params["limit"]&.to_i || 20, 1].max, 500].min
|
|
13
13
|
fetch_size = [limit * 5, 500].min
|
|
14
14
|
storage = MCP::SlaveSupport.resolve_storage(params)
|
|
15
15
|
profiles = storage.list(limit: fetch_size, type: "console")
|
|
@@ -9,7 +9,7 @@ module Profiler
|
|
|
9
9
|
ALL_FIELDS = %w[time job_class queue status duration gem_version token parent_token].freeze
|
|
10
10
|
|
|
11
11
|
def self.call(params)
|
|
12
|
-
limit = params["limit"]&.to_i || 20
|
|
12
|
+
limit = [[params["limit"]&.to_i || 20, 1].max, 500].min
|
|
13
13
|
fetch_size = [limit * 5, 500].min
|
|
14
14
|
storage = MCP::SlaveSupport.resolve_storage(params)
|
|
15
15
|
profiles = storage.list(limit: fetch_size, type: "job")
|
|
@@ -10,7 +10,7 @@ module Profiler
|
|
|
10
10
|
|
|
11
11
|
class << self
|
|
12
12
|
def call(params)
|
|
13
|
-
limit = params["limit"]&.to_i || 20
|
|
13
|
+
limit = [[params["limit"]&.to_i || 20, 1].max, 500].min
|
|
14
14
|
fetch_size = [limit * 10, 1000].min
|
|
15
15
|
storage = MCP::SlaveSupport.resolve_storage(params)
|
|
16
16
|
profiles = storage.list(limit: fetch_size)
|
|
@@ -10,7 +10,7 @@ module Profiler
|
|
|
10
10
|
|
|
11
11
|
def self.call(params)
|
|
12
12
|
storage = MCP::SlaveSupport.resolve_storage(params)
|
|
13
|
-
limit = params["limit"]&.to_i || 20
|
|
13
|
+
limit = [[params["limit"]&.to_i || 20, 1].max, 500].min
|
|
14
14
|
fetch_size = [limit * 5, 500].min
|
|
15
15
|
profiles = storage.list(limit: fetch_size, type: params["profile_type"])
|
|
16
16
|
|
|
@@ -9,7 +9,7 @@ module Profiler
|
|
|
9
9
|
ALL_FIELDS = %w[time test_name status duration queries n1 token].freeze
|
|
10
10
|
|
|
11
11
|
def self.call(params)
|
|
12
|
-
limit = params["limit"]&.to_i || 20
|
|
12
|
+
limit = [[params["limit"]&.to_i || 20, 1].max, 500].min
|
|
13
13
|
fetch_size = [limit * 5, 500].min
|
|
14
14
|
storage = MCP::SlaveSupport.resolve_storage(params)
|
|
15
15
|
profiles = storage.list(limit: fetch_size, type: "test")
|
|
@@ -33,10 +33,15 @@ module Profiler
|
|
|
33
33
|
return [{ type: "text", text: "Set #{key}=#{value} on slave '#{params["slave"]}'" }]
|
|
34
34
|
end
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
if value.empty?
|
|
37
|
+
Profiler.env_override_store.delete(key)
|
|
38
|
+
ENV.delete(key)
|
|
39
|
+
[{ type: "text", text: "Deleted #{key}" }]
|
|
40
|
+
else
|
|
41
|
+
Profiler.env_override_store.set(key, value)
|
|
42
|
+
ENV[key] = value
|
|
43
|
+
[{ type: "text", text: "Set #{key}=#{value}" }]
|
|
44
|
+
end
|
|
40
45
|
rescue Profiler::EnvOverrideStore::Error => e
|
|
41
46
|
::MCP::Tool::Response.new([{ type: "text", text: "Error: #{e.message}; #{key} was left unchanged." }], error: true)
|
|
42
47
|
end
|
data/lib/profiler/version.rb
CHANGED