{"record":{"id":"8835c545d327a0d7","repo":"alibaba/nacos","slug":"mcp-server-version-exist","errorCode":"MCP_SERVER_VERSION_EXIST","errorMessage":"Mcp Server %s and target version %s already exist, do not do release","messagePattern":"Mcp Server (.+?) and target version (.+?) already exist, do not do release","errorType":"exception","errorClass":"NacosApiException","httpStatus":409,"severity":"warning","filePath":"ai/src/main/java/com/alibaba/nacos/ai/remote/handler/ReleaseMcpServerRequestHandler.java","lineNumber":130,"sourceCode":"        throws NacosException {\n        String namespaceId = request.getNamespaceId();\n        McpServerBasicInfo serverSpecification = request.getServerSpecification();\n        LOGGER.info(\n            \"Release new mcp server {}, version {} into namespaceId {} from connectionId {}.\",\n            serverSpecification.getName(), serverSpecification.getVersionDetail().getVersion(),\n            namespaceId,\n            meta.getConnectionId());\n        ReleaseMcpServerResponse response = new ReleaseMcpServerResponse();\n        try {\n            // mcp server and version found, means this version of mcp server has been release, throw exception.\n            McpServerBasicInfo existMcpServer =\n                mcpServerOperationService.getMcpServerDetail(namespaceId,\n                    serverSpecification.getId(), serverSpecification.getName(),\n                    serverSpecification.getVersionDetail().getVersion());\n            String version = existMcpServer.getVersionDetail().getVersion();\n            LOGGER.info(\"Mcp Server {} and target version {} already exist.\",\n                existMcpServer.getName(), version);\n            throw new NacosApiException(NacosException.CONFLICT, ErrorCode.MCP_SERVER_VERSION_EXIST,\n                String.format(\n                    \"Mcp Server %s and target version %s already exist, do not do release\",\n                    existMcpServer.getName(), version));\n        } catch (NacosApiException e) {\n            if (ErrorCode.MCP_SERVER_NOT_FOUND.getCode() == e.getDetailErrCode()) {\n                // mcp server not found, create new mcp server.\n                String mcpId = createNewMcpServer(namespaceId, request);\n                response.setMcpId(mcpId);\n                LOGGER.info(\"Mcp Server {} released, Mcp Server id: {}\",\n                    serverSpecification.getName(), mcpId);\n            } else if (ErrorCode.MCP_SEVER_VERSION_NOT_FOUND.getCode() == e.getDetailErrCode()) {\n                // mcp server found but version not found, update mcp server.\n                createNewVersionMcpServer(namespaceId, request);\n                McpServerIndexData mcpServerIndexData =\n                    mcpServerIndex.getMcpServerByName(namespaceId,\n                        serverSpecification.getName());\n                response.setMcpId(mcpServerIndexData.getId());\n                LOGGER.info(\"Mcp Server {} new version {} released, Mcp Server id: {}\",","sourceCodeStart":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/ai/src/main/java/com/alibaba/nacos/ai/remote/handler/ReleaseMcpServerRequestHandler.java#L112-L148","documentation":"Thrown by ReleaseMcpServerRequestHandler.doHandler() when the MCP server already exists AND the target version already exists. doHandler first calls getMcpServerDetail to probe; if both server and version resolve, it throws MCP_SERVER_VERSION_EXIST (CONFLICT). The surrounding catch block then routes MCP_SERVER_NOT_FOUND to create-new and MCP_SEVER_VERSION_NOT_FOUND to new-version, but VERSION_EXIST matches neither and is rethrown, ultimately landing in the response error info.","triggerScenarios":"A ReleaseMcpServerRequest whose serverSpecification name/id and versionDetail.version exactly match an already-released MCP server version. Replaying the same release request, or a CI pipeline re-publishing without bumping the version.","commonSituations":"Idempotent re-deploy that did not change the version; a release pipeline that retries after a partial success; duplicate concurrent release requests for the same version; the version was published manually via console and the automated deploy runs again.","solutions":["Bump the versionDetail.version to a new value if you intend a new release.","If the version is intentionally the same, treat this response as success (the server+version is already present) and skip re-release.","Use the update MCP server API instead of release when you want to change an existing version in place."],"exampleFix":"// before: re-releasing the same version\nspec.getVersionDetail().setVersion(\"1.0.0\"); // already released\n\n// after: bump version for a new release\nspec.getVersionDetail().setVersion(\"1.0.1\");\n// or, if no change is needed, treat the CONFLICT response as a no-op success.","handlingStrategy":"try-catch","validationCode":"// Probe before releasing to avoid the CONFLICT\nMcpServerBasicInfo existing;\ntry {\n    existing = mcpServerOperationService.getMcpServerDetail(namespaceId,\n        spec.getId(), spec.getName(), spec.getVersionDetail().getVersion());\n} catch (NacosApiException e) { /* not found is expected for a new release */ existing = null; }\nif (existing != null) { /* already released; skip or bump version */ }","typeGuard":null,"tryCatchPattern":"ReleaseMcpServerResponse resp = handler.handle(request, meta);\nif (ErrorCode.MCP_SERVER_VERSION_EXIST.getCode() == resp.getDetailErrCode()) {\n    // idempotent: version already published. Treat as success or bump version.\n    return IdempotentResult.alreadyPresent(resp);\n}","preventionTips":["Make release pipelines idempotent: treat MCP_SERVER_VERSION_EXIST as success when no change is intended.","Bump the version string for every distinct release.","Avoid blind retries of the whole release after a partial success; probe first."],"tags":["ai","mcp-server","grpc","conflict","release","version","duplicate"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}