{"record":{"id":"bf4689be1d03c4d4","repo":"siyuan-note/siyuan","slug":"start-command-w","errorCode":null,"errorMessage":"start command: %w","messagePattern":"start command: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/mcp/client/mcp.go","lineNumber":477,"sourceCode":"\t\t}\n\t\treturn conf.ResolveSecretsVars(model.Conf.Secrets, model.Conf.Variables, value)\n\t}, runtime.GOOS)\n\tif err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"environment: %w\", err)\n\t}\n\tcmd.Env = cmdEnv\n\tstdin, err := cmd.StdinPipe()\n\tif err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"stdin pipe: %w\", err)\n\t}\n\tstdout, err := cmd.StdoutPipe()\n\tif err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"stdout pipe: %w\", err)\n\t}\n\tcmd.Stderr = io.Discard\n\n\tif err := cmd.Start(); err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"start command: %w\", err)\n\t}\n\n\tconnectCtx, connectCancel := context.WithTimeout(ctx, serverTimeout(server))\n\tdefer connectCancel()\n\ttransport := &mcp.IOTransport{Reader: stdout, Writer: stdin}\n\tsession, err := client.Connect(connectCtx, transport, nil)\n\tif err != nil {\n\t\tcmd.Process.Kill()\n\t\tcmd.Wait()\n\t\treturn nil, cmd, fmt.Errorf(\"connect: %w\", err)\n\t}\n\n\treturn session, cmd, nil\n}\n\ntype environmentEntry struct {\n\tname  string\n\tvalue string","sourceCodeStart":459,"sourceCodeEnd":495,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/mcp/client/mcp.go#L459-L495","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Verify the command exists and is executable: run it manually in a shell with the same user/environment","Use an absolute path to the executable instead of relying on PATH","Install the missing runtime/package (e.g. Node for npx-based servers) or correct the spelling","Check resource limits (memory, PIDs) if the command exists but the fork still fails"],"exampleFix":"// before\n{\"type\": \"stdio\", \"command\": \"mcp-server-everything\"}\n// after\n{\"type\": \"stdio\", \"command\": \"/usr/local/bin/mcp-server-everything\"} // or install the package first","handlingStrategy":"validation","validationCode":"path, err := exec.LookPath(server.Command)\nif err != nil {\n    return fmt.Errorf(\"stdio command %q not found for server %s\", server.Command, server.Name)\n}\nif info, err := os.Stat(path); err == nil && info.Mode()&0o111 == 0 {\n    return fmt.Errorf(\"%s is not executable\", path)\n}","typeGuard":"null","tryCatchPattern":"if err := connectStdio(ctx, client, server); err != nil {\n    if strings.Contains(err.Error(), \"start command\") {\n        return fmt.Errorf(\"cannot launch %q for server %q: %w\", server.Command, server.Name, err)\n    }\n    return err\n}","preventionTips":["Run the exact command with its args manually before registering the server","Prefer absolute executable paths over PATH lookups","Install required runtimes (Node, Python) in the same environment SiYuan runs in"],"tags":["mcp","stdio","process","exec"],"backgroundTag":"command-not-found","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}