{"record":{"id":"dfffed73e8a3ea86","repo":"alibaba/arthas","slug":"failed-to-initialize-arthas-mcp-server","errorCode":null,"errorMessage":"Failed to initialize Arthas MCP server","messagePattern":"Failed to initialize Arthas MCP server","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"critical","filePath":"core/src/main/java/com/taobao/arthas/core/mcp/ArthasMcpBootstrap.java","lineNumber":52,"sourceCode":"    }\n\n    public ArthasMcpServer start() {\n        logger.info(\"Initializing Arthas MCP Bootstrap...\");\n        try {\n            logger.debug(\"Creating MCP server instance with command executor: {}\", \n                    commandExecutor.getClass().getSimpleName());\n            \n            // Create and start MCP server with CommandExecutor and custom endpoint\n            mcpServer = new ArthasMcpServer(mcpEndpoint, commandExecutor, protocol);\n            logger.debug(\"MCP server instance created successfully\");\n            \n            mcpServer.start();\n            logger.info(\"Arthas MCP server initialized successfully\");\n            logger.info(\"Bootstrap ready - server is operational\");\n            return mcpServer;\n        } catch (Exception e) {\n            logger.error(\"Failed to initialize Arthas MCP server\", e);\n            throw new RuntimeException(\"Failed to initialize Arthas MCP server\", e);\n        }\n    }\n\n    public void shutdown() {\n        logger.info(\"Initiating Arthas MCP Bootstrap shutdown...\");\n        if (mcpServer != null) {\n            logger.debug(\"Stopping MCP server...\");\n            mcpServer.stop();\n            logger.info(\"MCP server stopped\");\n        } else {\n            logger.warn(\"MCP server was null during shutdown - may not have been properly initialized\");\n        }\n        logger.info(\"Arthas MCP Bootstrap shutdown completed\");\n    }\n}\n","sourceCodeStart":34,"sourceCodeEnd":68,"githubUrl":"https://github.com/alibaba/arthas/blob/21cf2e9ba52b305290be7223b980ff504bb9cb5b/core/src/main/java/com/taobao/arthas/core/mcp/ArthasMcpBootstrap.java#L34-L68","documentation":"Thrown as a RuntimeException by ArthasMcpBootstrap.start() wrapping any Exception that occurs while creating or starting the MCP server (the inner ArthasMcpServer construction or its start() call). The bootstrap logs the underlying cause and rethrows, so the original exception is available as the cause for diagnostics.","triggerScenarios":"Calling ArthasMcpBootstrap.start() when the MCP endpoint is invalid/unavailable, the CommandExecutor is misconfigured, port binding fails, or the inner server start throws. Any exception inside the try block (lines 38-49) triggers this.","commonSituations":"MCP endpoint already in use; null CommandExecutor; protocol misconfiguration; tool scanning failure propagating up; the inner 'Failed to start Arthas MCP server' (error 92) bubbling through here.","solutions":["Inspect the logged cause (logger.error logs the full exception) — fix the root failure it reports (often error 92).","Ensure the mcpEndpoint is free and correctly formatted, and the protocol is 'streamable' or 'stateless'.","Confirm the CommandExecutor passed to the bootstrap is non-null and initialised.","Retry after freeing the port / fixing configuration."],"exampleFix":"// before\nnew ArthasMcpBootstrap(executor, endpoint, protocol).start();  // endpoint busy\n// after\n// free the port / use a free endpoint, then start\nnew ArthasMcpBootstrap(executor, freeEndpoint, protocol).start();","handlingStrategy":"try-catch","validationCode":"// Pre-checks before starting the bootstrap\nObjects.requireNonNull(commandExecutor, \"commandExecutor\");\nif (mcpEndpoint == null || mcpEndpoint.trim().isEmpty())\n    throw new IllegalArgumentException(\"mcpEndpoint required\");","typeGuard":"null","tryCatchPattern":"try {\n    bootstrap.start();\n} catch (RuntimeException e) {\n    // 'Failed to initialize Arthas MCP server' — inspect e.getCause()\n    Throwable root = e.getCause() != null ? e.getCause() : e;\n    log.error(\"MCP init failed; root cause: {}\", root.getMessage(), root);\n    // fix the root cause (often error 92: port/endpoint in use), then retry\n}","preventionTips":["Inspect the wrapped cause to find the real failure (usually error 92).","Ensure the MCP endpoint is free and the protocol is valid before start().","Pass a non-null, initialised CommandExecutor."],"tags":["arthas","mcp","server","startup","runtime-exception"],"backgroundTag":null,"analyzedSha":"21cf2e9ba52b305290be7223b980ff504bb9cb5b","analyzedAt":"2026-08-14T00:57:07.243Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}