Mintplex-Labs/anything-llm · error

MCP server " ": invalid URL

Error message

MCP server "${name}": invalid URL "${server.url}"

What it means

After confirming an http MCP server has a url, the hypervisor runs it through the URL constructor (new URL(server.url)). If parsing throws, this templated error names the offending server and url. It catches syntactically invalid URLs, not unreachable ones — connectivity is checked later at connect time.

Solutions

  1. Use a full absolute URL with scheme, e.g. "https://example.com/mcp" or "http://localhost:3000/mcp"
  2. URL-encode any spaces or special characters in the path
  3. Paste the URL into a browser or curl to confirm it is syntactically well-formed
  4. Re-boot MCP servers after fixing the JSON

Example fix

// before
{ "my-server": { "type": "streamable", "url": "example.com/mcp" } }

// after
{ "my-server": { "type": "streamable", "url": "https://example.com/mcp" } }
Defensive patterns

Strategy: validation

Validate before calling

function assertValidUrl(name, url) {
  try { new URL(url); }
  catch { throw new Error(`Server "${name}": "${url}" is not a valid URL — include the scheme (https://)`); }
}

Type guard

function isParsableUrl(value) {
  try { new URL(value); return true; } catch { return false; }
}

Try / catch

try {
  await hypervisor.bootMCPServers();
} catch (err) {
  if (err.message.includes('invalid URL')) {
    // extract the URL from the message and highlight the field
  }
  throw err;
}

Prevention

When it happens

Trigger: url values like "localhost:3000/mcp" (no scheme), "https//example.com/mcp" (missing colon), URLs with spaces or unencoded characters, or a bare hostname such as "example.com".

Common situations: Copy-pasting an endpoint without the https:// prefix; missing the colon in the scheme; passing a server name or host instead of a full URL; unencoded query characters in the path.

Understand the failure class

Background: "Invalid URL" errors: why new URL(), URI.parse, and reqwest::Url reject your string — missing scheme, whitespace, and bad path format — this error's family across 39 libraries.

Related errors


AI-assisted analysis of Mintplex-Labs/anything-llm@3aec848f28 (2026-08-18). Data as JSON: /api/errors/8fb31d9f860dd46e. Report an issue: GitHub.

Appendix: source

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

      // "type" is optional for http servers - when omitted, SSE is assumed
      // (see createHttpTransport). An explicit unknown value is a config error.
      if (
        server.type !== undefined &&
        !["sse", "streamable", "http"].includes(server.type)
      ) {
        throw new Error("MCP server type must have sse or streamable value.");
      }

      if (!server.url) {
        throw new Error(
          `MCP server "${name}": missing required "url" for ${server.type || "sse"} transport`
        );
      }

      try {
        new URL(server.url);
      } catch {
        throw new Error(`MCP server "${name}": invalid URL "${server.url}"`);
      }
      return;
    }

    if (type === "stdio") {
      if (
        Object.prototype.hasOwnProperty.call(server, "args") &&
        !Array.isArray(server.args)
      )
        throw new Error("MCP server args must be an array");
    }
    return;
  }

  /**
   * Setup the server transport by type and server definition
   * @param {Object} server - The server definition
   * @param {MCPServerTypes} type - The server type

View on GitHub (pinned to 3aec848f28)