PostgreSQL performance Tuner MCP Server
ภาพรวม
คำอธิบายจากผู้ทำ (ภาษาอังกฤษตามต้นฉบับ)
provides AI-powered PostgreSQL performance tuning capabilities.
ใช้ทำอะไรได้
ตัวนี้ยังไม่ได้เรียบเรียงเป็นภาษาไทย ด้านล่างคือข้อเท็จจริงที่เราอ่านจาก registry
- การเชื่อมต่อ: รันบนเครื่อง
- ช่องทาง (transport): stdio
- หมวด: ฐานข้อมูลและชุดข้อมูล
ติดตั้ง
เลือกโปรแกรม AI ที่คุณใช้ แล้วคัดลอกค่าตั้งไปวาง
ผลตรวจผ่าน 2/2 · ทำงานบนเครื่องคุณ
ขั้นแรก: คุณใช้ AI ตัวไหน
เลือกแอปที่คุณใช้ ขั้นตอนจะขึ้นด้านล่าง
ต่อกับ Claude ได้ แต่ต้องเตรียมก่อน
ต้องลง Python (uv) ในเครื่องก่อน (ทำครั้งเดียว) · ใช้ได้เฉพาะแอป Claude บนคอม (Windows หรือ Mac) ไม่ใช่บนเว็บหรือมือถือ
ลง Python (uv) ในเครื่อง
ทำครั้งเดียว ใช้ได้กับทุกตัวที่ต้องใช้ Python (uv)
เปิดไฟล์ตั้งค่าของแอป Claude บนคอม
SettingsDeveloperEdit Config
วางค่าตั้งนี้แล้วบันทึกไฟล์
{ "mcpServers": { "pgtuner": { "command": "uvx", "args": [ "pgtuner-mcp" ] } } }ปิดแอป Claude แล้วเปิดใหม่
ลองเลย
ใช้ PostgreSQL performance Tuner MCP Server บอกหน่อยว่าทำอะไรให้ฉันได้บ้าง แล้วลองทำให้ดูหนึ่งอย่าง✓ ถ้า Claude บอกว่ากำลังใช้ PostgreSQL performance Tuner MCP Server หรือมีชื่อเครื่องมือของ PostgreSQL performance Tuner MCP Server ขึ้นในคำตอบ แปลว่าต่อสำเร็จ
ชื่อเมนูตรวจกับหน้าช่วยเหลือของ Anthropic เมื่อ 11 พ.ย. 2569 · หน้าจอของคุณอาจต่างเล็กน้อยตามรุ่นของแอป
ChatGPT ยังต่อ PostgreSQL performance Tuner MCP Server ไม่ได้
PostgreSQL performance Tuner MCP Server ต้องติดตั้งในเครื่องคุณ แต่ ChatGPT ต่อได้เฉพาะตัวที่ทำงานบนเว็บ
คุณทำแบบนี้แทนได้
ก · ใช้แอปที่ต่อ PostgreSQL performance Tuner MCP Server ได้
- ต้องลง Python (uv) ในเครื่องก่อน (ทำครั้งเดียว) · ใช้ได้เฉพาะแอป Claude บนคอม (Windows หรือ Mac) ไม่ใช่บนเว็บหรือมือถือ
- ต้องลง Python (uv) ในเครื่องก่อน (ทำครั้งเดียว)
- ต้องลง Python (uv) ในเครื่องก่อน (ทำครั้งเดียว)
- ต้องลง Python (uv) ในเครื่องก่อน (ทำครั้งเดียว)
ข · ตัวอื่นในหมวด ฐานข้อมูลและชุดข้อมูล ที่ต่อกับ ChatGPT ได้
เลือกจากตัวที่ใช้มากในหมวดเดียวกัน เฉพาะตัวที่ต่อด้วยที่อยู่ได้โดยไม่ต้องใส่คีย์
- Supabase✓ ChatGPT
- Appwrite MCP✓ ChatGPT
- Pg Aiguide✓ ChatGPT
ต่อกับ Claude Code ได้ แต่ต้องเตรียมก่อน
ต้องลง Python (uv) ในเครื่องก่อน (ทำครั้งเดียว)
ลง Python (uv) ในเครื่อง
ทำครั้งเดียว ใช้ได้กับทุกตัวที่ต้องใช้ Python (uv)
เปิด Terminal
Mac: กด Command+Space พิมพ์ Terminal · Windows: เปิด PowerShell
วางคำสั่งนี้แล้วกด Enter
claude mcp add pgtuner -- uvx pgtuner-mcpพิมพ์ /mcp ใน Claude Code
ต้องเห็น PostgreSQL performance Tuner MCP Server ในรายการและขึ้นว่าเชื่อมต่อแล้ว
ลองเลย
ใช้ PostgreSQL performance Tuner MCP Server บอกหน่อยว่าทำอะไรให้ฉันได้บ้าง แล้วลองทำให้ดูหนึ่งอย่าง✓ ถ้า Claude Code บอกว่ากำลังใช้ PostgreSQL performance Tuner MCP Server หรือมีชื่อเครื่องมือของ PostgreSQL performance Tuner MCP Server ขึ้นในคำตอบ แปลว่าต่อสำเร็จ
ชื่อเมนูตรวจกับหน้าช่วยเหลือของ Anthropic เมื่อ 11 พ.ย. 2569 · หน้าจอของคุณอาจต่างเล็กน้อยตามรุ่นของแอป
ต่อกับ Cursor ได้ แต่ต้องเตรียมก่อน
ต้องลง Python (uv) ในเครื่องก่อน (ทำครั้งเดียว)
ลง Python (uv) ในเครื่อง
ทำครั้งเดียว ใช้ได้กับทุกตัวที่ต้องใช้ Python (uv)
เปิดแชตของ AI ใน Cursor โหมด Agent
ลองเลย
ใช้ PostgreSQL performance Tuner MCP Server บอกหน่อยว่าทำอะไรให้ฉันได้บ้าง แล้วลองทำให้ดูหนึ่งอย่าง✓ ถ้า Cursor บอกว่ากำลังใช้ PostgreSQL performance Tuner MCP Server หรือมีชื่อเครื่องมือของ PostgreSQL performance Tuner MCP Server ขึ้นในคำตอบ แปลว่าต่อสำเร็จ
ชื่อเมนูตรวจกับหน้าช่วยเหลือของ Cursor เมื่อ 11 พ.ย. 2569 · หน้าจอของคุณอาจต่างเล็กน้อยตามรุ่นของแอป
ต่อกับ VS Code ได้ แต่ต้องเตรียมก่อน
ต้องลง Python (uv) ในเครื่องก่อน (ทำครั้งเดียว)
ลง Python (uv) ในเครื่อง
ทำครั้งเดียว ใช้ได้กับทุกตัวที่ต้องใช้ Python (uv)
เปิดแชตของ AI ใน VS Code โหมด Agent
ลองเลย
ใช้ PostgreSQL performance Tuner MCP Server บอกหน่อยว่าทำอะไรให้ฉันได้บ้าง แล้วลองทำให้ดูหนึ่งอย่าง✓ ถ้า VS Code บอกว่ากำลังใช้ PostgreSQL performance Tuner MCP Server หรือมีชื่อเครื่องมือของ PostgreSQL performance Tuner MCP Server ขึ้นในคำตอบ แปลว่าต่อสำเร็จ
ชื่อเมนูตรวจกับหน้าช่วยเหลือของ VS Code เมื่อ 11 พ.ย. 2569 · หน้าจอของคุณอาจต่างเล็กน้อยตามรุ่นของแอป
โปรแกรมอื่นที่ใช้ MCP ได้ เช่น Windsurf, Zed หรือ Gemini CLI มีวิธีเพิ่มต่างกัน ดูวิธีของแต่ละตัวในหน้ารวมโปรแกรม
ค่าตั้งแบบไฟล์ JSON อยู่ในหัวข้อ “สำหรับคนเขียนโค้ด” ด้านล่าง
สำหรับคนเขียนโค้ด: คำสั่ง Terminal และค่าตั้ง JSON
ติดตั้งในเครื่อง
Claude Code
claude mcp add pgtuner -- uvx pgtuner-mcpClaude Desktop (claude_desktop_config.json)
{
"mcpServers": {
"pgtuner": {
"command": "uvx",
"args": [
"pgtuner-mcp"
]
}
}
}Cursor (~/.cursor/mcp.json)
{
"mcpServers": {
"pgtuner": {
"command": "uvx",
"args": [
"pgtuner-mcp"
]
}
}
}VS Code (mcp.json)
{
"servers": {
"pgtuner": {
"type": "stdio",
"command": "uvx",
"args": [
"pgtuner-mcp"
]
}
}
}ค่าตั้งนี้สร้างจากข้อมูลใน registry ของผู้ทำ ถ้าไม่ตรงกับ README ให้เชื่อ README
สรุป
- ดาวน์โหลดต่อสัปดาห์i
- 35/สัปดาห์
- การเชื่อมต่อ
- รันบนเครื่อง
- ช่องทาง (transport)
- stdio
- รุ่นล่าสุดi
- 0.5.2
- ส่งเข้า registryi
- 13 ธ.ค. 2568
- แก้โค้ดล่าสุดi
- 2 มิ.ย. 2569
- ผู้ทำ
- isdaniel
- แพ็กเกจ
pypi: pgtuner-mcp- สถานะใน registry
- ใช้งานอยู่
ใช้กับโปรแกรมไหนได้
ดูจากแบบการต่อของ server ตัวนี้ และเอกสารของผู้ทำโปรแกรมแต่ละตัว ตรวจเมื่อ 10 พ.ย. 2569
ติดตั้งบนเครื่องได้ใน
ClaudeGooseLM StudioMsty StudioCherry StudioCursorVS Code + GitHub CopilotVisual StudioWindsurf (Devin Desktop)ZedKiroClineContinueJetBrains AI AssistantClaude CodeCodex CLIGemini CLIOpenCodenodecodeWarpLibreChatRaycast
คู่มือที่เกี่ยวข้อง
ทำอะไรได้บ้าง
รันในเครื่องคุณ รายการเครื่องมือจะขึ้นในแอป AI หลังติดตั้ง
ผลตรวจเบื้องต้นi
เราตรวจจากข้อมูลที่ใครก็เปิดดูได้ ยังไม่ได้อ่านโค้ด ข้อที่ไม่เกี่ยวกับตัวนี้ไม่นับในตัวหาร · ตรวจเมื่อ 12 พ.ย. 2569
- ✓ ผ่าน
ตัวตนผู้ทำตรงกับ repo
ชื่อใน registry ยืนยันด้วยบัญชี GitHub isdaniel ซึ่งเป็นเจ้าของ repo
- ✓ ผ่าน
ยังมีคนดูแล
มีการแก้โค้ดล่าสุด 5 เดือนที่ผ่านมา
- … ยังไม่ตรวจ
มีสัญญาอนุญาต (license)
ยังไม่ได้อ่านข้อมูล repo จาก GitHub
- – ไม่เกี่ยว
endpoint ตอบ
ตัวนี้รันบนเครื่องคุณ ไม่มี endpoint บนอินเทอร์เน็ต
- – ไม่เกี่ยว
ล็อกอินแบบ OAuth
ตัวนี้รันบนเครื่อง ใช้ค่าที่ตั้งในเครื่องแทน
- … ยังไม่ตรวจ
คำอธิบายเครื่องมือไม่มีคำสั่งแอบแฝง
รันในเครื่องคุณ เราอ่านรายการเครื่องมือได้เฉพาะตัวที่มี endpoint บนอินเทอร์เน็ต
พูดคุย
ถาม แชร์เคล็ดลับ หรือแจ้งว่าใช้ไม่ได้ เรียงตามที่คนกดว่ามีประโยชน์
ยังไม่มีใครโพสต์ ถามหรือแชร์เป็นคนแรกได้เลย
ข้อความในส่วนนี้เขียนโดยผู้ใช้ ไม่ใช่ทีม PopNx
รีวิวจากผู้ใช้
ยังไม่มีรีวิว
เทียบกับตัวอื่นในหมวด ฐานข้อมูลและชุดข้อมูลi
- ดาวมากกว่า 96% ของอีก 1168 ตัวในหมวดนี้
- ส่งรุ่นใหม่เข้า registry ล่าสุดกว่า 2% ของอีก 1168 ตัวในหมวดนี้
- ผลตรวจเบื้องต้นดีกว่าหรือเท่ากับ 100% ของอีก 1168 ตัวในหมวดนี้
เทียบกับทุก server ที่ยังใช้งานในหมวดนี้ทั้งทะเบียน ดาวนับเฉพาะเมื่อผู้ลงทะเบียนเป็นเจ้าของ repo
คำถามที่พบบ่อย
PostgreSQL performance Tuner MCP Server ปลอดภัยไหม?
จากการตรวจเบื้องต้นของเรา ผ่าน 2 จาก 2 ข้อที่ตรวจได้ เรายังไม่ได้อ่านโค้ด ก่อนใส่กุญแจหรือ token ให้ดูว่า server ขอสิทธิ์อะไร และเลือกกุญแจที่ทำได้เท่าที่จำเป็น
ต้องใช้กุญแจหรือรหัสอะไรบ้าง?
registry ไม่ได้ระบุว่าต้องใช้กุญแจ แต่บางตัวจะขอให้ล็อกอินตอนใช้ครั้งแรก
ตัวนี้รันบนเครื่องหรือบนคลาวด์?
รันบนเครื่องของคุณ โปรแกรม AI จะเปิด server ขึ้นมาเองเมื่อใช้ ข้อมูลไม่ต้องผ่านเซิร์ฟเวอร์ของผู้ทำ (ยกเว้นตัวที่ไปเรียกบริการออนไลน์ต่อ)
ยังมีคนดูแลอยู่ไหม?
repo บน GitHub มีการแก้โค้ดล่าสุด 5 เดือนที่ผ่านมา และส่งรุ่นล่าสุด (0.5.2) เข้า registry 11 เดือนที่ผ่านมา
ใช้กับโปรแกรมไหนได้บ้าง?
โปรแกรมที่รองรับ MCP เช่น Claude Desktop, Claude Code, Cursor และ VS Code ตัวนี้ต้องมี Python (uv) ในเครื่องด้วย
มีตัวไหนใช้แทนได้บ้าง?
ในหมวดเดียวกันมี Dbx, MCP Toolbox for Databases, MCP Toolbox for Databases
ตัวที่ใช้แทนได้
server หมวดเดียวกันจากผู้ทำคนอื่น เรียงตามดาว
อ่านการ์ด:↓ ดาวน์โหลดต่อสัปดาห์i★ ดาว GitHubiสามเสา: รีวิว · ผลตรวจ · การใช้งานiอัปเดต = วันที่ส่งรุ่นล่าสุดเข้า registryi
MCP Toolbox for Databases
MCP Toolbox for Databases enables your agent to connect to your database.
MCP Toolbox for Databases
MCP Toolbox for Databases enables your agent to connect to your database.
README จากผู้ทำ
เปิดอ่าน README
ส่วนนี้คัดจาก repo ของผู้ทำตามต้นฉบับ PopNx MCP ไม่ได้ตรวจหรือรับรองเนื้อหา ตัด HTML รูปภาพ และสคริปต์ออกแล้ว ลิงก์จะพาออกนอกเว็บ
PostgreSQL Performance Tuning MCP
A Model Context Protocol (MCP) server that provides AI-powered PostgreSQL performance tuning capabilities. This server helps identify slow queries, recommend optimal indexes, analyze execution plans, and leverage HypoPG for hypothetical index testing.
Features
Query Analysis
- Retrieve slow queries from
pg_stat_statementswith detailed statistics - Analyze query execution plans with
EXPLAINandEXPLAIN ANALYZE - Identify performance bottlenecks with automated plan analysis
- Monitor active queries and detect long-running transactions
Index Tuning
- AI-powered index recommendations based on query workload analysis
- Hypothetical index testing with HypoPG extension (no disk usage)
- Find unused and duplicate indexes for cleanup
- Estimate index sizes before creation
- Test query plans with proposed indexes before implementing
Database Health
- Comprehensive health scoring with multiple checks
- Connection utilization monitoring
- Cache hit ratio analysis (buffer and index)
- Lock contention detection
- Vacuum health and transaction ID wraparound monitoring
- Replication lag monitoring
- Background writer and checkpoint analysis
Vacuum Monitoring
- Track long-running VACUUM and VACUUM FULL operations in real-time
- Monitor autovacuum progress and performance
- Identify tables that need vacuuming
- View recent vacuum activity history
- Analyze autovacuum configuration effectiveness
I/O Performance Analysis
- Analyze disk read/write patterns across tables and indexes
- Identify I/O bottlenecks and hot tables
- Monitor buffer cache hit ratios
- Track temporary file usage indicating work_mem issues
- Analyze checkpoint and background writer I/O
- PostgreSQL 16+ enhanced pg_stat_io metrics support
Configuration Analysis
- Review PostgreSQL settings by category
- Get recommendations for memory, checkpoint, WAL, autovacuum, and connection settings
- Identify suboptimal configurations
MCP Prompts & Resources
- Pre-defined prompt templates for common tuning workflows
- Dynamic resources for table stats, index info, and health checks
- Comprehensive documentation resources
Installation
Standard Installation (for MCP clients like Claude Desktop)
pip install pgtuner_mcp
Or using uv:
uv pip install pgtuner_mcp
Manual Installation
git clone https://github.com/isdaniel/pgtuner_mcp.git
cd pgtuner_mcp pip install -e .
Configuration
Environment Variables
| Variable | Description | Required |
|---|---|---|
DATABASE_URI | PostgreSQL connection string | Yes |
PGTUNER_EXCLUDE_USERIDS | Comma-separated list of user IDs (OIDs) to exclude from monitoring | No |
PGTUNER_STATEMENT_TIMEOUT_MS | Per-statement timeout in ms (default 30000, 0=disable) | No |
PGTUNER_IDLE_TXN_TIMEOUT_MS | Idle-in-txn timeout in ms (default 60000) | No |
PGTUNER_LOCK_TIMEOUT_MS | Lock timeout in ms (default 5000) | No |
PGTUNER_CORS_ALLOW_ORIGINS | Comma-separated CORS allowlist; * for all | No |
PGTUNER_LINT_DISABLED_RULES | Comma-separated rule IDs to disable in linter | No |
Connection String Format: postgresql://user:password@host:port/database
Minimal User Permissions
To run this MCP server, the PostgreSQL user requires specific permissions to query system catalogs and extensions. Below are the minimal permissions needed for different feature sets.
Basic Permissions (Required for Core Functionality)
-- Create a dedicated monitoring user
CREATE USER pgtuner_monitor WITH PASSWORD 'secure_password';
-- Grant connection to the target database GRANT CONNECT ON DATABASE your_database TO pgtuner_monitor;
-- Grant usage on schemas GRANT USAGE ON SCHEMA public TO pgtuner_monitor; GRANT USAGE ON SCHEMA pg_catalog TO pgtuner_monitor;
-- Grant SELECT on user tables and indexes (for table stats and analysis) GRANT SELECT ON ALL TABLES IN SCHEMA public TO pgtuner_monitor; ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO pgtuner_monitor;
-- Grant access to system catalog views (read-only) GRANT pg_read_all_stats TO pgtuner_monitor; -- PostgreSQL 10+
Extension-Specific Permissions
For pgstattuple (Bloat Detection):
-- Create the extension (requires superuser or appropriate privileges)
CREATE EXTENSION IF NOT EXISTS pgstattuple;
-- Grant execution on pgstattuple functions GRANT EXECUTE ON FUNCTION pgstattuple(regclass) TO pgtuner_monitor; GRANT EXECUTE ON FUNCTION pgstattuple_approx(regclass) TO pgtuner_monitor; GRANT EXECUTE ON FUNCTION pgstatindex(regclass) TO pgtuner_monitor; GRANT EXECUTE ON FUNCTION pgstatginindex(regclass) TO pgtuner_monitor; GRANT EXECUTE ON FUNCTION pgstathashindex(regclass) TO pgtuner_monitor;
-- Alternative: Use pg_stat_scan_tables role (PostgreSQL 14+) GRANT pg_stat_scan_tables TO pgtuner_monitor;
For HypoPG (Hypothetical Index Testing):
-- Create the extension (requires superuser or appropriate privileges)
CREATE EXTENSION IF NOT EXISTS hypopg;
-- Grant SELECT on HypoPG views GRANT SELECT ON hypopg_list_indexes TO pgtuner_monitor; GRANT SELECT ON hypopg_hidden_indexes TO pgtuner_monitor;
-- Grant execution on HypoPG functions with proper signatures GRANT EXECUTE ON FUNCTION hypopg_create_index(text) TO pgtuner_monitor; GRANT EXECUTE ON FUNCTION hypopg_drop_index(oid) TO pgtuner_monitor; GRANT EXECUTE ON FUNCTION hypopg_reset() TO pgtuner_monitor; GRANT EXECUTE ON FUNCTION hypopg_hide_index(oid) TO pgtuner_monitor; GRANT EXECUTE ON FUNCTION hypopg_unhide_index(oid) TO pgtuner_monitor; GRANT EXECUTE ON FUNCTION hypopg_relation_size(oid) TO pgtuner_monitor;
-- Note: HypoPG operations are session-scoped and don't affect the actual database
Complete Setup Script
-- 1. Create the monitoring user
CREATE USER pgtuner_monitor WITH PASSWORD 'secure_password';
-- 2. Grant connection and schema access GRANT CONNECT ON DATABASE your_database TO pgtuner_monitor; GRANT USAGE ON SCHEMA public TO pgtuner_monitor;
-- 3. Grant read access to user tables GRANT SELECT ON ALL TABLES IN SCHEMA public TO pgtuner_monitor; ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO pgtuner_monitor;
-- 4. Grant system statistics access GRANT pg_read_all_stats TO pgtuner_monitor; -- PostgreSQL 10+
-- Grant access to pg_stat_statements views explicitly GRANT SELECT ON pg_stat_statements TO pgtuner_monitor; GRANT SELECT ON pg_stat_statements_info TO pgtuner_monitor;
-- 5. Install and grant access to extensions (as superuser) -- pg_stat_statements (required) CREATE EXTENSION IF NOT EXISTS pg_stat_statements;
-- pgstattuple (for bloat detection) CREATE EXTENSION IF NOT EXISTS pgstattuple; GRANT pg_stat_scan_tables TO pgtuner_monitor; -- PostgreSQL 14+ -- OR grant individual functions: -- GRANT EXECUTE ON FUNCTION pgstattuple(regclass) TO pgtuner_monitor; -- GRANT EXECUTE ON FUNCTION pgstattuple_approx(regclass) TO pgtuner_monitor; -- GRANT EXECUTE ON FUNCTION pgstatindex(regclass) TO pgtuner_monitor;
-- hypopg (for hypothetical index testing) CREATE EXTENSION IF NOT EXISTS hypopg; GRANT SELECT ON hypopg_list_indexes TO pgtuner_monitor; GRANT SELECT ON hypopg_hidden_indexes TO pgtuner_monitor; GRANT EXECUTE ON FUNCTION hypopg_create_index(text) TO pgtuner_monitor; GRANT EXECUTE ON FUNCTION hypopg_drop_index(oid) TO pgtuner_monitor; GRANT EXECUTE ON FUNCTION hypopg_reset() TO pgtuner_monitor; GRANT EXECUTE ON FUNCTION hypopg_hide_index(oid) TO pgtuner_monitor; GRANT EXECUTE ON FUNCTION hypopg_unhide_index(oid) TO pgtuner_monitor; GRANT EXECUTE ON FUNCTION hypopg_relation_size(oid) TO pgtuner_monitor;
-- 6. Verify permissions SET ROLE pgtuner_monitor; SELECT * FROM pg_stat_statements LIMIT 1; SELECT * FROM pg_stat_activity WHERE pid = pg_backend_pid(); SELECT * FROM pgstattuple('pg_class') LIMIT 1; SELECT * FROM hypopg_list_indexes(); RESET ROLE;
Excluding Specific Users from Monitoring
You can exclude specific PostgreSQL users from being included in query analysis and monitoring results. This is useful for filtering out:
- Monitoring or replication users
- System accounts
- Internal application service accounts
Set the PGTUNER_EXCLUDE_USERIDS environment variable with a comma-separated list of user OIDs:
# Exclude user IDs 16384, 16385, and 16386
export PGTUNER_EXCLUDE_USERIDS="16384,16385,16386"
To find the OID for a specific PostgreSQL user:
SELECT usesysid, usename FROM pg_user WHERE usename = 'monitoring_user';
When configured, the following queries are filtered:
pg_stat_activityqueries (filters onusesysidcolumn)pg_stat_statementsqueries (filters onuseridcolumn)
This affects tools like get_slow_queries, get_active_queries, analyze_wait_events, check_database_health, and get_index_recommendations.
MCP Client Configuration
Add to your cline_mcp_settings.json or Claude Desktop config:
{
"mcpServers": { "pgtuner_mcp": { "command": "python", "args": ["-m", "pgtuner_mcp"], "env": { "DATABASE_URI": "postgresql://user:password@localhost:5432/mydb" }, "disabled": false, "autoApprove": [] } } }
Or Streamable HTTP Mode
{
"mcpServers": { "pgtuner_mcp": { "type": "http", "url": "http://localhost:8080/mcp" } } }
Security Hardening
pgtuner_mcp HTTP modes (sse, streamable-http) do not include authentication. They are safe for local-only use; for any networked deployment you MUST front them with a reverse proxy that handles auth and TLS.
Connection-level safeguards (built in)
Every connection started by the pool receives session-level guards via libpq options at handshake time:
| Env | Default | Effect |
|---|---|---|
PGTUNER_STATEMENT_TIMEOUT_MS | 30000 | Per-statement cap. Caps analyze_query EXPLAIN ANALYZE. Set 0 to disable. |
PGTUNER_IDLE_TXN_TIMEOUT_MS | 60000 | Kills orphaned transactions. Set 0 to disable. |
PGTUNER_LOCK_TIMEOUT_MS | 5000 | Caps the tuning user's wait on application locks. |
Belt-and-braces — also pin on the monitoring role:
ALTER ROLE pgtuner_monitor SET statement_timeout = '30s';
ALTER ROLE pgtuner_monitor SET idle_in_transaction_session_timeout = '60s';
CORS
| Env | Default | Effect |
|---|---|---|
PGTUNER_CORS_ALLOW_ORIGINS | (default: any localhost/127.0.0.1 port, http or https) | Comma-separated allowlist. Setting it switches off the localhost regex default and uses literal-origin matching. Use * to allow all (forces allow_credentials=false). |
Recommended reverse-proxy template (Caddy)
mcp.example.com {
basicauth { teamuser } reverse_proxy localhost:8080 }
What is NOT included
- No Bearer-token / API-key auth (operator concern — see reverse proxy)
- No rate limiting (operator concern)
- No in-process TLS (use the reverse proxy)
- No per-client tool allowlist
Server Modes
1. Standard MCP Mode (Default)
# Default mode (stdio)
python -m pgtuner_mcp
Explicitly specify stdio mode
python -m pgtuner_mcp --mode stdio