rails-pg-extras-mcp 0.2.0 → 0.2.2

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: 7f644d2d5e6698d7c3e2816aa56a256ac6b150114fa618c00b60d22db2f60bfd
4
- data.tar.gz: 96f81ed50933097a54261932c517161dca4fd5f55471e1c8c5d9248c5de48217
3
+ metadata.gz: 6544b81c0de61c0ac92c52514874ec1672990525739d3ae4fe989d2f8f88f4eb
4
+ data.tar.gz: d9c1d471162694594c59165864ba48a2cd7bfcf0741e1dca4bd9246b769ea138
5
5
  SHA512:
6
- metadata.gz: 74c540154d4a2566c84aeb1af65e1ec02b7f3b398c6564c202eb0b1db7ca2d502925415c1784430aaf099b5983d940a4b43e4e6f50ac1980409741e6062e2221
7
- data.tar.gz: 648c78c14b9d85a3c9ae6ed10187125c29bf569ff43efdb2a742cce53fa88053faa21e94b37db1211383ef08426f3f11d73da0a9a31d4a1c5443967f41db09ae
6
+ metadata.gz: 950732591722d121efe13ee44003c6573dc5bbbedf7df3476c71324aa9b6dc9c26ff5c55fc4e7714ae4d34ae674d7e7f7f3cc48cdfc11ebf592145b56c601b6f
7
+ data.tar.gz: 9024824533e151b01dc9150f4daa850ac0b0cbbfb875ebf34bdce8a1a03d65c45125b6094f1cb61ab6cbf843cf537531e81a9db53b6d9f6137d16952ff1ff6c3
data/README.md CHANGED
@@ -25,7 +25,12 @@ opts = { auth_token: "secret" }
25
25
  mount RailsPgExtrasMcp::App.build(opts), at: "pg_extras_mcp"
26
26
  ```
27
27
 
28
- Refer to the [fast-mcp docs](https://github.com/yjacquin/fast-mcp) for a complete list of supported options (the `opts` hash is passed directly as-is). For real-world deployments, you'll likely need to configure the `:allowed_origins` setting.
28
+ Refer to the [fast-mcp docs](https://github.com/yjacquin/fast-mcp) for a complete list of supported options (the `opts` hash is passed directly as-is). For production deployments, you'll likely need a similar config:
29
+
30
+ ```ruby
31
+ opts = { allowed_origins: [ /.*./ ], allowed_ips: [ "*" ], auth_token: "secret", localhost_only: false }
32
+ mount RailsPgExtrasMcp::App.build(opts) at: "pg_extras_mcp"
33
+ ```
29
34
 
30
35
  Next, install [mcp-remote](https://github.com/geelen/mcp-remote):
31
36
 
@@ -126,6 +126,50 @@ class ExplainAnalyzeTool < ExplainBaseTool
126
126
  end
127
127
  end
128
128
 
129
+ class IndexInfoTool < FastMcp::Tool
130
+ description "Shows information about table indexes: name, table name, columns, index size, index scans, null frac"
131
+
132
+ arguments do
133
+ required(:table_name).filled(:string).description("The table name to get index info for")
134
+ end
135
+
136
+ def call(table_name:)
137
+ RailsPgExtras.index_info(args: { table_name: table_name }, in_format: :hash)
138
+ end
139
+
140
+ def self.name
141
+ "index_info"
142
+ end
143
+ end
144
+
145
+ class TableInfoTool < FastMcp::Tool
146
+ description "Shows information about a table: name, size, cache hit, estimated rows, sequential scans, indexes scans"
147
+
148
+ arguments do
149
+ required(:table_name).filled(:string).description("The table name to get info for")
150
+ end
151
+
152
+ def call(table_name:)
153
+ RailsPgExtras.table_info(args: { table_name: table_name }, in_format: :hash)
154
+ end
155
+ end
156
+
157
+ class TableSchemaTool < FastMcp::Tool
158
+ description "Shows the schema of a table"
159
+
160
+ arguments do
161
+ required(:table_name).filled(:string).description("The table name to get schema for")
162
+ end
163
+
164
+ def call(table_name:)
165
+ RailsPgExtras.table_schema(args: { table_name: table_name }, in_format: :hash)
166
+ end
167
+
168
+ def self.name
169
+ "table_schema"
170
+ end
171
+ end
172
+
129
173
  class ReadmeResource < FastMcp::Resource
130
174
  uri "https://raw.githubusercontent.com/pawurb/rails-pg-extras/refs/heads/main/README.md"
131
175
  resource_name "README"
@@ -157,19 +201,20 @@ module RailsPgExtrasMcp
157
201
  rack_method_name = opts[:auth_token].present? ? :authenticated_rack_middleware : :rack_middleware
158
202
 
159
203
  # Create the MCP middleware
160
- mcp_app = FastMcp.public_send(rack_method_name,
161
- app,
162
- **opts) do |server|
204
+ FastMcp.public_send(rack_method_name,
205
+ app,
206
+ **opts) do |server|
163
207
  server.register_tools(DiagnoseTool)
164
208
  server.register_tools(MissingFkConstraintsTool)
165
209
  server.register_tools(MissingFkIndexesTool)
210
+ server.register_tools(IndexInfoTool)
211
+ server.register_tools(TableInfoTool)
212
+ server.register_tools(TableSchemaTool)
166
213
  server.register_tools(*QUERY_TOOL_CLASSES)
167
214
  server.register_tools(ExplainTool) if ENV["PG_EXTRAS_MCP_EXPLAIN_ENABLED"] == "true"
168
215
  server.register_tools(ExplainAnalyzeTool) if ENV["PG_EXTRAS_MCP_EXPLAIN_ANALYZE_ENABLED"] == "true"
169
216
 
170
217
  server.register_resource(ReadmeResource)
171
-
172
- Rack::Builder.new { run mcp_app }
173
218
  end
174
219
  end
175
220
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsPgExtrasMcp
4
- VERSION = "0.2.0"
4
+ VERSION = "0.2.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-pg-extras-mcp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - pawurb