-
Notifications
You must be signed in to change notification settings - Fork 273
Add support for PostgreSQL authentication #1011
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for password-based authentication in addition to the existing Entra ID authentication for PostgreSQL tools. The change allows users to connect to PostgreSQL servers using either authentication method based on the username format.
Key changes:
- Added optional
passwordparameter to all PostgreSQL service methods and commands - Modified authentication logic to use password authentication when username doesn't contain "@", otherwise uses Entra ID
- Updated all test mocks to include the new password parameter (passing
null)
Reviewed Changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| IPostgresService.cs | Updated interface to add optional password parameter to all service methods |
| PostgresService.cs | Implemented conditional authentication logic based on username format; added password parameter to methods |
| BasePostgresOptions.cs | Added Password property to base options class |
| PostgresOptionDefinitions.cs | Defined new password option for CLI |
| BaseDatabaseCommand.cs | Registered password option and bound it in option parsing |
| DatabaseListCommand.cs | Added password option registration and binding |
| TableSchemaGetCommand.cs | Updated service call to pass password parameter |
| TableListCommand.cs | Updated service call to pass password parameter |
| DatabaseQueryCommand.cs | Updated service call to pass password parameter |
| TableSchemaGetCommandTests.cs | Updated test mocks to include null password parameter |
| TableListCommandTests.cs | Updated test mocks to include null password parameter |
| DatabaseQueryCommandTests.cs | Updated test mocks to include null password parameter |
| DatabaseListCommandTests.cs | Updated test mocks to include null password parameter |
| PostgresServiceParameterizedQueryTests.cs | Updated test method calls to include null password parameter |
tools/Azure.Mcp.Tools.Postgres/src/Commands/BaseDatabaseCommand.cs
Outdated
Show resolved
Hide resolved
tools/Azure.Mcp.Tools.Postgres/src/Options/PostgresOptionDefinitions.cs
Outdated
Show resolved
Hide resolved
|
How does this change address the problem in the linked issue? In the linked issue, it says "This PostgreSQL server is configured with both PostgreSQL authentication and Microsoft Entra authentication methods." It doesn't seen that the root cause of the failure was missing PostgreSQL authentication support. |
w/o the change, we don't really use the password provided by user. We always useEntra ID. |
| ) | ||
| { | ||
| Description = $"The authentication type to access PostgreSQL server. " + | ||
| $"Supported values are '{AuthTypes.MicrosoftEntra}' or '{AuthTypes.PostgreSQL}'", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we make it optional and default to MicrosoftEntra?
What does this PR do?
Add support for PostgreSQL authentication, by adding 2 new parameters named
auth-typeandpasswordto the following commands:postgres_database_list,postgres_table_list,postgres_database_queryandpostgres_table_schema_get.Password parameter is optional an only required if we are using
PostgreSQLauthentication (MicrosoftEntradoes not require it).GitHub issue number?
#236
Pre-merge Checklist
servers/Azure.Mcp.Server/CHANGELOG.mdand/orservers/Fabric.Mcp.Server/CHANGELOG.mdfor product changes (features, bug fixes, UI/UX, updated dependencies)servers/Azure.Mcp.Server/README.mdand/orservers/Fabric.Mcp.Server/README.mddocumentationeng/scripts/Process-PackageReadMe.ps1. See Package README/servers/Azure.Mcp.Server/docs/azmcp-commands.mdand/or/docs/fabric-commands.md.\eng\scripts\Update-AzCommandsMetadata.ps1to update tool metadata in azmcp-commands.md (required for CI)ToolDescriptionEvaluatorand obtained a score of0.4or more and a top 3 ranking for all related test prompts/servers/Azure.Mcp.Server/docs/e2eTestPrompts.mdcrypto mining, spam, data exfiltration, etc.)/azp run mcp - pullrequest - liveto run Live Test Pipeline