{"record":{"id":"871d28ef342ab6ab","repo":"PrefectHQ/fastmcp","slug":"the-google-genai-package-is-not-installed-insta","errorCode":null,"errorMessage":"The `google-genai` package is not installed. Install it with `pip install 'fastmcp-slim[gemini]'` or add `google-genai` to your dependencies.","messagePattern":"The `google-genai` package is not installed\\. Install it with `pip install 'fastmcp-slim\\[gemini\\]'` or add `google-genai` to your dependencies\\.","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"critical","filePath":"fastmcp_slim/fastmcp/client/sampling/handlers/google_genai.py","lineNumber":29,"sourceCode":"        Blob,\n        Candidate,\n        Content,\n        FunctionCall,\n        FunctionCallingConfig,\n        FunctionCallingConfigMode,\n        FunctionDeclaration,\n        FunctionResponse,\n        GenerateContentConfig,\n        GenerateContentResponse,\n        ModelContent,\n        Part,\n        ThinkingConfig,\n        ToolConfig,\n        UserContent,\n    )\n    from google.genai.types import Tool as GoogleTool\nexcept ImportError as e:\n    raise ImportError(\n        \"The `google-genai` package is not installed. \"\n        \"Install it with `pip install 'fastmcp-slim[gemini]'` or add `google-genai` \"\n        \"to your dependencies.\"\n    ) from e\n\nfrom mcp import ClientSession, ServerSession\nfrom mcp_types import (\n    AudioContent,\n    CreateMessageResult,\n    CreateMessageResultWithTools,\n    ImageContent,\n    ModelPreferences,\n    SamplingMessage,\n    SamplingMessageContentBlock,\n    StopReason,\n    TextContent,\n    ToolChoice,\n    ToolResultContent,","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/PrefectHQ/fastmcp/blob/1f021142978e0861cd910c8df4e8074bc7cf3978/fastmcp_slim/fastmcp/client/sampling/handlers/google_genai.py#L11-L47","documentation":"The google_genai sampling handler module imports google.genai at load time; if that package is missing, the module raises ImportError with instructions to install the optional 'gemini' extra. The handler cannot work without the SDK, so failure is immediate at import.","triggerScenarios":"Importing fastmcp.client.sampling.handlers.google_genai (or code paths that import it) without google-genai installed — e.g. base fastmcp-slim install without [gemini] extra.","commonSituations":"Fresh environments/CI without the extra; deploying to a server where optional extras weren't installed; switching handlers to Gemini without updating dependencies.","solutions":["Run: uv add 'fastmcp-slim[gemini]' or pip install 'fastmcp-slim[gemini]'.","Or add google-genai directly to your project dependencies.","If Gemini isn't needed, use a different sampling handler (Anthropic/OpenAI) whose SDK is installed.","Pin google-genai in your lockfile so environments stay reproducible."],"exampleFix":"// before\npip install fastmcp-slim\n// after\npip install 'fastmcp-slim[gemini]'","handlingStrategy":"validation","validationCode":"try:\n    import google.genai  # noqa: F401\nexcept ImportError:\n    raise SystemExit(\"Install with: pip install 'fastmcp-slim[gemini]'\")","typeGuard":"def gemini_available() -> bool:\n    try:\n        import google.genai\n        return True\n    except ImportError:\n        return False","tryCatchPattern":"try:\n    from fastmcp.client.sampling.handlers.google_genai import GoogleGenaiSamplingHandler\nexcept ImportError as e:\n    if \"google-genai\" in str(e):\n        handler = FallbackSamplingHandler()\n    else:\n        raise","preventionTips":["Install optional extras: fastmcp-slim[gemini]","Declare google-genai in your project's dependencies/lockfile","Verify imports in CI for every environment you deploy to","Import handler modules at startup, not lazily, to fail fast"],"tags":["importerror","google-genai","missing-dependency","optional-extra"],"backgroundTag":"missing-dependency","analyzedSha":"1f021142978e0861cd910c8df4e8074bc7cf3978","analyzedAt":"2026-08-29T14:31:16.082Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}