Fix Postgres data-plane params and add multi-schema table listing#2864
Open
vcolin7 wants to merge 5 commits into
Open
Fix Postgres data-plane params and add multi-schema table listing#2864vcolin7 wants to merge 5 commits into
vcolin7 wants to merge 5 commits into
Conversation
Resolves #471 by removing the unused subscriptionId and resourceGroup parameters from the ListDatabasesAsync, ExecuteQueryAsync, ListTablesAsync and GetTableSchemaAsync data-plane methods (these connect directly via Npgsql) and updating all callers. ARM server-config methods and the --subscription/--resource-group CLI options are unchanged. Resolves #469 by adding an optional --schema parameter (default 'public') to the table-listing path. ListTablesAsync now accepts a schema argument and uses a parameterized query: SELECT table_name FROM information_schema.tables WHERE table_schema = @Schema ORDER BY table_name; Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refines the Azure PostgreSQL tool’s data-plane surface by removing unused ARM-scoping parameters from IPostgresService/PostgresService, and extends azmcp postgres list to support listing tables from non-public schemas via a new optional --schema argument (defaulting to public).
Changes:
- Removed unused
subscriptionId/resourceGroupparameters from PostgreSQL data-plane service methods and updated all callers/tests accordingly. - Added
--schemato thepostgres listtable-listing path and updatedListTablesAsyncto use a parameterizedinformation_schemaquery with deterministic ordering. - Updated unit tests + docs (
azmcp-commands.md,e2eTestPrompts.md) and added a server changelog entry.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tools/Azure.Mcp.Tools.Postgres/tests/Azure.Mcp.Tools.Postgres.Tests/Table/TableSchemaGetCommandTests.cs | Updates mocked GetTableSchemaAsync calls to match the new signature. |
| tools/Azure.Mcp.Tools.Postgres/tests/Azure.Mcp.Tools.Postgres.Tests/Services/PostgresServiceTests.cs | Updates service tests and adds a new assertion that table listing uses a parameterized @schema query. |
| tools/Azure.Mcp.Tools.Postgres/tests/Azure.Mcp.Tools.Postgres.Tests/Services/PostgresServiceServerNameValidationTests.cs | Updates validation tests for new method signatures and adds required schema arg for table listing. |
| tools/Azure.Mcp.Tools.Postgres/tests/Azure.Mcp.Tools.Postgres.Tests/Services/PostgresServiceParameterizedQueryTests.cs | Removes unused subscription/RG params from data-plane calls in parameterization-focused tests. |
| tools/Azure.Mcp.Tools.Postgres/tests/Azure.Mcp.Tools.Postgres.Tests/Services/PostgresServiceConnectionStringInjectionTests.cs | Updates injection regression tests for new signatures and adds schema arg for table listing. |
| tools/Azure.Mcp.Tools.Postgres/tests/Azure.Mcp.Tools.Postgres.Tests/PostgresListCommandTests.cs | Adds coverage for --schema provided vs omitted (default public) and updates signatures. |
| tools/Azure.Mcp.Tools.Postgres/tests/Azure.Mcp.Tools.Postgres.Tests/Database/DatabaseQueryCommandTests.cs | Updates ExecuteQueryAsync call sites and negative assertions to new signature. |
| tools/Azure.Mcp.Tools.Postgres/src/Services/PostgresService.cs | Removes unused params and parameterizes the schema filter for table listing. |
| tools/Azure.Mcp.Tools.Postgres/src/Services/IPostgresService.cs | Updates interface signatures to remove subscription/RG for data-plane methods; adds schema to ListTablesAsync. |
| tools/Azure.Mcp.Tools.Postgres/src/Options/PostgresOptionDefinitions.cs | Introduces the --schema option definition. |
| tools/Azure.Mcp.Tools.Postgres/src/Options/BasePostgresOptions.cs | Adds Schema to the base options model for binding/JSON. |
| tools/Azure.Mcp.Tools.Postgres/src/Commands/Table/TableSchemaGetCommand.cs | Updates the data-plane call to GetTableSchemaAsync (drops unused params). |
| tools/Azure.Mcp.Tools.Postgres/src/Commands/PostgresListCommand.cs | Registers/binds --schema and forwards it (defaulting to public) to ListTablesAsync. |
| tools/Azure.Mcp.Tools.Postgres/src/Commands/Database/DatabaseQueryCommand.cs | Updates the data-plane call to ExecuteQueryAsync (drops unused params). |
| servers/Azure.Mcp.Server/docs/e2eTestPrompts.md | Adds an E2E prompt row covering schema-scoped table listing. |
| servers/Azure.Mcp.Server/docs/azmcp-commands.md | Documents the optional --schema parameter for azmcp postgres list. |
| servers/Azure.Mcp.Server/changelog-entries/vcolin7-postgres-schema-listing.yaml | Adds a changelog entry for the schema option + data-plane signature cleanup. |
Comments suppressed due to low confidence (1)
tools/Azure.Mcp.Tools.Postgres/src/Commands/PostgresListCommand.cs:43
--schemacan be provided without--database, but it has no effect unless the command is listing tables (--server+--database). This can lead to confusing output (users think they scoped by schema but actually listed servers/databases). Add a validator that requires--databasewhen--schemahas a value.
command.Validators.Add(result =>
{
// Validate that --server is provided when --database is specified
if (!string.IsNullOrEmpty(result.GetValueOrDefault<string>(PostgresOptionDefinitions.DatabaseOptional.Name)) &&
string.IsNullOrEmpty(result.GetValueOrDefault<string>(PostgresOptionDefinitions.ServerOptional.Name)))
Address maintainer review feedback on the Postgres data-plane commands. The query and table-schema-get commands connect directly via Npgsql and never use ARM scoping, but --subscription/--resource-group were still exposed in their MCP input schema. Re-parent BaseDatabaseCommand to GlobalCommand so those options are no longer registered, and add regression tests asserting the options are absent. Control-plane commands (list, server config/param) keep them. Relates to #469 and #471. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Cleans up the PostgreSQL data-plane service surface and unblocks listing tables that live outside the
publicschema.Why: The data-plane methods threaded
subscriptionId/resourceGroupthrough to code that connects directly to Postgres via Npgsql and never used them, andazmcp postgres listcould only ever see tables in thepublicschema because the schema was hardcoded in the query.Approach:
#471 (unused params): Removed
subscriptionIdandresourceGroupfromListDatabasesAsync,ExecuteQueryAsync,ListTablesAsync, andGetTableSchemaAsyncon bothIPostgresServiceandPostgresService, and updated every caller.#469 (multi-schema listing): Added an optional
--schemaoption (defaults topublicfor backward compatibility) on the table-listing path.ListTablesAsyncnow takes aschemaargument and runs a parameterized query so the schema is never interpolated:GitHub issue number?
Pre-merge Checklist
servers/Azure.Mcp.Server/README.mdand/orservers/Fabric.Mcp.Server/README.mddocumentation — N/A (no surface/description rename; only an added optional option)README.mdchanges running the script./eng/scripts/Process-PackageReadMe.ps1— N/AToolDescriptionEvaluator— N/A (tool description unchanged)consolidated-tools.json— N/A (no new/renamed tools)servers/Azure.Mcp.Server/docs/azmcp-commands.md./eng/scripts/Update-AzCommandsMetadata.ps1to update tool metadata — please run/verify in CIservers/Azure.Mcp.Server/docs/e2eTestPrompts.mdInvoking Livetests
Copilot submitted PRs are not trustworthy by default. Users with
writeaccess to the repo need to validate the contents of this PR before leaving a comment with the text/azp run mcp - pullrequest - live. This will trigger the necessary livetest workflows to complete required validation.