can1357/oh-my-pi · error · Error
Unknown server type: ${serverType}
Error message
Unknown server type: ${serverType} What it means
createTransport dispatches on the MCP server config's type field ('stdio' | 'http' | 'sse'); any other value reaches the default branch and throws 'Unknown server type: <type>'. It guards the transport factory against misconfigured or future-unknown server type strings.
Source
Thrown at packages/coding-agent/src/mcp/client.ts:84
throw Object.assign(new Error(`Unsupported server request: ${method}`), { code: -32601 });
}
}
/**
* Create a transport for the given server config.
*/
async function createTransport(config: MCPServerConfig): Promise<MCPTransport> {
const serverType = config.type ?? "stdio";
switch (serverType) {
case "stdio":
return createStdioTransport(config as MCPStdioServerConfig);
case "http":
return createHttpTransport(config as MCPHttpServerConfig);
case "sse":
return createSseTransport(config as MCPSseServerConfig);
default:
throw new Error(`Unknown server type: ${serverType}`);
}
}
/**
* Initialize connection with MCP server.
*/
async function initializeConnection(
transport: MCPTransport,
options?: {
signal?: AbortSignal;
/** Called after notifications/initialized succeeds. */
onInitialized?: () => void | Promise<void>;
},
): Promise<MCPInitializeResult> {
const params: MCPInitializeParams = {
protocolVersion: MCP_PROTOCOL_VERSION,
capabilities: {
roots: { listChanged: false },View on GitHub (pinned to 9690622007)
Solutions
- Fix the server's 'type' in the MCP config to one of: stdio, http, or sse.
- Check for typos/whitespace in the type string and validate the JSON config.
- Update the CLI if the config was authored by a newer tool using a new transport type.
- Use the /mcp add wizard, which writes valid types instead of hand-editing.
Example fix
// before (MCP config JSON)
{ "myserver": { "type": "websocket", "url": "http://localhost:3000" } }
// after
{ "myserver": { "type": "http", "url": "http://localhost:3000" } } Defensive patterns
Strategy: validation
Validate before calling
const TRANSPORT_TYPES = new Set(["stdio", "http", "sse"]);
function assertValidTransportType(cfg: { type: string }): void {
if (!TRANSPORT_TYPES.has(cfg.type)) {
throw new Error(`Config pre-check: unknown MCP server type '${cfg.type}' (expected stdio|http|sse)`);
}
} Type guard
function isKnownServerType(t: string): t is "stdio" | "http" | "sse" {
return t === "stdio" || t === "http" || t === "sse";
} Try / catch
try {
await connectToServer(name, config);
} catch (err) {
if (err instanceof Error && err.message.startsWith("Unknown server type:")) {
console.error(`${err.message} — fix 'type' in the MCP config (stdio|http|sse)`);
return;
}
throw err;
} Prevention
- Validate MCP config JSON against a schema before loading.
- Use the /mcp add wizard instead of hand-editing type fields.
- Trim/normalize the type string when reading third-party configs.
- Keep the client updated for newly introduced transport types.
When it happens
Trigger: connect() → createTransport() with a config whose type is misspelled (e.g. 'websocket', 'http2', or with stray whitespace) or from a newer config schema the client doesn't recognize.
Common situations: Hand-edited MCP config with a wrong 'type' value; config copied from another tool using different transport names; config written by a newer client version introducing an unsupported type.
Related errors
- No MCP manager available. MCP servers may not be configured.
- nameError (dynamic message from validateServerName, e.g. "Se
- MCP OAuth credential is missing refresh material
- Transport not connected
- Unsupported MCP server transport: ${server.type}
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/8ca229c7f6639ed8.
Report an issue: GitHub.