Skip to content
Docs Try Aspire

Compiler Warning ASPIREMCP001

Version introduced: 13.2

MCP server types and members are for evaluation purposes only and are subject to change or removal in future updates. Suppress this diagnostic to proceed.

This diagnostic warning is reported when using the experimental WithMcpServer extension method and related Model Context Protocol (MCP) server APIs. These APIs enable Aspire tooling to discover and proxy MCP servers exposed by resources.

The following APIs are protected by this diagnostic:

  • WithMcpServer on IResourceBuilder<T> — marks a resource as hosting an MCP server on a specified endpoint.
  • McpServerEndpointAnnotation — annotation that stores the MCP server endpoint information.

The following code generates ASPIREMCP001:

C# — AppHost.cs
var builder = DistributedApplication.CreateBuilder(args);
var api = builder.AddProject<Projects.MyApi>("api")
.WithMcpServer();
builder.Build().Run();

—or—

The following code uses a custom path and endpoint name:

C# — AppHost.cs
var builder = DistributedApplication.CreateBuilder(args);
var api = builder.AddProject<Projects.MyApi>("api")
.WithMcpServer("/sse", endpointName: "https");
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.ASPIREMCP001.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);ASPIREMCP001</NoWarn>
    </PropertyGroup>
  • Suppress in code with the #pragma warning disable ASPIREMCP001 directive:

    C# — Suppressing the warning
    #pragma warning disable ASPIREMCP001
    var api = builder.AddProject<Projects.MyApi>("api")
    .WithMcpServer();
    #pragma warning restore ASPIREMCP001
  • Configure MCP - Learn about Model Context Protocol configuration