Mintplex-Labs/anything-llm · error · Error
MCP server "${name}": invalid URL "${server.url}"
Error message
MCP server "${name}": invalid URL "${server.url}" What it means
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.
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 typeView on GitHub (pinned to 526360e320)
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.
Example fix
// before
{
"myServer": { "url": "localhost:8000/mcp" }
}
// after
{
"myServer": { "url": "http://localhost:8000/mcp" }
} Defensive patterns
Strategy: validation
Validate before calling
function isValidUrlString(u) {
try { new URL(u); return true; } catch { return false; }
}
// before starting:
if (!isValidUrlString(server.url)) {
throw new Error(`MCP server '${name}' has an invalid url '${server.url}'. Include the scheme (http:// or https://).`);
} Type guard
/** @param {unknown} u */
function isAbsoluteUrl(u) {
if (typeof u !== 'string') return false;
try { const p = new URL(u); return p.protocol === 'http:' || p.protocol === 'https:'; } catch { return false; }
} Try / catch
try {
new URL(server.url);
} catch {
throw new Error(`MCP server '${name}' url '${server.url}' is not a valid absolute URL — add http:// or https://`);
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- MCP server type must have sse or streamable value.
- MCP server "${name}": missing required "url" for ${server.ty
- MCP server command or url is required
- MCP server args must be an array
- MCP server name is required
AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13).
Data as JSON: /api/errors/8fb31d9f860dd46e.
Report an issue: GitHub.