pg-connection-analysis

pg-connection-analysis is a skill for Claude Code, Codex from isdaniel/pgtuner_mcp. It costs 57 tokens per session (2,102 once invoked), scanned A, original, Apache-2.0.

A guide for analyzing how PostgreSQL, a database system, uses its client connections, including active sessions and sessions that are waiting or idle.

In plain words
What is it for?
Use it to inspect connection health, investigate connection saturation, and decide whether a connection pooler such as PgBouncer is needed.
Why use it?
It helps diagnose too many connections, connection leaks, refused connections, and memory pressure caused by each database connection.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/isdaniel/pgtuner_mcp/pg-connection-analysis
Any agent
npx skills add isdaniel/pgtuner_mcp --skill pg-connection-analysis
Clone the repo
git clone --depth 1 https://github.com/isdaniel/pgtuner_mcp

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for pg-connection-analysis

README.md
[![agentmods](https://agentmods.dev/badge/skills/isdaniel/pgtuner_mcp/pg-connection-analysis.svg)](https://agentmods.dev/skills/isdaniel/pgtuner_mcp/pg-connection-analysis)
Your own site
<a href="https://agentmods.dev/skills/isdaniel/pgtuner_mcp/pg-connection-analysis"><img src="https://agentmods.dev/badge/skills/isdaniel/pgtuner_mcp/pg-connection-analysis.svg" alt="Measured on agentmods" height="20"></a>
Per session 57 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,102 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00057 $0.02102
Opus 5 $0.00028 $0.01051
Sonnet 5 $0.00011 $0.00420
Haiku 4.5 $0.00006 $0.00210

Measured 5d ago against content hash 71fb6231ee27, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-05, from the pricing page.

Security

Grade A, and why

pg-connection-analysis scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/pg-connection-analysis/SKILL.md · 249 lines

How it starts

The opening of the file, as written. The whole thing — 249 lines — stays where its author put it; the contents beside it link to each section on GitHub.

PostgreSQL Connection Analysis

This skill guides analysis and optimization of PostgreSQL connection usage using pgtuner-mcp tools.

When to Use This Skill

Use this skill when the user:

  • Reports "too many connections" errors or connection refused
  • Asks about connection pooling or PgBouncer setup
  • Sees high connection counts in monitoring
  • Reports idle connections consuming resources
  • Asks "how many connections is my database using?" or "do I need a connection pooler?"
  • Reports memory pressure related to per-connection overhead

MCP Resources Available

  • pgtuner://health/connections -- Quick connection utilization check (lightweight)
  • pgtuner://settings/connections -- Connection-related configuration

This skill supplements the health_check MCP Prompt's connection dimension.

Prerequisites

  • The pgtuner-mcp server must be connected with a valid DATABASE_URI

Agent Decision Tree

What is the user's symptom?
  |
  +--> "Too many connections / connection refused"
  |    --> Start with Step 1 (Connection State Breakdown), urgent
  |
  +--> "Should I use connection pooling?"
  |    --> Start with Step 1, then Step 3 (Pooling Analysis)
  |
  +--> "Idle connections eating memory"
  |    --> Start with Step 1 (focus on idle), then Step 4 (Configuration)
  |
  +--> "General connection health question"
       --> Start with Quick Check (MCP Resource), then Step 1 if needed

Connection Analysis Workflow

Quick Check: Use MCP Resource First

Before running full tool queries, the agent can read the lightweight resource:

Read resource: pgtuner://health/connections

This provides the connection utilization ratio without running the full health check tool. If this shows > 80% utilization, proceed with the full workflow.

Step 1: Connection State Breakdown

Tool: get_active_queries
Parameters:
  include_idle: true
  include_system: true
  min_duration_seconds: 0

Categorize all connections:

Read the full file on GitHub · 249 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 5d ago First seen · 249 lines · 57 tokens per session scan A 71fb6231ee27

Subscribe to this mod's changes

pg-connection-analysis is a skill published in the GitHub repository isdaniel/pgtuner_mcp (28 stars, last pushed 3mo ago), licensed Apache-2.0. It adds 57 tokens to every session and 2,102 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.