rails-pg-extras-mcp 0.2.2 → 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/lib/rails-pg-extras-mcp.rb +21 -14
- data/lib/rails_pg_extras_mcp/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: 72d363ce5cf74c8c22e8a636c3b908f27be10cc5a21691acd480b791ab9e8c33
|
4
|
+
data.tar.gz: 36f3cb7fd5c1784c727def8ea7ad4c6f572f21c301ce99440440e4d5843f1e62
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5565add5c44d77aa22c20f238c5f87d1f6e537f03f2b1d40fee5a5bbde03ed46690d11ecfecdecf791d65c0d748a26eaae5940d8808163e2c335fc4bad3c29ef
|
7
|
+
data.tar.gz: 8f7235f0b1e8ec213379c2f98895522ca54eed4c3c4912d7c5773a377fb9e0207a638ace52f235b7a6012161ed3f543afa565ecb5281e1f5fc3a7f09039f04b5
|
data/lib/rails-pg-extras-mcp.rb
CHANGED
@@ -75,23 +75,18 @@ class ExplainBaseTool < FastMcp::Tool
|
|
75
75
|
create,
|
76
76
|
grant,
|
77
77
|
begin,
|
78
|
-
commit
|
79
|
-
;
|
78
|
+
commit
|
80
79
|
]
|
81
80
|
|
82
|
-
|
83
|
-
required(:query).filled(:string).description("The query to debug")
|
84
|
-
end
|
85
|
-
|
86
|
-
def call(query:)
|
81
|
+
def call(sql_query:)
|
87
82
|
connection = RailsPgExtras.connection
|
88
83
|
|
89
|
-
if DENYLIST.any? { |deny|
|
84
|
+
if DENYLIST.any? { |deny| sql_query.downcase.include?(deny) }
|
90
85
|
raise "This query is not allowed. It contains a denied keyword. Denylist: #{DENYLIST.join(", ")}"
|
91
86
|
end
|
92
87
|
|
93
88
|
connection.execute("BEGIN")
|
94
|
-
result = connection.execute("#{
|
89
|
+
result = connection.execute("#{sql_query}")
|
95
90
|
connection.execute("ROLLBACK")
|
96
91
|
|
97
92
|
result.to_a
|
@@ -101,28 +96,36 @@ end
|
|
101
96
|
class ExplainTool < ExplainBaseTool
|
102
97
|
description "EXPLAIN a query. It must be an SQL string, without the EXPLAIN prefix"
|
103
98
|
|
99
|
+
arguments do
|
100
|
+
required(:sql_query).filled(:string).description("The SQL query to debug")
|
101
|
+
end
|
102
|
+
|
104
103
|
def self.name
|
105
104
|
"explain"
|
106
105
|
end
|
107
106
|
|
108
|
-
def call(
|
109
|
-
if
|
107
|
+
def call(sql_query:)
|
108
|
+
if sql_query.downcase.include?("analyze")
|
110
109
|
raise "This query is not allowed. It contains a denied ANALYZE keyword."
|
111
110
|
end
|
112
111
|
|
113
|
-
super(
|
112
|
+
super(sql_query: "EXPLAIN #{sql_query}")
|
114
113
|
end
|
115
114
|
end
|
116
115
|
|
117
116
|
class ExplainAnalyzeTool < ExplainBaseTool
|
118
117
|
description "EXPLAIN ANALYZE a query. It must be an SQL string, without the EXPLAIN ANALYZE prefix"
|
119
118
|
|
119
|
+
arguments do
|
120
|
+
required(:sql_query).filled(:string).description("The SQL query to debug")
|
121
|
+
end
|
122
|
+
|
120
123
|
def self.name
|
121
124
|
"explain_analyze"
|
122
125
|
end
|
123
126
|
|
124
|
-
def call(
|
125
|
-
super(
|
127
|
+
def call(sql_query:)
|
128
|
+
super(sql_query: "EXPLAIN ANALYZE #{sql_query}")
|
126
129
|
end
|
127
130
|
end
|
128
131
|
|
@@ -152,6 +155,10 @@ class TableInfoTool < FastMcp::Tool
|
|
152
155
|
def call(table_name:)
|
153
156
|
RailsPgExtras.table_info(args: { table_name: table_name }, in_format: :hash)
|
154
157
|
end
|
158
|
+
|
159
|
+
def self.name
|
160
|
+
"table_info"
|
161
|
+
end
|
155
162
|
end
|
156
163
|
|
157
164
|
class TableSchemaTool < FastMcp::Tool
|