Skip to content
Docs Try Aspire

Compiler Warning ASPIREPOSTGRES001

Version introduced: 13.2

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:

  • WithPostgresMcp on IResourceBuilder<PostgresDatabaseResource> — adds a Postgres MCP server container to a PostgreSQL database resource.
  • WithPostgresMcp on IResourceBuilder<AzurePostgresFlexibleServerDatabaseResource> — adds a Postgres MCP server container to an Azure PostgreSQL Flexible Server database resource running as a container.

The following code generates ASPIREPOSTGRES001 when using a PostgreSQL database resource:

C# — AppHost.cs (PostgreSQL)
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:

C# — AppHost.cs (Azure PostgreSQL)
var builder = DistributedApplication.CreateBuilder(args);
var db = builder.AddAzurePostgresFlexibleServer("postgres")
.RunAsContainer()
.AddDatabase("mydb")
.WithPostgresMcp();
builder.Build().Run();

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 = none

    For more information about editor config files, see Configuration files for code analysis rules.

  • Add the following PropertyGroup to your project file:

    C# project file
    <PropertyGroup>
    <NoWarn>$(NoWarn);ASPIREPOSTGRES001</NoWarn>
    </PropertyGroup>
  • Suppress in code with the #pragma warning disable ASPIREPOSTGRES001 directive:

    C# — Suppressing the warning
    #pragma warning disable ASPIREPOSTGRES001
    var db = builder.AddPostgres("postgres")
    .AddDatabase("mydb")
    .WithPostgresMcp();
    #pragma warning restore ASPIREPOSTGRES001