{"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":618,"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 := newStreamableClientTransport(server)\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},\n\t\t}\n\t} else {","sourceCodeStart":600,"sourceCodeEnd":636,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/mcp/client/mcp.go#L600-L636","documentation":"connectHTTP is used for HTTP (streamable) MCP servers and requires server.URL to be set, since it configures a StreamableClientTransport with that endpoint. If an HTTP-type MCP server is configured without a URL, the connection cannot even be attempted, so it returns this error immediately.","triggerScenarios":"connectServer dispatches to connectHTTP for a server with an HTTP transport type but conf.MCPServer.URL is empty (no endpoint configured).","commonSituations":"Creating an HTTP MCP server entry in the settings UI but leaving the endpoint field blank; a config migration/import that dropped the URL; toggling a server's type to HTTP without filling in the endpoint.","solutions":["Open the MCP server settings and fill in the HTTP endpoint URL (e.g. https://example.com/mcp)","If editing conf.json, set the url field of the affected server entry","Alternatively, if the server is actually a local process, switch its type to stdio and configure a command instead of a URL"],"exampleFix":"// before (conf)\n{\"name\": \"myserver\", \"type\": \"http\", \"url\": \"\"}\n// after\n{\"name\": \"myserver\", \"type\": \"http\", \"url\": \"https://example.com/mcp\"}","handlingStrategy":"validation","validationCode":"if server.Type == \"http\" && server.URL == \"\" {\n    return errors.New(\"HTTP MCP server requires a URL\")\n}\nif _, err := url.Parse(server.URL); err != nil {\n    return fmt.Errorf(\"invalid URL: %w\", err)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Require the URL field in the settings form when transport type is HTTP","Validate the URL parses and uses http/https before saving","Switch to stdio type (with a command) for local process servers instead of leaving URL blank"],"tags":["mcp","http","missing-url","config"],"backgroundTag":"missing-required-config-field","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"}