Rails PG Extras MCP logo

Rails PG Extras MCP

Community
pawurb

MCP (Model Context Protocol) LLM interface for rails-pg-extras gem

Publisherpawurb
Repositoryrails-pg-extras-mcp
LanguageRuby
Forks
1
Stars
29
Available tools
0
Transport typestdio, streamable-http
Categories
LicenseMIT
Links
  • Connect tools to AI workflows

    Rails PG Extras MCP exposes MCP capabilities that can be used by compatible AI clients and agents.

  • 0 available tools

    Browse the callable actions below, including names and descriptions when provided by the server.

  • Ready-to-copy setup

    Use the installation snippets to configure this server in your preferred MCP client.

  • Open source signals

    29 stars and 1 forks from the linked repository.

Rails PG Extras MCP Gem Version GH Actions

MCP (Model Context Protocol) interface for rails-pg-extras gem. Easily explore PostgreSQL metadata and debug performance issues. Check for table bloat, slow queries, unused indexes, and more. Run EXPLAIN ANALYZE on bottlenecks and get clear, LLM-powered insights to optimize your database.

Use a minimally privileged, read-only user to eliminate the risk of data modification or exposure.

Check out this post for more in-depth info on the project.

LLM interface

Installation

bash
bundle add rails-pg-extras-mcp

The library supports MCP protocol via HTTP SSE interface.

config/routes.rb

ruby
mount RailsPgExtrasMcp::App.build, at: "pg_extras_mcp"

with optional authorization:

ruby
opts = { auth_token: "secret" }
mount RailsPgExtrasMcp::App.build(opts), at: "pg_extras_mcp"

Refer to the fast-mcp docs 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:

ruby
opts = { allowed_origins: [ /.*./ ], allowed_ips: [ "*" ], auth_token: "secret", localhost_only: false }
mount RailsPgExtrasMcp::App.build(opts) at: "pg_extras_mcp"

Next, install mcp-remote:

bash
npm install -g mcp-remote

and in your LLM of choice:

json
{
  "mcpServers": {
    "pg-extras": {
      "command": "npx",
      "args": [
        "mcp-remote",
        "http://localhost:3000/pg_extras_mcp/sse",
        "--header",
        "Authorization: secret"
      ]
    }
  }
}

You can now ask LLM questions about the metadata and performance metrics of your database.

Optional EXPLAIN ANALYZE support

calls and outliers methods return a list of bottleneck queries. LLM can get better insights into these queries by performing EXPLAIN and EXPLAIN ANALYZE analysis. MCP server exposes two optional methods for this purpose: explain and explain_analyze.

You can enable them by setting the following ENV variables:

ENV['PG_EXTRAS_MCP_EXPLAIN_ENABLED'] = 'true' ENV['PG_EXTRAS_MCP_EXPLAIN_ANALYZE_ENABLED'] = 'true'

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:

Least responsibility

If you're not planing to use EXPLAIN ANALYZE features, you should configure a user with read access only to the metadata tables:

sql
CREATE ROLE extras_viewer NOLOGIN;
CREATE USER extras_user WITH PASSWORD 'your_password';
GRANT extras_viewer TO extras_user;

GRANT CONNECT ON DATABASE your_db_name TO extras_user;
GRANT USAGE ON SCHEMA public TO extras_user;

GRANT SELECT ON pg_stat_statements TO extras_user;
GRANT SELECT ON pg_stat_activity, pg_locks TO extras_user;
GRANT SELECT ON pg_stat_user_indexes, pg_index TO extras_user;
GRANT SELECT ON pg_stat_all_tables, pg_stat_database, pg_settings, pg_namespace TO extras_user;

GRANT EXECUTE ON FUNCTION pg_relation_size(regclass) TO extras_user;
GRANT EXECUTE ON FUNCTION pg_indexes_size(regclass) TO extras_user;
GRANT EXECUTE ON FUNCTION pg_table_size(regclass) TO extras_user;
GRANT EXECUTE ON FUNCTION pg_total_relation_size(regclass) TO extras_user;

You can ask an LLM to check which db user it's connected with using connections tool.

Status

The project is in an early beta, so proceed with caution.

Installation

TypingMind
Prerequisites:

Node.js 18+

{
  "mcpServers": {
    "pawurb-rails-pg-extras-mcp": {
      "command": "",
      "args": []
    }
  }
}

Use Rails PG Extras MCP MCP with multiple AI models

TypingMind connects MCP tools at the workspace level, so once Rails PG Extras MCP is connected, you can use it with different AI models in TypingMind instead of setting it up separately for each model. You can run MCP locally on your device or connect to a remote MCP server URL.

Option 1: Use the local connector

Use this when the MCP server needs access to local files, apps, or private resources on your computer.

1

Open the MCP settings

In TypingMind, go to Settings, Advanced Settings, then Model Context Protocol and choose Setup Connector.

  1. Open TypingMind in your browser.
  2. Click the Settings icon.
  3. Go to Advanced Settings.
  4. Open the Model Context Protocol section.
  5. Click Setup Connector and choose This Device.
TypingMind MCP connector setup screen with This Device selected
2

Run the connector command

