siyuan-note/siyuan · error
url is required for http server
Error message
url is required for http server
What it means
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.
Source
Thrown at kernel/mcp/client/mcp.go:616
}
sort.Slice(ret, func(i, j int) bool {
left, right := strings.ToUpper(ret[i]), strings.ToUpper(ret[j])
if left == right {
return ret[i] < ret[j]
}
return left < right
})
return ret
}
// MCPEnvironmentVariables 返回当前内核环境变量名称和新服务默认允许继承的名称,不暴露变量值。
func MCPEnvironmentVariables() (names, defaults []string) {
return environmentVariableNames(os.Environ(), runtime.GOOS), defaultMCPEnvironmentNames(runtime.GOOS)
}
func connectHTTP(ctx context.Context, client *mcp.Client, server conf.MCPServer, interactive bool) (*mcp.ClientSession, *exec.Cmd, *mcpOAuthHandler, error) {
if server.URL == "" {
return nil, nil, nil, fmt.Errorf("url is required for http server")
}
transport := &mcp.StreamableClientTransport{
Endpoint: server.URL,
}
var oauthHandler *mcpOAuthHandler
if !hasAuthorizationHeader(server.Headers) {
oauthHandler = newMCPOAuthHandler(server, interactive)
transport.OAuthHandler = oauthHandler
}
// 所有 MCP HTTP 出站请求统一带上 SiYuan UA,便于第三方 MCP server 识别客户端身份
uaBase := httpclient.NewUserAgentRoundTripper(http.DefaultTransport)
if len(server.Headers) > 0 {
transport.HTTPClient = &http.Client{
Transport: &headerRoundTripper{
base: uaBase,
headers: server.Headers,
},View on GitHub (pinned to 251596fc0d)
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.
Example fix
// before
{"type": "http", "url": ""}
// after
{"type": "http", "url": "https://mcp.example.com/sse"} Defensive patterns
Strategy: validation
Validate before calling
func validateHTTPServer(server conf.MCPServer) error {
if server.Type == "http" && server.URL == "" {
return errors.New("http server requires a URL")
}
return nil
} Type guard
func isHTTPServerConfigured(s conf.MCPServer) bool {
return s.Type == "http" && strings.TrimSpace(s.URL) != ""
} Prevention
- In the config UI, make URL a required field when type == http.
- Distinguish stdio vs http clearly so users pick the right type.
When it happens
Trigger: 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).
Common situations: 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.
Related errors
AI-assisted analysis of siyuan-note/siyuan@251596fc0d (2026-08-12).
Data as JSON: /api/errors/5c10c2f67d5ce2e1.
Report an issue: GitHub.