Skip to content
This repository was archived by the owner on Feb 6, 2026. It is now read-only.

Commit 43b7cfe

Browse files
Copilotjongio
andauthored
Refactor postgres commands to follow ObjectVerb naming pattern, fix command hierarchy, and ensure all commands end with verbs (#866)
* Initial plan * Implement postgres server param set pattern - refactor from setparam Co-authored-by: jongio <2163001+jongio@users.noreply.github.com> * Refactor postgres commands to follow ObjectVerb naming pattern Co-authored-by: jongio <2163001+jongio@users.noreply.github.com> * Fix whitespace formatting in PostgresSetup.cs Co-authored-by: jongio <2163001+jongio@users.noreply.github.com> * Fix command naming consistency - rename ParamSetCommand to ServerParamSetCommand Co-authored-by: jongio <2163001+jongio@users.noreply.github.com> * Add 'get' verb to postgres server param command for consistency Co-authored-by: jongio <2163001+jongio@users.noreply.github.com> * Ensure all postgres commands end with verbs (get, set, list, etc.) Co-authored-by: jongio <2163001+jongio@users.noreply.github.com> * Fix whitespace formatting issues in PostgresSetup.cs Co-authored-by: jongio <2163001+jongio@users.noreply.github.com> * Update CHANGELOG.md with postgres command refactoring entry for issue #865 Co-authored-by: jongio <2163001+jongio@users.noreply.github.com> * Add PR link to CHANGELOG.md entry for postgres command refactoring Co-authored-by: jongio <2163001+jongio@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: jongio <2163001+jongio@users.noreply.github.com>
1 parent 8a3cba0 commit 43b7cfe

19 files changed

Lines changed: 137 additions & 87 deletions

.vscode/cspell.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@
300300
"servicebus",
301301
"sessionhost",
302302
"setparam",
303+
"setpermission",
303304
"skillset",
304305
"staticwebapp",
305306
"syslib",

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ The Azure MCP Server updates automatically by default whenever a new release com
5151
### Other Changes
5252

5353
- Added caching for Cosmos DB databases and containers. [[813](https://github.com/Azure/azure-mcp/pull/813)]
54+
- Refactored PostgreSQL commands to follow ObjectVerb naming pattern, fix command hierarchy, and ensure all commands end with verbs. This improves consistency and discoverability across all postgres commands. [[#865](https://github.com/Azure/azure-mcp/issues/865)] [[#866](https://github.com/Azure/azure-mcp/pull/866)]
5455

5556
#### Dependency Updates
5657

areas/postgres/src/AzureMcp.Postgres/Commands/PostgresJsonContext.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ namespace AzureMcp.Postgres.Commands;
1010

1111
[JsonSerializable(typeof(DatabaseListCommand.DatabaseListCommandResult))]
1212
[JsonSerializable(typeof(DatabaseQueryCommand.DatabaseQueryCommandResult))]
13-
[JsonSerializable(typeof(GetConfigCommand.GetConfigCommandResult))]
14-
[JsonSerializable(typeof(GetParamCommand.GetParamCommandResult))]
15-
[JsonSerializable(typeof(SetParamCommand.SetParamCommandResult))]
13+
[JsonSerializable(typeof(ServerConfigGetCommand.ServerConfigGetCommandResult))]
14+
[JsonSerializable(typeof(ServerParamGetCommand.ServerParamGetCommandResult))]
15+
[JsonSerializable(typeof(ServerParamSetCommand.ServerParamSetCommandResult))]
1616
[JsonSerializable(typeof(ServerListCommand.ServerListCommandResult))]
17-
[JsonSerializable(typeof(GetSchemaCommand.GetSchemaCommandResult))]
17+
[JsonSerializable(typeof(TableSchemaGetCommand.TableSchemaGetCommandResult))]
1818
[JsonSerializable(typeof(TableListCommand.TableListCommandResult))]
1919

2020
internal sealed partial class PostgresJsonContext : JsonSerializerContext

areas/postgres/src/AzureMcp.Postgres/Commands/Server/GetConfigCommand.cs renamed to areas/postgres/src/AzureMcp.Postgres/Commands/Server/ServerConfigGetCommand.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
namespace AzureMcp.Postgres.Commands.Server;
1212

13-
public sealed class GetConfigCommand(ILogger<GetConfigCommand> logger) : BaseServerCommand<GetConfigOptions>(logger)
13+
public sealed class ServerConfigGetCommand(ILogger<ServerConfigGetCommand> logger) : BaseServerCommand<ServerConfigGetOptions>(logger)
1414
{
1515
private const string CommandTitle = "Get PostgreSQL Server Configuration";
1616
public override string Name => "config";
@@ -37,8 +37,8 @@ public override async Task<CommandResponse> ExecuteAsync(CommandContext context,
3737
var config = await pgService.GetServerConfigAsync(options.Subscription!, options.ResourceGroup!, options.User!, options.Server!);
3838
context.Response.Results = config?.Length > 0 ?
3939
ResponseResult.Create(
40-
new GetConfigCommandResult(config),
41-
PostgresJsonContext.Default.GetConfigCommandResult) :
40+
new ServerConfigGetCommandResult(config),
41+
PostgresJsonContext.Default.ServerConfigGetCommandResult) :
4242
null;
4343
}
4444
catch (Exception ex)
@@ -48,5 +48,5 @@ public override async Task<CommandResponse> ExecuteAsync(CommandContext context,
4848
}
4949
return context.Response;
5050
}
51-
internal record GetConfigCommandResult(string Configuration);
51+
internal record ServerConfigGetCommandResult(string Configuration);
5252
}

areas/postgres/src/AzureMcp.Postgres/Commands/Server/GetParamCommand.cs renamed to areas/postgres/src/AzureMcp.Postgres/Commands/Server/ServerParamGetCommand.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace AzureMcp.Postgres.Commands.Server;
1313

14-
public sealed class GetParamCommand(ILogger<GetParamCommand> logger) : BaseServerCommand<GetParamOptions>(logger)
14+
public sealed class ServerParamGetCommand(ILogger<ServerParamGetCommand> logger) : BaseServerCommand<ServerParamGetOptions>(logger)
1515
{
1616
private const string CommandTitle = "Get PostgreSQL Server Parameter";
1717
private readonly Option<string> _paramOption = PostgresOptionDefinitions.Param;
@@ -30,7 +30,7 @@ protected override void RegisterOptions(Command command)
3030
command.AddOption(_paramOption);
3131
}
3232

33-
protected override GetParamOptions BindOptions(ParseResult parseResult)
33+
protected override ServerParamGetOptions BindOptions(ParseResult parseResult)
3434
{
3535
var options = base.BindOptions(parseResult);
3636
options.Param = parseResult.GetValueForOption(_paramOption);
@@ -54,8 +54,8 @@ public override async Task<CommandResponse> ExecuteAsync(CommandContext context,
5454
var parameterValue = await pgService.GetServerParameterAsync(options.Subscription!, options.ResourceGroup!, options.User!, options.Server!, options.Param!);
5555
context.Response.Results = parameterValue?.Length > 0 ?
5656
ResponseResult.Create(
57-
new GetParamCommandResult(parameterValue),
58-
PostgresJsonContext.Default.GetParamCommandResult) :
57+
new ServerParamGetCommandResult(parameterValue),
58+
PostgresJsonContext.Default.ServerParamGetCommandResult) :
5959
null;
6060
}
6161
catch (Exception ex)
@@ -66,5 +66,5 @@ public override async Task<CommandResponse> ExecuteAsync(CommandContext context,
6666
return context.Response;
6767
}
6868

69-
internal record GetParamCommandResult(string ParameterValue);
69+
internal record ServerParamGetCommandResult(string ParameterValue);
7070
}

areas/postgres/src/AzureMcp.Postgres/Commands/Server/SetParamCommand.cs renamed to areas/postgres/src/AzureMcp.Postgres/Commands/Server/ServerParamSetCommand.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111

1212
namespace AzureMcp.Postgres.Commands.Server;
1313

14-
public sealed class SetParamCommand(ILogger<SetParamCommand> logger) : BaseServerCommand<SetParamOptions>(logger)
14+
public sealed class ServerParamSetCommand(ILogger<ServerParamSetCommand> logger) : BaseServerCommand<ServerParamSetOptions>(logger)
1515
{
1616
private const string CommandTitle = "Set PostgreSQL Server Parameter";
1717
private readonly Option<string> _paramOption = PostgresOptionDefinitions.Param;
1818
private readonly Option<string> _valueOption = PostgresOptionDefinitions.Value;
19-
public override string Name => "setparam";
19+
public override string Name => "set";
2020

2121
public override string Description =>
2222
"Sets a specific parameter of a PostgreSQL server to a certain value.";
@@ -32,7 +32,7 @@ protected override void RegisterOptions(Command command)
3232
command.AddOption(_valueOption);
3333
}
3434

35-
protected override SetParamOptions BindOptions(ParseResult parseResult)
35+
protected override ServerParamSetOptions BindOptions(ParseResult parseResult)
3636
{
3737
var options = base.BindOptions(parseResult);
3838
options.Param = parseResult.GetValueForOption(_paramOption);
@@ -57,8 +57,8 @@ public override async Task<CommandResponse> ExecuteAsync(CommandContext context,
5757
var result = await pgService.SetServerParameterAsync(options.Subscription!, options.ResourceGroup!, options.User!, options.Server!, options.Param!, options.Value!);
5858
context.Response.Results = !string.IsNullOrEmpty(result) ?
5959
ResponseResult.Create(
60-
new SetParamCommandResult(result, options.Param!, options.Value!),
61-
PostgresJsonContext.Default.SetParamCommandResult) :
60+
new ServerParamSetCommandResult(result, options.Param!, options.Value!),
61+
PostgresJsonContext.Default.ServerParamSetCommandResult) :
6262
null;
6363
}
6464
catch (Exception ex)
@@ -69,5 +69,5 @@ public override async Task<CommandResponse> ExecuteAsync(CommandContext context,
6969
return context.Response;
7070
}
7171

72-
internal record SetParamCommandResult(string Message, string Parameter, string Value);
72+
internal record ServerParamSetCommandResult(string Message, string Parameter, string Value);
7373
}

areas/postgres/src/AzureMcp.Postgres/Commands/Table/GetSchemaCommand.cs renamed to areas/postgres/src/AzureMcp.Postgres/Commands/Table/TableSchemaGetCommand.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace AzureMcp.Postgres.Commands.Table;
1313

14-
public sealed class GetSchemaCommand(ILogger<GetSchemaCommand> logger) : BaseDatabaseCommand<GetSchemaOptions>(logger)
14+
public sealed class TableSchemaGetCommand(ILogger<TableSchemaGetCommand> logger) : BaseDatabaseCommand<TableSchemaGetOptions>(logger)
1515
{
1616
private const string CommandTitle = "Get PostgreSQL Table Schema";
1717
private readonly Option<string> _tableOption = PostgresOptionDefinitions.Table;
@@ -28,7 +28,7 @@ protected override void RegisterOptions(Command command)
2828
command.AddOption(_tableOption);
2929
}
3030

31-
protected override GetSchemaOptions BindOptions(ParseResult parseResult)
31+
protected override TableSchemaGetOptions BindOptions(ParseResult parseResult)
3232
{
3333
var options = base.BindOptions(parseResult);
3434
options.Table = parseResult.GetValueForOption(_tableOption);
@@ -52,8 +52,8 @@ public override async Task<CommandResponse> ExecuteAsync(CommandContext context,
5252
List<string> schema = await pgService.GetTableSchemaAsync(options.Subscription!, options.ResourceGroup!, options.User!, options.Server!, options.Database!, options.Table!);
5353
context.Response.Results = schema?.Count > 0 ?
5454
ResponseResult.Create(
55-
new GetSchemaCommandResult(schema),
56-
PostgresJsonContext.Default.GetSchemaCommandResult) :
55+
new TableSchemaGetCommandResult(schema),
56+
PostgresJsonContext.Default.TableSchemaGetCommandResult) :
5757
null;
5858
}
5959
catch (Exception ex)
@@ -65,5 +65,5 @@ public override async Task<CommandResponse> ExecuteAsync(CommandContext context,
6565
return context.Response;
6666
}
6767

68-
internal record GetSchemaCommandResult(List<string> Schema);
68+
internal record TableSchemaGetCommandResult(List<string> Schema);
6969
}