Choose This Device, copy the command from TypingMind, and run it in Terminal. Keep the process running while you use MCP.

  1. Copy the setup command shown by TypingMind.
  2. Open Terminal on macOS or Windows Terminal on Windows.
  3. Paste and run the command.
  4. Approve the package install if Terminal asks you to proceed.
  5. Keep the Terminal window running while using MCP tools.
3

Add Rails PG Extras MCP as a server

When the connector status is Ready, click Edit Servers and paste the MCP server configuration.

  1. Wait until the connector status shows Ready.
  2. Click Edit Servers.
  3. Paste the Rails PG Extras MCP MCP server configuration.
  4. Save the server list.
  5. Refresh if you want to confirm the connector is still ready.
TypingMind MCP settings showing active server and Edit Servers button
{
  "mcpServers": {
    "pawurb-rails-pg-extras-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "rails-pg-extras-mcp"
      ]
    }
  }
}
4

Use it across models

Save the server list, open Plugins, enable the Rails PG Extras MCP MCP tools, then select any supported AI model in TypingMind and use the tools in chat or assign them to an AI agent.

  1. Open the Plugins page in TypingMind.
  2. Enable the Rails PG Extras MCP MCP tools.
  3. Start a chat and choose the AI model you want to use.
  4. Use the MCP tools in chat or assign them to an AI agent.
  5. Switch to another AI model whenever needed without reconnecting MCP.
TypingMind chat using enabled MCP tools with a selected AI model
Can you use Rails PG Extras MCP to help me with this task?
Rails PG Extras MCP
Sure. I read it.
Here is what I found using Rails PG Extras MCP.

Option 2: Add an MCP server URL

Use this when Rails PG Extras MCP is already hosted remotely or your team wants one shared connector that multiple users can access.

1

Open MCP connectors

In TypingMind, go to Plugins, open MCP connectors, then choose Add URL.

  1. Open TypingMind in your browser.
  2. Go to Plugins.
  3. Open MCP connectors.
  4. Click Add URL.
TypingMind Add Custom MCP Server URL form
2

Paste the server URL

Enter your server URL in the Server URL field. Add a connection name, description, icon, custom HTTP headers, or OAuth client settings if the server requires them.

  1. Paste your server URL into the Server URL field.
  2. Enter a connection name for Rails PG Extras MCP.
  3. Add a description and icon if you want it to be easier to identify.
  4. Add custom HTTP headers or OAuth client details if the server requires authentication.
3

Create the connection

Click Create connection, then return to the Plugins list and confirm the new MCP connection is active.

  1. Click Create connection.
  2. Return to the MCP connectors list.
  3. Confirm the Rails PG Extras MCP connection appears as active.
  4. Refresh the plugin list if the connection does not appear immediately.
4

Switch models without reconnecting

Start a chat with your preferred model, enable the Rails PG Extras MCP tools from Plugins, and switch to another model whenever needed. The MCP connection stays available to the TypingMind workspace.

  1. Start a new chat in TypingMind.
  2. Select the AI model you want to use.
  3. Enable the Rails PG Extras MCP tools from Plugins.
  4. Ask the model to use the tool when needed.
  5. Switch to another AI model and reuse the same MCP connection.
TypingMind chat using enabled MCP tools with a selected AI model
Can you use Rails PG Extras MCP to help me with this task?
Rails PG Extras MCP
Sure. I read it.
Here is what I found using Rails PG Extras MCP.

Frequently asked questions

What is the Rails PG Extras MCP MCP server used for?

Rails PG Extras MCP is an MCP server that lets compatible AI clients connect to external tools and context. In TypingMind, you can add this MCP server once and make its tools available in your AI workspace.

Can I use Rails PG Extras MCP MCP with multiple AI models in TypingMind?

Yes. TypingMind connects MCP tools at the workspace level, so you can use Rails PG Extras MCP with different AI models such as Claude, ChatGPT, Gemini, or other models you have configured in TypingMind without setting up the MCP server separately for each model.

Why use Rails PG Extras MCP MCP with TypingMind?

TypingMind is one of the best frontends for LLM chat because it brings multiple AI models, prompts, plugins, AI agents, API keys, and MCP tools into one workspace. With Rails PG Extras MCP connected, you can use its MCP tools across your preferred models while keeping your chat workflow organized in TypingMind.

How do I connect Rails PG Extras MCP MCP to TypingMind?

Rails PG Extras MCP can be connected in TypingMind with the local MCP connector or by adding a remote MCP server URL. Use the local connector when the server needs access to files, apps, or private resources on your device, and use a server URL when the MCP server is hosted remotely.

What tools does Rails PG Extras MCP MCP provide in TypingMind?

Rails PG Extras MCP exposes MCP capabilities that can be enabled from the TypingMind Plugins page and used in chat or assigned to AI agents.

Do I need to share my API keys with TypingMind to use Rails PG Extras MCP MCP?

No. TypingMind is local-first and lets you keep your model providers, API keys, prompts, and MCP configuration under your control. If Rails PG Extras MCP requires authentication, add the required headers, OAuth settings, or local configuration for that MCP server when you create the connection.

Related MCP Servers

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