-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
Description
Several issues prevent the PostgreSQL MCP server from working correctly with IAM authentication on standalone RDS instances.
Issues Found
1. args.hostname reference error (Critical)
Location: server.py:726 (in main())
The CLI argument is defined as --db_endpoint but the code references args.hostname:
db_endpoint=args.hostname, # Should be args.db_endpointThis causes an AttributeError when starting the server.
2. Missing --username parameter for IAM auth
The server defaults to using the master username from RDS instance properties, but the master user often doesn't have the rds_iam role granted. Users need a way to specify a different database user for IAM authentication.
3. Connection lookup mismatch with cluster_identifier
The connection map uses cluster_identifier as part of the key. When the server starts with cluster_identifier=None but the MCP client passes cluster_identifier="" (empty string), the connection isn't found because None != "".
4. Async event loop conflict
The startup validation creates a connection pool in one event loop (asyncio.run()), but MCP runs in a different event loop. The aiorwlock.RWLock in the connection pool is bound to the first event loop and fails when used in the second:
Database connection error: <aiorwlock._RWLockCore object at ...> is bound to a different event loop
5. MCP client doesn't know startup parameters
When get_database_connection_info is called and no connections exist (due to issue #4 or first-time use), it returns []. The MCP client has no way to know the correct parameters to connect, requiring manual user input.
Steps to Reproduce
- Set up an RDS PostgreSQL instance with IAM authentication
- Create a database user with
rds_iamrole:GRANT rds_iam TO myuser; - Try to start the MCP server:
uvx awslabs.postgres-mcp-server@latest \
--region=us-east-1 \
--db_type=RPG \
--db_endpoint=mydb.xxx.us-east-1.rds.amazonaws.com \
--database=mydb \
--connection_method=PG_WIRE_IAM_PROTOCOL- Observe
AttributeError: 'Namespace' object has no attribute 'hostname'
Expected Behavior
The server should:
- Accept
--usernameparameter for IAM authentication - Start successfully and connect using the specified user
- Handle queries from MCP clients without connection lookup failures
- Provide startup parameters to clients so they know how to connect
Environment
- postgres-mcp-server version: 1.23.3
- Python: 3.10
- AWS: RDS PostgreSQL (standalone instance, not Aurora)
- Connection method: PG_WIRE_IAM_PROTOCOL
Proposed Fix
See PR #2504
Related
- postgres-mcp-server: IAM Auth Support #1813 (IAM Auth Support - Feature Request)
Metadata
Metadata
Assignees
Labels
Type
Projects
Status