-
Notifications
You must be signed in to change notification settings - Fork 2
Troubleshooting
Common issues and solutions when using postgres-mcp.
Every postgres-mcp tool returns a structured response — never a raw exception. This makes errors deterministic and parseable for both humans and AI agents.
{
"success": true,
"data": "..."
}{
"success": false,
"error": "Table 'public.nonexistent' not found",
"code": "TABLE_NOT_FOUND",
"category": "RESOURCE",
"suggestion": "Check table name spelling or run pg_list_tables",
"recoverable": true
}- No raw exceptions — You will never see an unstructured MCP error from a tool call
-
No silent failures — Empty results for nonexistent objects return explicit errors instead of
{count: 0} -
Actionable context — Error messages include the object name, schema, and often a
suggestionfield -
Consistent contract — The same
{success, error, code, category, suggestion, recoverable}shape across all 248 tools
Symptoms:
- "Connection refused" errors
- Timeout on database connection
Solutions:
-
Verify PostgreSQL is running:
psql -h localhost -U your_user -d your_database
-
Check connection string format:
postgres://user:password@host:5432/database
-
Docker users: Use
host.docker.internalinstead oflocalhost:{ "env": { "POSTGRES_HOST": "host.docker.internal" } } -
Check firewall rules: Ensure port 5432 is accessible.
-
Check pg_hba.conf: Ensure your host is allowed to connect.
AWS RDS:
- Use the full endpoint:
your-instance.xxxx.us-east-1.rds.amazonaws.com - Ensure security group allows inbound traffic on port 5432
Supabase:
- Use pooler connection string for best performance
- Enable SSL:
?sslmode=require
Neon:
- Use the full endpoint with project ID
- SSL is required:
?sslmode=require
Symptoms:
- IDE shows tool limit warning
- Some tools not appearing
Solutions:
Use a restrictive preset:
# Most restrictive general-purpose preset
--tool-filter essential # 48 tools
# Or extension-only
--tool-filter ext-ai # 26 toolsSee Tool-Filtering for all options.
Symptoms:
- Extension tools return "extension not found"
- Tools fail with permission errors
Solutions:
-
Verify extension is installed:
SELECT * FROM pg_extension WHERE extname = 'pgvector';
-
Install missing extension:
CREATE EXTENSION IF NOT EXISTS vector;
-
Check for shared_preload_libraries (pg_cron, pg_stat_kcache):
- Edit
postgresql.conf - Add:
shared_preload_libraries = 'pg_cron' - Restart PostgreSQL
- Edit
Symptoms:
- "Invalid token" errors
- 401 Unauthorized responses
Solutions:
-
Check token expiration: Tokens may have expired.
-
Verify audience claim:
- Token must contain the correct
audclaim - Keycloak: Add Audience mapper to client
- Token must contain the correct
-
Check issuer URL:
- Must exactly match
OAUTH_ISSUER - Include trailing
/if your provider requires it
- Must exactly match
-
Clock skew: Increase tolerance:
OAUTH_CLOCK_TOLERANCE=60
Symptoms:
- "Insufficient scope" errors
- Code Mode "admin required" errors
Solutions:
- Request appropriate scopes during token acquisition
- Configure client scopes in your OAuth provider
- For Code Mode, ensure token has
adminscope
Symptoms:
- "Rate limit exceeded" error after many executions
Solutions:
- Wait 1 minute for rate limit reset (60 executions/minute)
- Batch multiple operations into single Code Mode calls
- Use individual tools for infrequent operations
Symptoms:
- Code Mode returns execution errors
- JavaScript syntax errors
Solutions:
-
Check syntax: Use async/await properly
// Correct const result = await pg.query("SELECT 1"); return result.rows; // Incorrect - missing await const result = pg.query("SELECT 1");
-
Avoid blocked operations:
- No
require() - No
processaccess - No
eval() - No filesystem or network access
- No
-
Return a value: Code must return something
// Always return a value return { success: true, data: rows };
Solutions:
-
Check query plan:
Use pg_explain tool with ANALYZE option
-
Add missing indexes:
- Check
postgres://indexesresource for unused index warnings - Use
pg_index_recommendationsfor suggestions
- Check
-
Update statistics:
ANALYZE table_name;
-
Increase cache TTL for stable schemas:
METADATA_CACHE_TTL_MS=300000 # 5 minutes
Symptoms:
- "Connection pool exhausted" errors
- Timeouts waiting for connections
Solutions:
-
Check pool status:
- Read
postgres://poolresource
- Read
-
Close long-running transactions:
- Check
postgres://activityfor long queries - Use
pg_cancel_backendif needed
- Check
-
Increase pool size (if available connections exist)
LOG_LEVEL=debugThis reveals:
- Connection attempts
- Query execution details
- OAuth validation steps
- Tool resolution
# Test CLI
node dist/cli.js info
node dist/cli.js list-tools
# Health endpoint (HTTP mode)
curl http://localhost:3000/healthSymptoms:
- Legacy SSE client connects but never receives tools
- Python
mcp.client.ssehangs after connecting
Solutions:
-
Verify the server is running with HTTP transport:
node dist/cli.js --transport http --port 3000
-
Use the correct endpoint: Legacy SSE clients should connect to
/sse, not/mcp:# Correct async with sse_client("http://localhost:3000/sse") as (read, write): # Incorrect — /mcp uses Streamable HTTP protocol async with sse_client("http://localhost:3000/mcp") as (read, write):
-
Check health endpoint:
curl http://localhost:3000/health
Symptoms:
-
POST /mcpinitialize works, but subsequent requests return 400 - Response:
{"jsonrpc":"2.0","error":{"code":-32700,"message":"Parse error: Invalid JSON"}}
Solutions:
-
Include the session header on all requests after initialize:
-H "Mcp-Session-Id: <id-from-initialize-response>" -
Send valid JSON-RPC body — even notifications need a proper body:
{ "jsonrpc": "2.0", "method": "notifications/initialized" }
Symptoms:
- 404 on
POST /messages?sessionId=... - 400 on
POST /mcpwithMcp-Session-Idheader
Solutions:
- Session may have expired — SSE sessions close when the client disconnects
-
Re-initialize — Create a new session by connecting to
GET /sseorPOST /mcpwithout a session header -
Check server logs — Enable
LOG_LEVEL=debugto see session lifecycle events
See HTTP-Transport for full endpoint documentation.
If you're still stuck:
- Search the Wiki: AI-Powered Wiki Search
- Check GitHub Issues: Open Issues
-
File a Bug Report: Include logs with
LOG_LEVEL=debug
- Quick-Start - Installation and configuration
- HTTP-Transport - HTTP/SSE endpoint details
- OAuth-and-Security - Authentication setup
- Tool-Filtering - Reducing tool count