NousResearch/hermes-agent · warning · Error
Bearer token required
Error message
Bearer token required
What it means
When an HTTP-transport MCP server selects header auth (httpAuth === 'header'), a bearer token is mandatory and is sent as bearer_token in the create payload. A whitespace-only token fails the trim check and throws client-side.
Source
Thrown at web/src/lib/mcp-server-create.ts:58
if (!line) continue;
const separator = line.indexOf("=");
if (separator === -1) continue;
const key = line.slice(0, separator).trim();
const value = line.slice(separator + 1).trim();
if (key) env[key] = value;
}
return env;
}
export function buildMcpServerCreate(draft: McpServerDraft): McpServerCreate {
const name = draft.name.trim();
if (!name) throw new Error("Name required");
if (draft.transport === "http") {
const url = draft.url.trim();
if (!url) throw new Error("URL required");
if (draft.httpAuth === "header" && !draft.bearerToken.trim()) {
throw new Error("Bearer token required");
}
const server: McpServerCreate = { name, url };
if (draft.httpAuth !== "none") server.auth = draft.httpAuth;
if (draft.httpAuth === "header") {
server.bearer_token = draft.bearerToken;
}
return server;
}
const command = draft.command.trim();
if (!command) throw new Error("Command required");
const server: McpServerCreate = { name, command };
const args = parseArgs(draft.args);
if (args.length) server.args = args;
const env = parseEnv(draft.env);
if (Object.keys(env).length) server.env = env;View on GitHub (pinned to c896c09c42)
Solutions
- Paste the server's bearer token into the token field and submit.
- If the server needs no auth header, set auth to 'none'; if it uses OAuth, pick that option instead.
- Disable submit until bearerToken.trim() is non-empty when httpAuth === 'header'.
Defensive patterns
Strategy: validation
Validate before calling
if (draft.transport === 'http' && draft.httpAuth === 'header' && !draft.bearerToken.trim()) {
setFieldError('bearerToken', 'Bearer token is required for header auth')
return
} Type guard
function hasBearerWhenHeader(d: McpServerDraft): boolean {
return d.httpAuth !== 'header' || d.bearerToken.trim().length > 0
} Try / catch
try {
const payload = buildMcpServerCreate(draft)
} catch (err) {
if (String(err) === 'Bearer token required') { focusField('bearerToken'); return }
throw err
} Prevention
- Reset the auth choice to 'none' when the user leaves the token blank.
- Never log or persist the bearer token beyond the create call.
- Validate token presence before enabling submit when header auth is selected.
When it happens
Trigger: Choosing 'Bearer token' auth in the add-server form but leaving the token field empty; pasting only whitespace; state where httpAuth defaults to 'header' before the user enters a token.
Common situations: Users selecting header auth 'just in case' without a token; autofill failing on password-type inputs; form resubmission after a failed attempt clearing the token field.
Related errors
- Name required
- URL required
- Command required
- Remote gateway session token is required.
- Preview mode — launching is disabled.
AI-assisted analysis of NousResearch/hermes-agent@c896c09c42 (2026-08-14).
Data as JSON: /api/errors/737a567b1ea938ef.
Report an issue: GitHub.