rails-pg-extras-mcp 0.2.3 → 0.2.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 72d363ce5cf74c8c22e8a636c3b908f27be10cc5a21691acd480b791ab9e8c33
4
- data.tar.gz: 36f3cb7fd5c1784c727def8ea7ad4c6f572f21c301ce99440440e4d5843f1e62
3
+ metadata.gz: 1b4509d036ac44d7408f298e5809c97517b938a17b767b495ecc49a6829030dd
4
+ data.tar.gz: 4de56739fdb9f9a55246468c49389dd797a48f44fa140fd7928fbe0d67525701
5
5
  SHA512:
6
- metadata.gz: 5565add5c44d77aa22c20f238c5f87d1f6e537f03f2b1d40fee5a5bbde03ed46690d11ecfecdecf791d65c0d748a26eaae5940d8808163e2c335fc4bad3c29ef
7
- data.tar.gz: 8f7235f0b1e8ec213379c2f98895522ca54eed4c3c4912d7c5773a377fb9e0207a638ace52f235b7a6012161ed3f543afa565ecb5281e1f5fc3a7f09039f04b5
6
+ metadata.gz: 748259151e1174a0352136ae9168978b19beea269cae6fb56b72e4afd9a8f07e818394174f26b14e1737f6e4c461de8aa2fa527c476b61f7a0178ab1074d772a
7
+ data.tar.gz: 0e4ca375b7e0366cc2a3b08c10915576de3fe97b5fbf5f8ebb545e153ce14298a7d38adb6e6da0c69e1b3aa5056991d343678ebeeb75b52558ecb8566137bfa3
data/README.md CHANGED
@@ -67,7 +67,7 @@ You can enable them by setting the following `ENV` variables:
67
67
  `ENV['PG_EXTRAS_MCP_EXPLAIN_ENABLED'] = 'true'`
68
68
  `ENV['PG_EXTRAS_MCP_EXPLAIN_ANALYZE_ENABLED'] = 'true'`
69
69
 
70
- Enabling these features means that an LLM, can run arbitrary queries in your database. The execution context is wrapped in a transaction and rolled back, so, in theory, any data modification should not be possible. But it's advised to configure a read-only permission if you want to use these features. By specifying `ENV['RAILS_PG_EXTRAS_DATABASE_URL']` you can overwrite the default Rails ActiveRecord database connection to restrict an access scope.
70
+ Enabling these features means that an LLM, can run arbitrary queries in your database. The execution context is wrapped in a transaction and rolled back, so, in theory, any data modification should not be possible. But it's advised to configure a read-only permission if you want to use these features. By specifying `ENV['RAILS_PG_EXTRAS_MCP_DATABASE_URL']` you can overwrite the default Rails ActiveRecord database connection to restrict an access scope:
71
71
 
72
72
  ## Status
73
73
 
@@ -85,11 +85,18 @@ class ExplainBaseTool < FastMcp::Tool
85
85
  raise "This query is not allowed. It contains a denied keyword. Denylist: #{DENYLIST.join(", ")}"
86
86
  end
87
87
 
88
- connection.execute("BEGIN")
89
- result = connection.execute("#{sql_query}")
90
- connection.execute("ROLLBACK")
91
-
92
- result.to_a
88
+ # Prevent multiple queries in one request
89
+ sql_query = sql_query.gsub(/;/, "")
90
+
91
+ connection.execute("BEGIN;")
92
+ begin
93
+ result = connection.execute("#{sql_query}")
94
+ connection.execute("ROLLBACK;")
95
+ result.to_a
96
+ rescue => e
97
+ connection.execute("ROLLBACK;") rescue nil
98
+ raise e
99
+ end
93
100
  end
94
101
  end
95
102
 
@@ -222,6 +229,10 @@ module RailsPgExtrasMcp
222
229
  server.register_tools(ExplainAnalyzeTool) if ENV["PG_EXTRAS_MCP_EXPLAIN_ANALYZE_ENABLED"] == "true"
223
230
 
224
231
  server.register_resource(ReadmeResource)
232
+
233
+ if !ENV["RAILS_PG_EXTRAS_MCP_DATABASE_URL"].to_s.empty?
234
+ RailsPgExtras.database_url = ENV["RAILS_PG_EXTRAS_MCP_DATABASE_URL"]
235
+ end
225
236
  end
226
237
  end
227
238
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsPgExtrasMcp
4
- VERSION = "0.2.3"
4
+ VERSION = "0.2.5"
5
5
  end
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
15
15
  s.test_files = s.files.grep(%r{^(spec)/})
16
16
  s.require_paths = ["lib"]
17
17
  s.license = "MIT"
18
- s.add_dependency "rails-pg-extras", "~> 5.6"
18
+ s.add_dependency "rails-pg-extras", "~> 5.6.12"
19
19
  s.add_dependency "rails"
20
20
  s.add_dependency "fast-mcp"
21
21
  s.add_development_dependency "rake"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-pg-extras-mcp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - pawurb
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-07-12 00:00:00.000000000 Z
11
+ date: 2025-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails-pg-extras
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '5.6'
19
+ version: 5.6.12
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '5.6'
26
+ version: 5.6.12
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rails
29
29
  requirement: !ruby/object:Gem::Requirement