{"record":{"id":"4e7d651d6f1139aa","repo":"siyuan-note/siyuan","slug":"tool-handler-is-not-configured","errorCode":null,"errorMessage":"tool handler is not configured","messagePattern":"tool handler is not configured","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/mcp/server.go","lineNumber":302,"sourceCode":"\t\t\t\tif errors.Is(err, model.ErrEncryptedBoxNotUnlocked) {\n\t\t\t\t\treturn toolErrorResult(\"encrypted notebook is locked, please unlock it first\"), nil\n\t\t\t\t}\n\t\t\t\tlogging.LogWarnf(\"mcp: acquire encrypted notebook operations for tool [%s] failed: %v\", name, err)\n\t\t\t\treturn toolErrorResult(err.Error()), nil\n\t\t\t}\n\t\t}\n\t\tdefer releaseBoxLeases()\n\n\t\tvar (\n\t\t\tresult tools.CallToolResult\n\t\t\terr    error\n\t\t)\n\t\tif tool.ContextHandler != nil {\n\t\t\tresult, err = tool.ContextHandler(ctx, arguments)\n\t\t} else if tool.Handler != nil {\n\t\t\tresult, err = tool.Handler(arguments)\n\t\t} else {\n\t\t\terr = fmt.Errorf(\"tool handler is not configured\")\n\t\t}\n\t\tif err != nil {\n\t\t\treturn toolErrorResult(err.Error()), nil\n\t\t}\n\t\tif err = validator.ValidateOutputContext(ctx, result); err != nil {\n\t\t\treturn toolErrorResult(fmt.Sprintf(\n\t\t\t\t\"invalid tool output after execution; execution result may have side effects and must not be retried automatically: %v\",\n\t\t\t\terr)), nil\n\t\t}\n\n\t\tcontent := make([]mcpsdk.Content, 0, len(result.Content))\n\t\tfor _, item := range result.Content {\n\t\t\tconverted, convertErr := convertContentItem(item)\n\t\t\tif convertErr != nil {\n\t\t\t\treturn toolErrorResult(fmt.Sprintf(\n\t\t\t\t\t\"invalid tool content after execution; execution result may have side effects and must not be retried automatically: %v\",\n\t\t\t\t\tconvertErr)), nil\n\t\t\t}","sourceCodeStart":284,"sourceCodeEnd":320,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/mcp/server.go#L284-L320","documentation":"A registered MCP tool has neither ContextHandler nor Handler set, so when it is invoked the server records 'tool handler is not configured' as a tool error result. This is an internal registration defect: a tool was advertised without an implementation.","triggerScenarios":"A tools/call targets a tool whose struct instance has nil ContextHandler and nil Handler — typically a tool added to the registry without assigning its handler function, or one whose handler was conditionally omitted (e.g. capability disabled) but still registered.","commonSituations":"Plugin/extension code registering tools declaratively and forgetting the handler; refactoring that renamed a handler function leaving the field nil; building tools from config where a handler mapping is missing.","solutions":["Assign either ContextHandler(ctx, arguments) or Handler(arguments) on the tool at registration time","If the tool is intentionally unavailable, do not register it (or filter it from the tools list) instead of registering with nil handlers","Add a registration-time assertion/log that flags tools with no handler"],"exampleFix":"// before\nserver.AddTool(&mcpsdk.Tool{Name: \"export\"}) // no handler\n// after\nserver.AddTool(&mcpsdk.Tool{Name: \"export\", Handler: exportHandler})","handlingStrategy":"validation","validationCode":"func validateTool(t *Tool) error {\n    if t.ContextHandler == nil && t.Handler == nil {\n        return fmt.Errorf(\"tool %q has no handler\", t.Name)\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"if result.IsError != nil && *result.IsError {\n    if strings.Contains(resultText(result), \"tool handler is not configured\") {\n        // fix tool registration on the server side\n    }\n}","preventionTips":["Assert handler presence whenever a tool is registered","Filter out tools whose handler is conditionally unavailable instead of registering nil","Cover every registered tool with a smoke test invocation"],"tags":["mcp","tools","registration"],"backgroundTag":"missing-dependency","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"}