{"record":{"id":"5c10c2f67d5ce2e1","repo":"siyuan-note/siyuan","slug":"url-is-required-for-http-server","errorCode":null,"errorMessage":"url is required for http server","messagePattern":"url is required for http server","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/mcp/client/mcp.go","lineNumber":616,"sourceCode":"\t}\n\tsort.Slice(ret, func(i, j int) bool {\n\t\tleft, right := strings.ToUpper(ret[i]), strings.ToUpper(ret[j])\n\t\tif left == right {\n\t\t\treturn ret[i] < ret[j]\n\t\t}\n\t\treturn left < right\n\t})\n\treturn ret\n}\n\n// MCPEnvironmentVariables 返回当前内核环境变量名称和新服务默认允许继承的名称，不暴露变量值。\nfunc MCPEnvironmentVariables() (names, defaults []string) {\n\treturn environmentVariableNames(os.Environ(), runtime.GOOS), defaultMCPEnvironmentNames(runtime.GOOS)\n}\n\nfunc connectHTTP(ctx context.Context, client *mcp.Client, server conf.MCPServer, interactive bool) (*mcp.ClientSession, *exec.Cmd, *mcpOAuthHandler, error) {\n\tif server.URL == \"\" {\n\t\treturn nil, nil, nil, fmt.Errorf(\"url is required for http server\")\n\t}\n\n\ttransport := &mcp.StreamableClientTransport{\n\t\tEndpoint: server.URL,\n\t}\n\tvar oauthHandler *mcpOAuthHandler\n\tif !hasAuthorizationHeader(server.Headers) {\n\t\toauthHandler = newMCPOAuthHandler(server, interactive)\n\t\ttransport.OAuthHandler = oauthHandler\n\t}\n\t// 所有 MCP HTTP 出站请求统一带上 SiYuan UA，便于第三方 MCP server 识别客户端身份\n\tuaBase := httpclient.NewUserAgentRoundTripper(http.DefaultTransport)\n\tif len(server.Headers) > 0 {\n\t\ttransport.HTTPClient = &http.Client{\n\t\t\tTransport: &headerRoundTripper{\n\t\t\t\tbase:    uaBase,\n\t\t\t\theaders: server.Headers,\n\t\t\t},","sourceCodeStart":598,"sourceCodeEnd":634,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/mcp/client/mcp.go#L598-L634","documentation":"Precondition check in connectHTTP: the server is configured with Type == \"http\" but server.URL is empty. The MCP StreamableClientTransport requires an Endpoint, so the function bails out before constructing the transport. This is a pure configuration defect.","triggerScenarios":"connectHTTP(server) is called for a server whose Type is \"http\" and URL field is unset/empty. This happens when the user created an HTTP server entry but left the URL blank, or set the type incorrectly (the server is actually stdio).","commonSituations":"User picked 'http' as the server type in the UI but did not fill in the endpoint URL; config migration left URL empty; user actually meant a stdio server and selected the wrong type.","solutions":["Set server.URL to the full MCP HTTP endpoint (e.g. https://example.com/mcp).","If the server is a local command, change server.Type to \"stdio\" and fill server.Command instead of URL.","Validate the config in the UI before save: if Type == \"http\", require a non-empty URL."],"exampleFix":"// before\n{\"type\": \"http\", \"url\": \"\"}\n// after\n{\"type\": \"http\", \"url\": \"https://mcp.example.com/sse\"}","handlingStrategy":"validation","validationCode":"func validateHTTPServer(server conf.MCPServer) error {\n    if server.Type == \"http\" && server.URL == \"\" {\n        return errors.New(\"http server requires a URL\")\n    }\n    return nil\n}","typeGuard":"func isHTTPServerConfigured(s conf.MCPServer) bool {\n    return s.Type == \"http\" && strings.TrimSpace(s.URL) != \"\"\n}","tryCatchPattern":null,"preventionTips":["In the config UI, make URL a required field when type == http.","Distinguish stdio vs http clearly so users pick the right type."],"tags":["mcp","http","config-validation"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}