{"record":{"id":"8fb31d9f860dd46e","repo":"Mintplex-Labs/anything-llm","slug":"mcp-server-name-invalid-url-server-url","errorCode":null,"errorMessage":"MCP server \"${name}\": invalid URL \"${server.url}\"","messagePattern":"MCP server \"(.+?)\": invalid URL \"(.+?)\"","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/utils/MCP/hypervisor/index.js","lineNumber":384,"sourceCode":"      // \"type\" is optional for http servers - when omitted, SSE is assumed\n      // (see createHttpTransport). An explicit unknown value is a config error.\n      if (\n        server.type !== undefined &&\n        ![\"sse\", \"streamable\", \"http\"].includes(server.type)\n      ) {\n        throw new Error(\"MCP server type must have sse or streamable value.\");\n      }\n\n      if (!server.url) {\n        throw new Error(\n          `MCP server \"${name}\": missing required \"url\" for ${server.type || \"sse\"} transport`\n        );\n      }\n\n      try {\n        new URL(server.url);\n      } catch {\n        throw new Error(`MCP server \"${name}\": invalid URL \"${server.url}\"`);\n      }\n      return;\n    }\n\n    if (type === \"stdio\") {\n      if (\n        Object.prototype.hasOwnProperty.call(server, \"args\") &&\n        !Array.isArray(server.args)\n      )\n        throw new Error(\"MCP server args must be an array\");\n    }\n    return;\n  }\n\n  /**\n   * Setup the server transport by type and server definition\n   * @param {Object} server - The server definition\n   * @param {MCPServerTypes} type - The server type","sourceCodeStart":366,"sourceCodeEnd":402,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/MCP/hypervisor/index.js#L366-L402","documentation":"Thrown by #validateServerDefinitionByType when server.url is present but `new URL(server.url)` throws — i.e. the value is not a parseable absolute URL. The caught exception is swallowed and replaced with a message naming the server and echoing the offending string. This runs only for http-classified servers and after the missing-url check.","triggerScenarios":"A server url that is a relative path (e.g. /mcp), missing the scheme (e.g. localhost:8000 instead of http://localhost:8000), contains illegal characters, has whitespace, or is otherwise malformed so the WHATWG URL parser rejects it.","commonSituations":"Omitting the http:// or https:// scheme (the most common cause — 'localhost:8000' is not a valid absolute URL); trailing/leading spaces from copy-paste; using a protocol the parser rejects; relative paths meant for a stdio server mistakenly placed under url.","solutions":["Prefix the url with the scheme: http:// or https:// (e.g. http://localhost:8000, not localhost:8000).","Trim whitespace around the url value.","Ensure the url is absolute (includes host), not a relative path.","The message echoes the bad value — compare it against a known-good URL."],"exampleFix":"// before\n{\n  \"myServer\": { \"url\": \"localhost:8000/mcp\" }\n}\n\n// after\n{\n  \"myServer\": { \"url\": \"http://localhost:8000/mcp\" }\n}","handlingStrategy":"validation","validationCode":"function isValidUrlString(u) {\n  try { new URL(u); return true; } catch { return false; }\n}\n// before starting:\nif (!isValidUrlString(server.url)) {\n  throw new Error(`MCP server '${name}' has an invalid url '${server.url}'. Include the scheme (http:// or https://).`);\n}","typeGuard":"/** @param {unknown} u */\nfunction isAbsoluteUrl(u) {\n  if (typeof u !== 'string') return false;\n  try { const p = new URL(u); return p.protocol === 'http:' || p.protocol === 'https:'; } catch { return false; }\n}","tryCatchPattern":"try {\n  new URL(server.url);\n} catch {\n  throw new Error(`MCP server '${name}' url '${server.url}' is not a valid absolute URL — add http:// or https://`);\n}","preventionTips":["Always include the scheme (http:// or https://) — 'localhost:8000' alone is invalid.","Trim whitespace around url values copied from elsewhere.","Validate with new URL() in your config loader before the hypervisor sees it.","Use absolute URLs only, never relative paths."],"tags":["mcp","configuration","validation","malformed-url","transport"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}