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 +4 -4
- data/README.md +6 -1
- data/lib/rails-pg-extras-mcp.rb +50 -5
- 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: 6544b81c0de61c0ac92c52514874ec1672990525739d3ae4fe989d2f8f88f4eb
|
4
|
+
data.tar.gz: d9c1d471162694594c59165864ba48a2cd7bfcf0741e1dca4bd9246b769ea138
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
|
data/lib/rails-pg-extras-mcp.rb
CHANGED
@@ -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
|
-
|
161
|
-
|
162
|
-
|
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
|