areas/postgres/src/AzureMcp.Postgres/Options/Server/GetConfigOptions.cs renamed to areas/postgres/src/AzureMcp.Postgres/Options/Server/ServerConfigGetOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33

44
namespace AzureMcp.Postgres.Options.Server;
55

6-
public class GetConfigOptions : BasePostgresOptions;
6+
public class ServerConfigGetOptions : BasePostgresOptions;

areas/postgres/src/AzureMcp.Postgres/Options/Server/GetParamOptions.cs renamed to areas/postgres/src/AzureMcp.Postgres/Options/Server/ServerParamGetOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace AzureMcp.Postgres.Options.Server;
77

8-
public class GetParamOptions : BasePostgresOptions
8+
public class ServerParamGetOptions : BasePostgresOptions
99
{
1010
[JsonPropertyName(PostgresOptionDefinitions.ParamName)]
1111
public string? Param { get; set; }

areas/postgres/src/AzureMcp.Postgres/Options/Server/SetParamOptions.cs renamed to areas/postgres/src/AzureMcp.Postgres/Options/Server/ServerParamSetOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace AzureMcp.Postgres.Options.Server;
77

8-
public class SetParamOptions : BasePostgresOptions
8+
public class ServerParamSetOptions : BasePostgresOptions
99
{
1010
[JsonPropertyName(PostgresOptionDefinitions.ParamName)]
1111
public string? Param { get; set; }

0 commit comments

Comments
 (0)