Compiler Warning ASPIREPOSTGRES001
The PostgreSQL MCP integration APIs are experimental and subject to change or removal in future updates. Suppress this diagnostic to proceed.
The WithPostgresMcp extension method for adding Model Context Protocol (MCP) support to PostgreSQL resources is an experimental feature. This API may change or be removed in future versions.
The following APIs are protected by this diagnostic:
WithPostgresMcponIResourceBuilder<PostgresDatabaseResource>— adds a Postgres MCP server container to a PostgreSQL database resource.WithPostgresMcponIResourceBuilder<AzurePostgresFlexibleServerDatabaseResource>— adds a Postgres MCP server container to an Azure PostgreSQL Flexible Server database resource running as a container.
Example
Section titled “Example”The following code generates ASPIREPOSTGRES001 when using a PostgreSQL database resource:
var builder = DistributedApplication.CreateBuilder(args);
var db = builder.AddPostgres("postgres") .AddDatabase("mydb") .WithPostgresMcp();
builder.Build().Run();—or—
The following code generates ASPIREPOSTGRES001 when using an Azure PostgreSQL Flexible Server database resource:
var builder = DistributedApplication.CreateBuilder(args);
var db = builder.AddAzurePostgresFlexibleServer("postgres") .RunAsContainer() .AddDatabase("mydb") .WithPostgresMcp();
builder.Build().Run();To correct this warning
Section titled “To correct this warning”Suppress the warning with either of the following methods:
-
Set the severity of the rule in the .editorconfig file.
.editorconfig [*.{cs,vb}]dotnet_diagnostic.ASPIREPOSTGRES001.severity = noneFor more information about editor config files, see Configuration files for code analysis rules.
-
Add the following
PropertyGroupto your project file:C# project file <PropertyGroup><NoWarn>$(NoWarn);ASPIREPOSTGRES001</NoWarn></PropertyGroup> -
Suppress in code with the
#pragma warning disable ASPIREPOSTGRES001directive:C# — Suppressing the warning #pragma warning disable ASPIREPOSTGRES001var db = builder.AddPostgres("postgres").AddDatabase("mydb").WithPostgresMcp();#pragma warning restore ASPIREPOSTGRES001
See also
Section titled “See also”- PostgreSQL integration - Learn about PostgreSQL hosting integration
- Configure MCP - Learn about Model Context Protocol configuration