{"record":{"id":"03fc876647002e91","repo":"siyuan-note/siyuan","slug":"unsupported-server-type-s","errorCode":null,"errorMessage":"unsupported server type: %s","messagePattern":"unsupported server type: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/mcp/client/mcp.go","lineNumber":444,"sourceCode":"\t}\n}\n\nfunc connectServer(ctx context.Context, server conf.MCPServer, interactive bool) (*mcp.ClientSession, *exec.Cmd, *mcpOAuthHandler, error) {\n\tc := mcp.NewClient(&mcp.Implementation{Name: \"siyuan\", Version: \"3.0\"}, &mcp.ClientOptions{\n\t\tToolListChangedHandler: func(context.Context, *mcp.ToolListChangedRequest) {\n\t\t\tlogging.LogInfof(\"mcp: server [%s] tool list changed, reconnecting\", server.Name)\n\t\t\tgo reconnectMCPServer(server.ID)\n\t\t},\n\t})\n\n\tswitch server.Type {\n\tcase \"stdio\":\n\t\tsession, cmd, err := connectStdio(ctx, c, server)\n\t\treturn session, cmd, nil, err\n\tcase \"http\":\n\t\treturn connectHTTP(ctx, c, server, interactive)\n\tdefault:\n\t\treturn nil, nil, nil, fmt.Errorf(\"unsupported server type: %s\", server.Type)\n\t}\n}\n\nfunc connectStdio(ctx context.Context, client *mcp.Client, server conf.MCPServer) (*mcp.ClientSession, *exec.Cmd, error) {\n\tif server.Command == \"\" {\n\t\treturn nil, nil, fmt.Errorf(\"command is required for stdio server\")\n\t}\n\n\tcmd := exec.Command(server.Command, server.Args...)\n\t// stdio 环境变量插值不受密钥 AllowedHosts 约束：目标是本地子进程而非网络主机，管理员在 Env 中\n\t// 引用 {{secrets.NAME}} 本身就是对该服务器的显式授权，与直接写入明文属于同一信任级别。\n\tcmdEnv, err := buildStdioEnvironment(server, os.LookupEnv, func(value string) string {\n\t\tif model.Conf == nil {\n\t\t\treturn value\n\t\t}\n\t\treturn conf.ResolveSecretsVars(model.Conf.Secrets, model.Conf.Variables, value)\n\t}, runtime.GOOS)\n\tif err != nil {","sourceCodeStart":426,"sourceCodeEnd":462,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/mcp/client/mcp.go#L426-L462","documentation":"connectServer dispatches on the configured MCP server's Type field, which must be exactly \"stdio\" or \"http\". Any other value (including empty) falls into the default branch and produces this error. It is a configuration validation failure surfaced before any connection attempt.","triggerScenarios":"connectOneServer processes a conf.MCPServer whose server.Type is not \"stdio\" or \"http\", e.g. a typo like \"Stdio\", \"sse\", \"streamable-http\", or an unset field.","commonSituations":"Hand-editing the MCP server config JSON with an unsupported type string, migrating from another client's config format that used \"sse\" or \"websocket\", or a config written by an older/newer version with different type names.","solutions":["Set server.Type to exactly \"stdio\" or \"http\" in the MCP server configuration","If the server is SSE/streamable-HTTP based, use type \"http\" with the correct URL","Check for case or spelling mistakes in the type value (it is lowercase and case-sensitive)","Re-add the server through the SiYuan MCP settings UI so the type field is written correctly"],"exampleFix":"// before\n{\"name\": \"myserver\", \"type\": \"sse\", \"url\": \"http://localhost:3000/sse\"}\n// after\n{\"name\": \"myserver\", \"type\": \"http\", \"url\": \"http://localhost:3000\"}","handlingStrategy":"validation","validationCode":"func validMCPServerType(t string) bool {\n    switch t {\n    case \"stdio\", \"http\":\n        return true\n    }\n    return false\n}\n// call before connectServer: if !validMCPServerType(server.Type) { reject config }","typeGuard":"null","tryCatchPattern":"session, cmd, oauth, err := connectServer(ctx, server, interactive)\nif err != nil {\n    if strings.Contains(err.Error(), \"unsupported server type\") {\n        logging.LogWarnf(\"mcp: fix config type for [%s]: %v\", server.Name, err)\n    }\n    return err\n}","preventionTips":["Add servers through the settings UI instead of hand-editing config files","Remember the type vocabulary is exactly the lowercase strings \"stdio\" and \"http\"","Validate config on load and surface a clear message pointing at the offending server entry"],"tags":["mcp","config","validation","unsupported-type"],"backgroundTag":"invalid-enum-value","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"}