{"record":{"id":"4a01648d7ec3baaf","repo":"Mintplex-Labs/anything-llm","slug":"mcp-server-name-is-not-currently-running","errorCode":null,"errorMessage":"MCP server ${name} is not currently running","messagePattern":"MCP server (.+?) is not currently running","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/utils/MCP/index.js","lineNumber":83,"sourceCode":"            name: `${name}-${tool.name}`,\n            setup: (aibitat) => {\n              aibitat.function({\n                super: aibitat,\n                name: `${name}-${tool.name}`,\n                controller: new AbortController(),\n                description: tool.description,\n                isMCPTool: true,\n                examples: [],\n                parameters: {\n                  $schema: \"http://json-schema.org/draft-07/schema#\",\n                  ...tool.inputSchema,\n                },\n                handler: async function (args = {}) {\n                  try {\n                    const mcpLayer = new MCPCompatibilityLayer();\n                    const currentMcp = mcpLayer.mcps[name];\n                    if (!currentMcp)\n                      throw new Error(\n                        `MCP server ${name} is not currently running`\n                      );\n\n                    aibitat.handlerProps.log(\n                      `Executing MCP server: ${name}:${tool.name} with args:`,\n                      args\n                    );\n                    aibitat.introspect(\n                      `Executing MCP server: ${name} with ${JSON.stringify(args, null, 2)}`\n                    );\n                    const result = await currentMcp.callTool({\n                      name: tool.name,\n                      arguments: args,\n                    });\n                    aibitat.handlerProps.log(\n                      `MCP server: ${name}:${tool.name} completed successfully`,\n                      result\n                    );","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/MCP/index.js#L65-L101","documentation":"Thrown inside the agent tool handler built by MCPCompatibilityLayer.convertServerToolsToPlugins. The plugin was registered at boot time (so the server was alive then), but when the agent actually invokes the tool, mcpLayer.mcps[name] is undefined — the underlying MCP Client was never connected, crashed, timed out, or was killed/restarted after registration. The handler guards against calling callTool on a missing client.","triggerScenarios":"An MCP server process exited or its stdio/SSE transport dropped between boot and tool invocation; calling restartMCPServer or killMCPServer cleared this.mcps before the agent fired the tool; a 30s connection timeout left the server unregistered; running an agent flow immediately after a failed/partial boot.","commonSituations":"Long-lived agent sessions where the MCP child process is OOM-killed; remote SSE server with an unstable network; developer manually restarted the MCP layer mid-session; Docker container where the MCP command binary is missing so the process exits.","solutions":["Check the MCP hypervisor logs for 'Transport closed' / 'Transport error' / 'Connection timeout' on that server name.","Run activeMCPServers()/bootMCPServers() to confirm the server is in this.mcps before issuing agent tasks.","Increase the 30s connection timeout or fix the slow-starting MCP server so connect() completes.","For stdio servers, verify the command binary exists in PATH inside the container (Node, npx, python, etc.).","Restart the AnythingLLM process (or call restartMCPServer) and retry the agent task."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Before dispatching an agent task that uses MCP tools, confirm the server is live.\nconst layer = new MCPCompatibilityLayer();\nawait layer.bootMCPServers();\nconst live = Object.keys(layer.mcps);\nfor (const needed of requiredServers) {\n  if (!live.includes(needed)) {\n    throw new Error(`Required MCP server \"${needed}\" is not running; cannot run agent task`);\n  }\n}","typeGuard":null,"tryCatchPattern":"// The agent handler already catches this and returns a user-facing string.\n// At the orchestration layer, retry once after re-booting:\ntry {\n  return await agent.run();\n} catch (e) {\n  if (/is not currently running/i.test(e.message)) {\n    await new MCPCompatibilityLayer().bootMCPServers(); // re-establish\n    return await agent.run(); // single retry\n  }\n  throw e;\n}","preventionTips":["Increase the 30s connect timeout if your MCP server is slow to start.","Monitor 'Transport closed/error' logs and auto-restart failed servers.","Keep agent sessions short relative to MCP server uptime, or implement a heartbeat.","Ensure the MCP command binary exists in the runtime PATH before booting."],"tags":["mcp","runtime","agent","lifecycle"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}