{"record":{"id":"9e50cb845bbfc457","repo":"microsoft/aspire","slug":"mcp-server-configuration-builder-resource-name-configures-a","errorCode":null,"errorMessage":"MCP server configuration '{builder.Resource.Name}' configures a description and cannot be marked as existing.","messagePattern":"MCP server configuration '(.+?)' configures a description and cannot be marked as existing\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Azure.ConnectorNamespace/AzureConnectorNamespaceExtensions.cs","lineNumber":507,"sourceCode":"    /// Marks a managed MCP server configuration as an existing Azure resource.\n    /// </summary>\n    /// <param name=\"builder\">The MCP server configuration resource builder.</param>\n    /// <returns>The resource builder.</returns>\n    /// <ats-returns>The resource builder.</ats-returns>\n    [AspireExport(\"asExistingConnectorNamespaceMcpServerConfig\", MethodName = \"asExisting\")]\n    public static IResourceBuilder<AzureConnectorNamespaceMcpServerConfigResource> AsExisting(\n        this IResourceBuilder<AzureConnectorNamespaceMcpServerConfigResource> builder)\n    {\n        ArgumentNullException.ThrowIfNull(builder);\n        if (builder.Resource.Connectors.Count > 0)\n        {\n            throw new InvalidOperationException(\n                $\"MCP server configuration '{builder.Resource.Name}' has connector routes and cannot be marked as existing.\");\n        }\n\n        if (!string.IsNullOrWhiteSpace(builder.Resource.Description))\n        {\n            throw new InvalidOperationException(\n                $\"MCP server configuration '{builder.Resource.Name}' configures a description and cannot be marked as existing.\");\n        }\n\n        if (builder.Resource.AccessPolicies.Count > 0)\n        {\n            throw new InvalidOperationException(\n                $\"MCP server configuration '{builder.Resource.Name}' configures access policies and cannot be marked as existing.\");\n        }\n\n        builder.Resource.IsExisting = true;\n        return builder;\n    }\n\n    /// <summary>\n    /// Adds a Microsoft Entra user or group access policy to a managed MCP server configuration.\n    /// </summary>\n    /// <param name=\"builder\">The MCP server configuration resource builder.</param>\n    /// <param name=\"name\">The Aspire resource name for the policy.</param>","sourceCodeStart":489,"sourceCodeEnd":525,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Azure.ConnectorNamespace/AzureConnectorNamespaceExtensions.cs#L489-L525","documentation":"AsExisting only accepts a bare MCP server configuration reference. A Description on the resource is modeled content that would be silently dropped (or wrongly deployed) on an existing reference, so AsExisting refuses the conversion when Description is non-whitespace.","triggerScenarios":"Calling builder.AsExisting() on an MCP server configuration whose Resource.Description was set via WithDescription (or an equivalent API).","commonSituations":"Builders that set a description for documentation/dashboard purposes and are later switched to existing mode when the config is pre-provisioned.","solutions":["Remove the WithDescription call (or clear Resource.Description) before calling AsExisting.","Keep the description in your own documentation instead of the resource model when using existing mode.","If the description matters for deployment, keep the configuration in create mode."],"exampleFix":"// before\nvar mcp = ns.AddMcpServerConfig(\"tools\", options).WithDescription(\"My MCP tools\");\nmcp.AsExisting(); // throws\n\n// after\nvar mcp = ns.AddMcpServerConfig(\"tools\", options);\nmcp.AsExisting(); // description removed","handlingStrategy":"validation","validationCode":"if (string.IsNullOrWhiteSpace(mcp.Resource.Description))\n{\n    mcp.AsExisting();\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    mcp.AsExisting();\n}\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"configures a description\"))\n{\n    // remove WithDescription or document the existing config elsewhere\n}","preventionTips":["Only call AsExisting on freshly created, unconfigured builders.","Keep descriptions for create-mode resources; use comments/docs for existing references.","Order fluent calls so AsExisting comes first."],"tags":["azure","aspire-hosting","mcp","existing-resource"],"backgroundTag":"invalid-state-transition","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T09:17:21.228Z"}