rails-pg-extras-mcp 0.1.0 → 0.1.1

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: e8d771e114f631fe7a9708fca02ae9466ab30a3da437ad14bf2085ec3a723592
4
- data.tar.gz: e96491dbe241a9bb66484e8bc9088cdb1d933f09ae62a1d89d9b65b44e5ebad5
3
+ metadata.gz: 4b1051245810be2fecf8e867a4d310f92afb59428b99946191a1e206cf5b44a0
4
+ data.tar.gz: 36da9617db4420bdc098e9562ddd5ae521b57b08bea97737a079cf1cae0e31c8
5
5
  SHA512:
6
- metadata.gz: 9aefce0884fb505759dcaafbadbfdbcf821826400273c74f20a1a5d8a69cc41e81d4130789f5b07f36cb5b526e75c2c6b01ac6356562f78233769de582403221
7
- data.tar.gz: 0ec7f68987e6ee2e358745827d060e2723f9f68c53cdf2232b051ad6d723d8f873e325acbe52a1e46d2c0e6df9945a376abecab2dd93a75666045e4f57763891
6
+ metadata.gz: 16765fe32563b12c1a8b2d7136c8f4a32556caafc52d223060c7af000b71fc747329e1e4a7296aafb73ba218b9aa57ae5a72aedcad1ebc68bc3ed9a03cbb5146
7
+ data.tar.gz: 2d0c7c8f2cb2317d02621752f6d82cadfd6c7ed82b364529bf15a6f5cf37c9f1f54ef7e13316139db8173a7f09562086afa626643d4cb6f5e4aca28be005b1f7
data/README.md CHANGED
@@ -16,10 +16,15 @@ The library supports MCP protocol via HTTP SSE interface.
16
16
  `config/routes.rb`
17
17
 
18
18
  ```ruby
19
- # Authentication is not yet supported
20
19
  mount RailsPgExtras.mcp_app, at: "pg-extras-mcp"
21
20
  ```
22
21
 
22
+ with optional authorization:
23
+
24
+ ```ruby
25
+ mount RailsPgExtras.mcp_app(auth_token: "secret"), at: "pg-extras-mcp"
26
+ ```
27
+
23
28
  Install [mcp-remote](https://github.com/geelen/mcp-remote):
24
29
 
25
30
  ```bash
@@ -35,7 +40,9 @@ and in your LLM of choice:
35
40
  "command": "npx",
36
41
  "args": [
37
42
  "mcp-remote",
38
- "http://localhost:3000/pg-extras-mcp/sse"
43
+ "http://localhost:3000/pg-extras-mcp/sse",
44
+ "--header",
45
+ "Authorization: secret"
39
46
  ]
40
47
  }
41
48
  }
@@ -75,6 +75,7 @@ class ExplainBaseTool < FastMcp::Tool
75
75
  grant,
76
76
  begin,
77
77
  commit,
78
+ ;
78
79
  ]
79
80
 
80
81
  arguments do
@@ -104,6 +105,10 @@ class ExplainTool < ExplainBaseTool
104
105
  end
105
106
 
106
107
  def call(query:)
108
+ if query.downcase.include?("analyze")
109
+ raise "This query is not allowed. It contains a denied ANALYZE keyword."
110
+ end
111
+
107
112
  super(query: "EXPLAIN #{query}")
108
113
  end
109
114
  end
@@ -133,19 +138,29 @@ end
133
138
 
134
139
  module RailsPgExtrasMcp
135
140
  class App
136
- def self.build
141
+ def self.build(auth_token: nil)
137
142
  app = lambda do |_env|
138
143
  [200, { "Content-Type" => "text/html" },
139
144
  ["<html><body><h1>Hello from Rack!</h1><p>This is a simple Rack app with MCP middleware.</p></body></html>"]]
140
145
  end
141
146
 
142
- # Create the MCP middleware
143
- mcp_app = FastMcp.rack_middleware(
144
- app,
145
- name: "rails-pg-extras-mcp", version: RailsPgExtrasMcp::VERSION,
147
+ opts = {
148
+ name: "rails-pg-extras-mcp",
149
+ version: RailsPgExtrasMcp::VERSION,
146
150
  path_prefix: "/pg-extras-mcp",
147
151
  logger: Logger.new($stdout),
148
- ) do |server|
152
+ }
153
+
154
+ if auth_token.present?
155
+ opts[:auth_token] = auth_token
156
+ end
157
+
158
+ rack_method_name = auth_token.present? ? :authenticated_rack_middleware : :rack_middleware
159
+
160
+ # Create the MCP middleware
161
+ mcp_app = FastMcp.public_send(rack_method_name,
162
+ app,
163
+ **opts) do |server|
149
164
  server.register_tools(DiagnoseTool)
150
165
  server.register_tools(MissingFkConstraintsTool)
151
166
  server.register_tools(MissingFkIndexesTool)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsPgExtrasMcp
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
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.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - pawurb
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-06-21 00:00:00.000000000 Z
11
+ date: 2025-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails-pg-extras