Compiler Warning ASPIREMCP001
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:
WithMcpServeronIResourceBuilder<T>— marks a resource as hosting an MCP server on a specified endpoint.McpServerEndpointAnnotation— annotation that stores the MCP server endpoint information.
Example
Section titled “Example”The following code generates ASPIREMCP001:
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:
var builder = DistributedApplication.CreateBuilder(args);
var api = builder.AddProject<Projects.MyApi>("api") .WithMcpServer("/sse", endpointName: "https");
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.ASPIREMCP001.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);ASPIREMCP001</NoWarn></PropertyGroup> -
Suppress in code with the
#pragma warning disable ASPIREMCP001directive:C# — Suppressing the warning #pragma warning disable ASPIREMCP001var api = builder.AddProject<Projects.MyApi>("api").WithMcpServer();#pragma warning restore ASPIREMCP001
See also
Section titled “See also”- Configure MCP - Learn about Model Context Protocol configuration