{"record":{"id":"7140e0cfa68ae632","repo":"alibaba/spring-ai-alibaba","slug":"createmcpservererror","errorCode":"CreateMCPServerError","errorMessage":"Failed to create MCPServer. fail parse InstallConfig","messagePattern":"Failed to create MCPServer\\. fail parse InstallConfig","errorType":"error_code","errorClass":"BizException","httpStatus":500,"severity":"error","filePath":"spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-core/src/main/java/com/alibaba/cloud/ai/studio/core/base/service/impl/McpServerServiceImpl.java","lineNumber":121,"sourceCode":"\t\t\t\tthrow new Exception(String.valueOf(checkResult.getMessage()));\n\t\t\t}\n\t\t\tentity.setDeployConfig(checkResult.getData());\n\t\t\tentity.setHost(fetchHost(checkResult.getData()));\n\t\t\tentity.setDetailConfig(detail.getDetailConfig());\n\t\t\tentity.setDescription(detail.getDescription());\n\t\t\tentity.setWorkspaceId(context.getWorkspaceId());\n\t\t\tentity.setAccountId(context.getAccountId());\n\t\t\tentity.setStatus(McpServerStatusEnum.Normal.getCode());\n\t\t\tentity.setBizType(detail.getBizType());\n\t\t\tentity.setInstallType(detail.getInstallType());\n\t\t\tentity.setDeployEnv(detail.getDeployEnv());\n\t\t\tentity.setSource(detail.getSource());\n\t\t\tentity.setType(detail.getType() == null ? McpServerTypeEnum.CUSTOMER.name() : detail.getType());\n\t\t\tthis.save(entity);\n\t\t\treturn serverCode;\n\t\t}\n\t\tcatch (Exception e) {\n\t\t\tthrow new BizException(ErrorCode.CREATE_MCP_ERROR.toError(\"fail parse InstallConfig\"), e);\n\t\t}\n\n\t}\n\n\t/**\n\t * Updates an existing MCP server configuration\n\t * @param detail Updated server configuration\n\t */\n\t@Override\n\tpublic void updateMcp(McpServerDetail detail) {\n\t\ttry {\n\t\t\tRequestContext context = RequestContextHolder.getRequestContext();\n\t\t\tString serverCode = detail.getServerCode();\n\t\t\tMcpServerEntity entity = getMcpByCode(context.getWorkspaceId(), serverCode, null);\n\t\t\tif (entity == null) {\n\t\t\t\tthrow new BizException(MCP_NOT_FOUND.toError());\n\t\t\t}\n\t\t\tentity.setName(detail.getName());","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-core/src/main/java/com/alibaba/cloud/ai/studio/core/base/service/impl/McpServerServiceImpl.java#L103-L139","documentation":"Thrown by McpServerServiceImpl.createMcp when any exception occurs while persisting/processing a new MCP server — in particular when the install/deploy config (InstallConfig) cannot be parsed or validated. The original exception is attached as cause.","triggerScenarios":"Calling createMcp with a detail whose installConfig/deployConfig is malformed JSON, has an unknown installType, or fails mcpManager.processInstallConfig validation, causing the catch-all to wrap the failure.","commonSituations":"Hand-crafted MCP server payloads with invalid command/URL fields, JSON that does not match the InstallConfig schema, new install types not supported by the deployed manager version.","solutions":["Inspect the cause exception in server logs to see the exact parse/validation failure.","Validate the installConfig JSON against the expected InstallConfig schema (correct fields for stdio vs sse type) before calling createMcp.","Check installType is a supported value and matches the deployConfig format; correct and retry."],"exampleFix":"// before: malformed install config\n{\"installType\": \"stdio\"}  // missing command/args\n// after\n{\"installType\": \"stdio\", \"command\": \"npx\", \"args\": [\"-y\", \"@modelcontextprotocol/server-everything\"]}","handlingStrategy":"validation","validationCode":"if (detail.getInstallConfig() == null) throw new IllegalArgumentException(\"installConfig required\");\n// pre-validate with the same manager used server-side\nResult<String> check = mcpManager.processInstallConfig(detail.getDeployConfig(), detail.getInstallType());\nif (!check.isSuccess()) throw new IllegalArgumentException(\"Invalid InstallConfig: \" + check.getMessage());","typeGuard":null,"tryCatchPattern":"try {\n    mcpService.createMcp(detail);\n} catch (BizException e) {\n    if (\"CreateMCPServerError\".equals(e.getCode())) {\n        log.error(\"MCP create failed\", e.getCause()); // inspect cause for parse error\n    } else { throw e; }\n}","preventionTips":["Validate InstallConfig JSON against schema before calling createMcp","Match installType with the deployConfig shape (stdio vs sse)","Check server logs for the wrapped cause"],"tags":["mcp","config","json","parse"],"backgroundTag":"json-unmarshal-failed","analyzedSha":"f82da0b50f35744c13968191be2b1cd2452ef550","analyzedAt":"2026-09-09T15:32:42.421Z","contentChangedAt":"2026-09-09T15:32:42.421Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}