{"record":{"id":"ca921e258f0d8181","repo":"microsoft/aspire","slug":"mcp-server-configuration-builder-resource-name-already-has-a","errorCode":null,"errorMessage":"MCP server configuration '{builder.Resource.Name}' already has a connector. The current Connector Namespace preview supports one connector per MCP server configuration.","messagePattern":"MCP server configuration '(.+?)' already has a connector\\. The current Connector Namespace preview supports one connector per MCP server configuration\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Azure.ConnectorNamespace/AzureConnectorNamespaceExtensions.cs","lineNumber":602,"sourceCode":"        ArgumentException.ThrowIfNullOrWhiteSpace(connectorName);\n        ArgumentNullException.ThrowIfNull(connection);\n        ArgumentNullException.ThrowIfNull(options);\n\n        if (builder.Resource.IsExisting)\n        {\n            throw new InvalidOperationException(\n                $\"Existing MCP server configuration '{builder.Resource.Name}' is read-only.\");\n        }\n\n        if (!ReferenceEquals(builder.Resource.Parent, connection.Resource.Parent))\n        {\n            throw new InvalidOperationException(\n                $\"Connector connection '{connection.Resource.Name}' belongs to a different Connector Namespace.\");\n        }\n\n        if (builder.Resource.Connectors.Count > 0)\n        {\n            throw new InvalidOperationException(\n                $\"MCP server configuration '{builder.Resource.Name}' already has a connector. \" +\n                \"The current Connector Namespace preview supports one connector per MCP server configuration.\");\n        }\n\n        if (options.Operations is null || options.Operations.Length == 0)\n        {\n            throw new ArgumentException(\n                \"At least one connector operation must be explicitly allow-listed.\",\n                nameof(options));\n        }\n\n        var operationNames = new HashSet<string>(StringComparer.OrdinalIgnoreCase);\n        var connectorDefinition = new AzureConnectorNamespaceMcpConnectorDefinition(\n            connectorName,\n            options.DisplayName,\n            options.Description,\n            connection.Resource);\n        foreach (var operation in options.Operations)","sourceCodeStart":584,"sourceCodeEnd":620,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Azure.ConnectorNamespace/AzureConnectorNamespaceExtensions.cs#L584-L620","documentation":"The Connector Namespace preview limits each MCP server configuration to exactly one connector route. WithConnector enforces this by throwing when Resource.Connectors is non-empty, making the preview constraint explicit instead of silently overwriting the previous route.","triggerScenarios":"Calling WithConnector a second time on the same MCP server configuration, regardless of which connection is used for the second call.","commonSituations":"Wiring several connectors (database + storage, multiple tools) to one MCP server config; loops or shared helpers that attach connectors to every config in a namespace.","solutions":["Create an additional MCP server configuration for the second connector and call WithConnector once on each.","Remove one of the WithConnector calls so the config keeps a single connector.","When the preview lifts the one-connector limit, revisit this constraint (it is a preview limitation, not a permanent API rule)."],"exampleFix":"// before\nvar tools = ns.AddMcpServerConfig(\"tools\", options);\ntools.WithConnector(\"db-conn\", dbConnection, o);\ntools.WithConnector(\"storage-conn\", storageConnection, o); // throws\n\n// after\nvar tools = ns.AddMcpServerConfig(\"tools\", options)\n    .WithConnector(\"db-conn\", dbConnection, o);\nvar storage = ns.AddMcpServerConfig(\"storage-tools\", storageOptions)\n    .WithConnector(\"storage-conn\", storageConnection, o);","handlingStrategy":"validation","validationCode":"if (mcp.Resource.Connectors.Count == 0)\n{\n    mcp.WithConnector(name, connection, connectorOptions);\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    mcp.WithConnector(name, connection, connectorOptions);\n}\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"already has a connector\"))\n{\n    // create another MCP server configuration for the extra connector\n}","preventionTips":["Design one connector per MCP server config while the preview limit holds.","Fan out to additional AddMcpServerConfig builders for extra connectors.","Track WithConnector calls in shared helpers so a config is wired at most once."],"tags":["azure","aspire-hosting","connector","limit-exceeded"],"backgroundTag":"operation-not-supported","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"}