{"record":{"id":"47ec046417189d2b","repo":"googleapis/mcp-toolbox","slug":"invalid-source-for-q-tool-source-q-is-not-a-com-47ec04","errorCode":null,"errorMessage":"invalid source for %q tool: source %q is not a compatible type","messagePattern":"invalid source for %q tool: source %q is not a compatible type","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/tools/valkey/valkey.go","lineNumber":99,"sourceCode":"// validate interface\nvar _ tools.Tool = Tool{}\n\ntype Tool struct {\n\ttools.BaseTool[Config]\n}\n\nfunc (t Tool) GetSourceName() string {\n\treturn t.Cfg.Source\n}\n\nfunc (t Tool) ToConfig() tools.ToolConfig {\n\treturn t.Cfg\n}\n\nfunc (t Tool) ValidateSource(source sources.Source) error {\n\t_, ok := source.(compatibleSource)\n\tif !ok {\n\t\treturn fmt.Errorf(\"invalid source for %q tool: source %q is not a compatible type\", t.Cfg.Type, t.Cfg.Source)\n\t}\n\treturn nil\n}\n\nfunc (t Tool) Invoke(ctx context.Context, s sources.Source, params parameters.ParamValues, accessToken tools.AccessToken) (any, util.ToolboxError) {\n\tsource, ok := s.(compatibleSource)\n\tif !ok {\n\t\treturn nil, util.NewClientServerError(\"source used is not compatible with the tool\", http.StatusInternalServerError, nil)\n\t}\n\n\t// Replace parameters\n\tcommands, err := replaceCommandsParams(t.Cfg.Commands, t.Cfg.Parameters, params)\n\tif err != nil {\n\t\treturn nil, util.NewAgentError(\"error replacing commands' parameters\", err)\n\t}\n\tres, err := source.RunCommand(ctx, commands)\n\tif err != nil {\n\t\treturn nil, util.ProcessGeneralError(err)","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/valkey/valkey.go#L81-L117","documentation":"Valkey tools assert that the attached source implements the compatibleSource interface (a Valkey client-backed source). ValidateSource returns this error when the tool is bound to a source of any other type, so the tool never runs against a non-Valkey backend.","triggerScenarios":"tools.yaml pairing a valkey tool with a source whose kind is not valkey (e.g. redis, postgres); calling ValidateSource or Invoke with a mismatched sources.Source implementation.","commonSituations":"Assuming Redis and Valkey sources are interchangeable; copy-pasted configs where the source name points to a different kind; refactors that changed the source kind but not the tool bindings.","solutions":["Point the tool's 'source' field at a source declared with kind: valkey","If the backend is Redis, use the corresponding redis tool kind instead of the valkey one","Confirm the source initializes successfully before the tool binds to it"],"exampleFix":"# before\nsources:\n  cache:\n    kind: redis\n    address: localhost:6379\ntools:\n  valkey-cmd:\n    kind: valkey-execute-sql\n    source: cache\n# after\nsources:\n  cache:\n    kind: valkey\n    address: localhost:6379\ntools:\n  valkey-cmd:\n    kind: valkey-execute-sql\n    source: cache","handlingStrategy":"validation","validationCode":"kind, _ := getSourceKind(toolsYAML, tool.Source)\nif kind != \"valkey\" {\n    return fmt.Errorf(\"tool %s requires a valkey source, got %s\", tool.Name, kind)\n}","typeGuard":"func asValkeySource(s sources.Source) (compatibleSource, bool) {\n    cs, ok := s.(compatibleSource)\n    return cs, ok\n}","tryCatchPattern":"if err := tool.ValidateSource(src); err != nil {\n    // rebind tool to a kind: valkey source and reload\n}","preventionTips":["Don't assume redis sources work with valkey tools; declare kind: valkey explicitly","Name sources by kind in tools.yaml","Run a toolbox config preflight check in CI"],"tags":["go","tool-configuration","valkey","type-assertion"],"backgroundTag":"incompatible-source-type","analyzedSha":"8cc6e09de2ad7b8bffc77751799585a1401a48eb","analyzedAt":"2026-09-05T01:10:36.887Z","contentChangedAt":"2026-09-05T01:10:36.887Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}