{"record":{"id":"0ef95908c45b867a","repo":"googleapis/mcp-toolbox","slug":"invalid-source-for-q-tool-source-q-is-not-a-com-0ef959","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":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/tools/http/http.go","lineNumber":129,"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\n// Helper function to generate the HTTP request body upon Tool invocation.\nfunc getRequestBody(bodyParams parameters.Parameters, requestBodyPayload string, paramsMap map[string]any) (string, error) {\n\tbodyParamValues, err := parameters.GetParams(bodyParams, paramsMap)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tbodyParamsMap := bodyParamValues.AsMap()\n\n\trequestBodyStr, err := parameters.PopulateTemplateWithJSON(\"HTTPToolRequestBody\", requestBodyPayload, bodyParamsMap)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn requestBodyStr, nil\n}","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/http/http.go#L111-L147","documentation":"The \"http\" tool only works with sources implementing compatibleSource (HttpDefaultHeaders, HttpBaseURL, HttpQueryParams, RunRequest). ValidateSource type-asserts the configured source and returns this error when the source kind doesn't support raw HTTP requests.","triggerScenarios":"An http tool's \"source\" field names a non-HTTP source (e.g., postgres, firestore) so the source.(compatibleSource) assertion fails during tool/source validation at startup.","commonSituations":"Pointing an http tool at a database source by mistake; renaming/re-pointing a shared source; copying tool definitions between configs where source names refer to different source kinds.","solutions":["Set the tool's \"source\" to a source declared with kind \"http\" in tools.yaml.","Confirm the named source's kind in the sources: section matches what the http tool expects.","If the intent was a database query, change the tool type to the appropriate SQL tool instead."],"exampleFix":"# before\nproxy-tool:\n  type: http\n  source: postgres-src\n  path: /v1/items\n  method: GET\n  description: Proxy call\n# after\nproxy-tool:\n  type: http\n  source: rest-api-src\n  path: /v1/items\n  method: GET\n  description: Proxy call","handlingStrategy":"validation","validationCode":"// Ensure each http tool's source is an http-kind source\nsrc, ok := cfg.Sources[tool.Source]\nif tool.Type == \"http\" && (!ok || src.Kind != \"http\") {\n    return fmt.Errorf(\"http tool %q requires an http source, got %q\", tool.Name, tool.Source)\n}","typeGuard":"func isHTTPSource(s sources.Source) bool {\n    _, ok := s.(interface {\n        HttpDefaultHeaders() map[string]string\n        HttpBaseURL() string\n        HttpQueryParams() map[string]string\n        RunRequest(context.Context, *http.Request) (any, error)\n    })\n    return ok\n}","tryCatchPattern":null,"preventionTips":["Only point http tools at sources with kind \"http\"","Use kind-explicit source names to prevent accidental cross-wiring","Validate tool/source pairings in a startup or CI config check"],"tags":["go","config","source-compatibility","http"],"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"}