{"record":{"id":"100a1a57ca3f0c8b","repo":"googleapis/mcp-toolbox","slug":"invalid-source-for-q-tool-source-q-is-not-a-com-100a1a","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/sqlite/sqliteexecutesql/sqliteexecutesql.go","lineNumber":101,"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\tsqlStr, ok := params.AsMap()[\"sql\"].(string)\n\tif !ok {\n\t\treturn nil, util.NewAgentError(\"missing or invalid 'sql' parameter\", nil)\n\t}\n\tif sqlStr == \"\" {\n\t\treturn nil, util.NewAgentError(\"sql parameter cannot be empty\", nil)\n\t}\n\n\t// Log the query executed for debugging.","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/sqlite/sqliteexecutesql/sqliteexecutesql.go#L83-L119","documentation":"Same pattern as the Spanner tool: sqlite-execute-sql's ValidateSource asserts that the bound source implements compatibleSource (an SQLite source exposing *sql.DB). Any non-SQLite source fails the assertion and yields this error, preventing cross-engine tool/source pairing.","triggerScenarios":"Tool of kind `sqlite-execute-sql` bound via `source:` to a source whose kind is not `sqlite`; passing a foreign sources.Source implementation directly to Invoke/ValidateSource.","commonSituations":"Reusing one shared tools.yaml across projects where source names collide; renaming the sqlite source but leaving the tool pointing at a different engine's source; dynamic tool wiring in Go code.","solutions":["Point the tool's `source:` field at a source with `kind: sqlite`.","Add/fix the sqlite source declaration in `sources:`.","Validate tool-to-source engine compatibility at config load time."],"exampleFix":"// before\nsource: \"my-postgres\"\n// after\nsource: \"my-sqlite\"","handlingStrategy":"type-guard","validationCode":"yq '.tools[] | select(.kind == \"sqlite-execute-sql\") | .source' tools.yaml\n# cross-check the referenced source's kind is sqlite:\nyq '.sources[<name>].kind' tools.yaml","typeGuard":"func isSQLiteSource(s sources.Source) bool {\n    _, ok := s.(sqliteexecutesql.CompatibleSource)\n    return ok\n}","tryCatchPattern":"if err := tool.ValidateSource(src); err != nil {\n    return fmt.Errorf(\"bind %q to a sqlite source: %w\", toolName, err)\n}","preventionTips":["Name sources clearly by engine (my-sqlite, my-pg) and reference exactly.","Run `toolbox --tools-file tools.yaml` (validate/dry-run) before deploying.","Re-grep source refs after renaming any source.","Avoid template variables that could swap source names between engines."],"tags":["go","config","source-binding","sqlite"],"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"}