{"record":{"id":"cae9ebd231bc9ce9","repo":"Mintplex-Labs/anything-llm","slug":"mcp-server-name-is-required","errorCode":null,"errorMessage":"MCP server name is required","messagePattern":"MCP server name is required","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/utils/MCP/hypervisor/index.js","lineNumber":449,"sourceCode":"          },\n        });\n      default:\n        return new SSEClientTransport(url, {\n          requestInit: {\n            headers: server.headers,\n          },\n        });\n    }\n  }\n\n  /**\n   * @private Start a single MCP server by its server definition from the JSON file\n   * @param {string} name - The name of the MCP server to start\n   * @param {Object} server - The server definition\n   * @returns {Promise<boolean>}\n   */\n  async #startMCPServer({ name, server }) {\n    if (!name) throw new Error(\"MCP server name is required\");\n    if (!server) throw new Error(\"MCP server definition is required\");\n    const serverType = this.#parseServerType(server);\n    if (!serverType) throw new Error(\"MCP server command or url is required\");\n\n    this.#validateServerDefinitionByType(name, server, serverType);\n    this.log(`Attempting to start MCP server: ${name}`);\n    const mcp = new Client({ name: name, version: \"1.0.0\" });\n    const transport = await this.#setupServerTransport(server, serverType);\n\n    // Add connection event listeners\n    transport.onclose = () => this.log(`${name} - Transport closed`);\n    transport.onerror = (error) =>\n      this.log(`${name} - Transport error:`, error);\n    transport.onmessage = (message) =>\n      this.log(`${name} - Transport message:`, message);\n\n    // Connect and await the connection with a timeout\n    this.mcps[name] = mcp;","sourceCodeStart":431,"sourceCodeEnd":467,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/MCP/hypervisor/index.js#L431-L467","documentation":"Thrown by the private #startMCPServer in the MCP hypervisor when the `name` argument is falsy. Every MCP server in mcp_servers.json is keyed by its name (Object.entries of mcpServers), so a missing name implies a malformed config or a direct/programmatic call that passed an empty or undefined name. It is a defensive precondition guard before any transport is built.","triggerScenarios":"Calling #startMCPServer({ name: \"\" }) or { name: undefined } or omitting the key. In normal flow this happens only if mcp_servers.json contains an entry with an empty string key, or a test/extension invokes the boot path with a hand-built definition lacking a name.","commonSituations":"Manually editing mcp_servers.json and leaving an empty key like \"\": { \"command\": [...] }; a corrupted/truncated config file; calling the hypervisor restart/boot APIs with a server name that resolved to empty after trimming.","solutions":["Open mcp_servers.json and verify every key under mcpServers is a non-empty unique string (e.g. \"docker-mcp\", not \"\").","If calling restartMCPServer/boot programmatically, ensure the name you pass is a trimmed non-empty string before invoking.","Validate the JSON with a linter or json.parse to ensure no empty or duplicate keys exist.","Regenerate the file via the AnythingLLM UI's MCP server settings rather than hand-editing."],"exampleFix":"// before (mcp_servers.json)\n{\n  \"mcpServers\": {\n    \"\": { \"command\": [\"node\", \"srv.js\"] }\n  }\n}\n// after\n{\n  \"mcpServers\": {\n    \"my-server\": { \"command\": [\"node\", \"srv.js\"] }\n  }\n}","handlingStrategy":"validation","validationCode":"// Before booting, validate every entry has a non-empty name.\nconst defs = hypervisor.mcpServerConfigs;\nconst invalid = defs.filter((d) => !d.name || !d.name.trim());\nif (invalid.length) {\n  throw new Error(`MCP config has ${invalid.length} entry/entries with a missing name`);\n}","typeGuard":"/** True when an MCP server entry has a usable name. */\nfunction hasValidName(entry) {\n  return (\n    entry !== null &&\n    typeof entry === \"object\" &&\n    typeof entry.name === \"string\" &&\n    entry.name.trim().length > 0\n  );\n}","tryCatchPattern":"try {\n  await hypervisor.bootMCPServers();\n} catch (e) {\n  if (/name is required/i.test(e.message)) {\n    // surface a config-level message rather than a raw throw\n    logger.error(\"MCP config has an entry with a missing/empty name — fix mcp_servers.json\");\n  }\n  throw e;\n}","preventionTips":["Always add MCP servers via the AnythingLLM UI so the name key is enforced non-empty.","Treat mcp_servers.json as machine-written; lint it on CI with a schema validator (e.g. ajv).","Never hand-edit an entry to use an empty string key."],"tags":["mcp","configuration","validation"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}