siyuan-note/siyuan · error

start command

Error message

start command: %w

What it means

connectStdio spawns the configured command with cmd.Start() and wraps any failure with the "start command:" prefix. Start fails before any MCP traffic: the executable could not be found, was not executable, or the process could not be forked. The child never runs, so the MCP session cannot be established.

Solutions

  1. Verify the command exists and is executable: run it manually in a shell with the same user/environment
  2. Use an absolute path to the executable instead of relying on PATH
  3. Install the missing runtime/package (e.g. Node for npx-based servers) or correct the spelling
  4. Check resource limits (memory, PIDs) if the command exists but the fork still fails

Example fix

// before
{"type": "stdio", "command": "mcp-server-everything"}
// after
{"type": "stdio", "command": "/usr/local/bin/mcp-server-everything"} // or install the package first
Defensive patterns

Strategy: validation

Validate before calling

path, err := exec.LookPath(server.Command)
if err != nil {
    return fmt.Errorf("stdio command %q not found for server %s", server.Command, server.Name)
}
if info, err := os.Stat(path); err == nil && info.Mode()&0o111 == 0 {
    return fmt.Errorf("%s is not executable", path)
}

Type guard

null

Try / catch

if err := connectStdio(ctx, client, server); err != nil {
    if strings.Contains(err.Error(), "start command") {
        return fmt.Errorf("cannot launch %q for server %q: %w", server.Command, server.Name, err)
    }
    return err
}

Prevention

When it happens

Trigger: connectStdio calls cmd.Start() on a conf.MCPServer whose Command does not exist on PATH, lacks the execute bit, or cannot be forked due to resource limits.

Common situations: Typo in the command name or the package not installed (npx cannot resolve it), command installed only inside a different environment (Docker, another user's PATH), missing execute permission, or fork failures under memory/PID limits.

Related errors


AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19). Data as JSON: /api/errors/bf4689be1d03c4d4. Report an issue: GitHub.

Appendix: source

Thrown at kernel/mcp/client/mcp.go:477

		}
		return conf.ResolveSecretsVars(model.Conf.Secrets, model.Conf.Variables, value)
	}, runtime.GOOS)
	if err != nil {
		return nil, nil, fmt.Errorf("environment: %w", err)
	}
	cmd.Env = cmdEnv
	stdin, err := cmd.StdinPipe()
	if err != nil {
		return nil, nil, fmt.Errorf("stdin pipe: %w", err)
	}
	stdout, err := cmd.StdoutPipe()
	if err != nil {
		return nil, nil, fmt.Errorf("stdout pipe: %w", err)
	}
	cmd.Stderr = io.Discard

	if err := cmd.Start(); err != nil {
		return nil, nil, fmt.Errorf("start command: %w", err)
	}

	connectCtx, connectCancel := context.WithTimeout(ctx, serverTimeout(server))
	defer connectCancel()
	transport := &mcp.IOTransport{Reader: stdout, Writer: stdin}
	session, err := client.Connect(connectCtx, transport, nil)
	if err != nil {
		cmd.Process.Kill()
		cmd.Wait()
		return nil, cmd, fmt.Errorf("connect: %w", err)
	}

	return session, cmd, nil
}

type environmentEntry struct {
	name  string
	value string

View on GitHub (pinned to 9f775e8a12)