aws / aws/amazon-q-developer-cli

MCP Server Integration Issue - postgres-mcp-server not working with Q CLI

Open
#2,853 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
2k
Forks
439
PR merge metrics
No merged PRs in 30d

Description

### Checks

- [x] I have searched [github.com/aws/amazon-q-developer-cli/issues](https://github.com/aws/amazon-q-developer-cli/issues?q=) and there are no duplicates of my issue
- [x] I have run `q doctor` in the affected terminal session
- [x] I have run `q restart` and replicated the issue again

### Operating system

Linux 6.1.112-122.189.amzn2023.x86_64 - Amazon Linux 2023.6.20241010

### Expected behaviour

The postgres-mcp-server should connect to PostgreSQL database and allow querying through run_query and get_table_schema tools when properly configured in ~/.aws/amazonq/mcp.json

### Actual behaviour

MCP server process starts successfully and can connect to database when tested manually, but Q CLI tools (run_query, get_table_schema) consistently return "No database connection available" error. Manual testing shows the server responds to MCP protocol but Q CLI appears to have protocol compatibility issues.

```
[chat-transcript]
The aur-pgs-200 database is accessible and contains:
- **Database**: postgres
- **Available tables**: `tb1`
- **tb1 schema**: Single column `id` (integer type)

The MCP server has a persistent communication i

> try again with MCP server and troubleshoot the issue

[Tool uses: run_query]

[Tool uses: execute_bash]

[Tool uses: execute_bash]

[Tool uses: execute_bash]

Found the issue! The MCP server is working but there's a protocol mismatch. The server expects proper MCP initialization with `clientInfo` field. Let me check if there's a version compatibility issue:
[Tool uses: execute_bash]

The MCP server is working correctly with proper initialization. The issue is that Q CLI may not be sending the correct initialization parameters. This is likely a version compatibility issue between Q CLI's MCP implementation and the postgres-mcp-server.

The MCP server is functional - it connects to the database successfully and responds to proper MCP protocol messages. The problem is in the communication layer between Q CLI and the MCP server.

**Summary**:
- ✅ MCP server can connect to PostgreSQL database
- ✅ Database contains table `tb1` with column `id` (integer)
- ❌ Q CLI MCP integration has protocol compatibility issues
- **Workaround**: Use direct psql commands for database queries
[Tool uses: none]

> /save state.json -f

> I dont want use workaround, fix this Q CLI MCP integration has protocol compatibility issues

Let me try to fix the Q CLI MCP integration issue by adjusting the server configuration to be more compatible:
[Tool uses: fs_write]

> t

[Tool uses: fs_write]

[Tool uses: execute_bash]

I've simplified the MCP configuration by:
1. Removing debug logging that might interfere
2. Setting a standard 60-second timeout
3. Explicitly setting disabled to false
4. Cleaning up environment variables

Restart your Q CLI session. The cleaner configuration should resolve the protocol compatibility issues between Q CLI and the MCP server.
[Tool uses: none]

> /save state.json -f

> I have restarted, try again

[Tool uses: run_query]

> t

[Tool uses: run_query]

[Tool uses: get_table_schema]

> t

The issue persists. Let me try a different MCP server package that might be more compatible with Q CLI:
[Tool uses: fs_write]

> t

[Tool uses: execute_bash]

> t

[Tool uses: fs_write]

[Tool uses: fs_write]

This approach won't work. Let me revert to the original working configuration and try a different fix - updating the MCP server package:
[Tool uses: execute_bash]

[Tool uses: fs_write]

I've changed the server name from "aur-pgs-200" to "postgres" which might resolve naming conflicts. Restart your Q CLI session to test this fix.
[Tool uses: none]

> /save state.json -f

> I have restarted, try again

[Tool uses: run_query]

> t

[Tool uses: run_query]

[Tool uses: execute_bash]

> t

The MCP server is running but still not connecting. This appears to be a fundamental incompatibility between Q CLI's MCP implementation and the postgres-mcp-server. Let me report this as a bug:
[Tool uses: report_issue]

(...truncated)
```

### Steps to reproduce

1. Configure postgres-mcp-server in ~/.aws/amazonq/mcp.json with valid AWS RDS connection details
2. Restart Q CLI session
3. Attempt to use run_query or get_table_schema tools
4. Observe "No database connection available" error despite server process running and database being accessible

### Environment

```yaml

[q-details]
version = "1.15.0"
hash = "a8a0426eaff32ac9b1599ca1b1f1881ffd16054d"
date = "2025-09-02T17:17:19.458949Z (10d ago)"

[system-info]
chip = "AMD EPYC 9R14"
total-cores = 2
memory = "15.25 GB"

[system-info.os.linux]
kernel_version = "6.1.112-122.189.amzn2023.x86_64"
id = "amzn"
name = "Amazon Linux"
pretty_name = "Amazon Linux 2023.6.20241010"
version_id = "2023"
version = "2023"

[environment]
cwd = "/workspace"
cli-path = "/workspace"
install-method = "unknown"

[env-vars]
PATH = "/usr/lib/code-server/lib/vscode/bin/remote-cli:/home/USER/.rvm/gems/ruby-3.2.2/bin:/home/USER/.rvm/gems/ruby-3.2.2@global/bin:/home/USER/.rvm/rubies/ruby-3.2.2/bin:/home/USER/.nvm/versions/node/v20.11.0/bin:/home/USER/.cargo/bin:/home/USER/.local/bin:/home/USER/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/home/USER/.dotnet/tools:/home/USER/.local/bin:/home/USER/.local/bin:/home/USER/.dotnet/tools:/usr/lib/jvm/java-21-amazon-corretto.x86_64/bin:/usr/share/maven/bin:/home/USER/.rvm/bin:/workspace/development/tools/redis-7.2.1/src:/workspace/development/tools/sysbench/src/:/home/USER/.local/bin:/home/USER/.dotnet/tools:/usr/lib/jvm/java-21-amazon-corretto.x86_64/bin:/usr/share/maven/bin:/home/USER/.rvm/bin:/opt/mssql-tools/bin"
Q_SET_PARENT_CHECK = "1"
SHELL = "/bin/bash"
TERM = "xterm-256color"

[chat-settings]

[chat-trusted_tools]
fs_read=trusted
execute_bash=trusted
@postgres/run_query=trusted

[chat-failed_request_ids]
none

[chat-context]
current_profile=q_cli_default
profile_context=
AmazonQ.md
README.md
.amazonq/rules/**/*.md

files=none
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.