different-ai/openwork · error
server_name is required
Error message
server_name is required
What it means
Thrown by `opencodeMcpAuth` in the Electron runtime when the `serverName` argument is missing, null, or whitespace-only. The server name identifies which MCP server to authenticate with via the `opencode` CLI, so it is validated (trimmed, non-empty) before the binary is resolved and executed.
Source
Thrown at apps/desktop/electron/runtime.mjs:2269
env: { ...(await buildChildEnv()), OPENCODE_INSTALL_DIR: installDir },
timeoutMs: 180_000,
});
return {
ok: result.status === 0,
status: result.status,
stdout: result.stdout,
stderr: result.stderr,
};
}
async function opencodeMcpAuth(projectDir, serverName) {
const safeProjectDir = String(projectDir ?? "").trim();
const safeServerName = String(serverName ?? "").trim();
if (!safeProjectDir) {
throw new Error("project_dir is required");
}
if (!safeServerName) {
throw new Error("server_name is required");
}
const program = resolveBinary("opencode");
if (!program) {
throw new Error("Failed to locate opencode.");
}
const result = await runShellCommand(program, ["mcp", "auth", safeServerName], {
cwd: safeProjectDir,
env: await buildChildEnv(),
timeoutMs: 120_000,
});
return {
ok: result.status === 0,
status: result.status,
stdout: result.stdout,
stderr: result.stderr,
};View on GitHub (pinned to 2b7df46e8a)
Solutions
- Pass the actual MCP server name (non-empty string) to opencodeMcpAuth
- Validate/trim serverName at the call site and surface a UI message if it is blank
- Fix the data source so server entries always carry a name
Example fix
// before
await opencodeMcpAuth(projectDir, selectedServer?.name);
// after
const name = selectedServer?.name?.trim();
if (!name) throw new Error('Select an MCP server first');
await opencodeMcpAuth(projectDir, name); Defensive patterns
Strategy: validation
Validate before calling
function hasServerName(name) {
return typeof name === 'string' && name.trim().length > 0;
} Type guard
function isNamedServer(s) {
return typeof s?.name === 'string' && s.name.trim().length > 0;
} Try / catch
try {
await opencodeMcpAuth(projectDir, serverName);
} catch (e) {
if (e.message === 'server_name is required') {
showError('Select an MCP server to authenticate');
} else throw e;
} Prevention
- Validate server entries (name present) when loading MCP config
- Disable per-server auth buttons when the entry lacks a name
- Trim and check identifiers coming from renderer IPC
When it happens
Trigger: Calling `opencodeMcpAuth(projectDir)`, `opencodeMcpAuth(projectDir, undefined)`, `opencodeMcpAuth(projectDir, null)` or `opencodeMcpAuth(projectDir, " ")`.
Common situations: Renderer sends an MCP auth request for a server entry that was deleted or never had a name; a list-selection bug passing an empty identifier; deserialized config where serverName defaulted to an empty string.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- project_dir is required
- Failed to locate opencode.
- invalid_mcp_token_payload
- invalid_mcp_connection_payload
- Electron desktop helper is unavailable: ${command}
AI-assisted analysis of different-ai/openwork@2b7df46e8a (2026-09-01).
Data as JSON: /api/errors/4c54b3b2b794b74c.
Report an issue: GitHub.