Mintplex-Labs/anything-llm · error · Error

MCP server name is required

Error message

MCP server name is required

What it means

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.

Source

Thrown at server/utils/MCP/hypervisor/index.js:449

          },
        });
      default:
        return new SSEClientTransport(url, {
          requestInit: {
            headers: server.headers,
          },
        });
    }
  }

  /**
   * @private Start a single MCP server by its server definition from the JSON file
   * @param {string} name - The name of the MCP server to start
   * @param {Object} server - The server definition
   * @returns {Promise<boolean>}
   */
  async #startMCPServer({ name, server }) {
    if (!name) throw new Error("MCP server name is required");
    if (!server) throw new Error("MCP server definition is required");
    const serverType = this.#parseServerType(server);
    if (!serverType) throw new Error("MCP server command or url is required");

    this.#validateServerDefinitionByType(name, server, serverType);
    this.log(`Attempting to start MCP server: ${name}`);
    const mcp = new Client({ name: name, version: "1.0.0" });
    const transport = await this.#setupServerTransport(server, serverType);

    // Add connection event listeners
    transport.onclose = () => this.log(`${name} - Transport closed`);
    transport.onerror = (error) =>
      this.log(`${name} - Transport error:`, error);
    transport.onmessage = (message) =>
      this.log(`${name} - Transport message:`, message);

    // Connect and await the connection with a timeout
    this.mcps[name] = mcp;

View on GitHub (pinned to 526360e320)

Solutions

  1. Open mcp_servers.json and verify every key under mcpServers is a non-empty unique string (e.g. "docker-mcp", not "").
  2. If calling restartMCPServer/boot programmatically, ensure the name you pass is a trimmed non-empty string before invoking.
  3. Validate the JSON with a linter or json.parse to ensure no empty or duplicate keys exist.
  4. Regenerate the file via the AnythingLLM UI's MCP server settings rather than hand-editing.

Example fix

// before (mcp_servers.json)
{
  "mcpServers": {
    "": { "command": ["node", "srv.js"] }
  }
}
// after
{
  "mcpServers": {
    "my-server": { "command": ["node", "srv.js"] }
  }
}
Defensive patterns

Strategy: validation

Validate before calling

// Before booting, validate every entry has a non-empty name.
const defs = hypervisor.mcpServerConfigs;
const invalid = defs.filter((d) => !d.name || !d.name.trim());
if (invalid.length) {
  throw new Error(`MCP config has ${invalid.length} entry/entries with a missing name`);
}

Type guard

/** True when an MCP server entry has a usable name. */
function hasValidName(entry) {
  return (
    entry !== null &&
    typeof entry === "object" &&
    typeof entry.name === "string" &&
    entry.name.trim().length > 0
  );
}

Try / catch

try {
  await hypervisor.bootMCPServers();
} catch (e) {
  if (/name is required/i.test(e.message)) {
    // surface a config-level message rather than a raw throw
    logger.error("MCP config has an entry with a missing/empty name — fix mcp_servers.json");
  }
  throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13). Data as JSON: /api/errors/cae9ebd231bc9ce9. Report an issue: GitHub.