Google GenAI SDK Linter
This extension provides linting capabilities for Python code using the Google GenAI SDK. It helps developers migrate from older google.generativeai
API usage to the newer google.genai
SDK, and provides contextual documentation suggestions via the Context7 MCP server.
Features
- Deprecated API Detection: Identifies and flags usage of deprecated
google.generativeai
imports and API calls (e.g., GENAI001
).
- Generation Parameter Enforcement: Ensures that generation parameters (like
temperature
) are correctly encapsulated within types.GenerationConfig
when calling generate_content
(e.g., GENAI005
).
- Contextual Documentation Suggestions: Integrates with the Context7 MCP server to fetch and display relevant documentation snippets for Google GenAI API calls directly within your code (e.g.,
GENAI_DOC_SUGGESTION
). This helps you understand the latest usage patterns and migration paths.
Requirements
This extension requires the Context7 MCP Server extension (Upstash.context7-mcp
) to be installed and active in your VS Code environment to provide contextual documentation suggestions. Without it, the linter will still function for other rules, but documentation suggestions will not be available.
Setting up the Context7 MCP Server
To enable the full functionality of this linter, you need to set up and run the Context7 MCP Server. Here's how:
- Clone the Context7 MCP Server Repository:
git clone https://github.com/upstash/context7-mcp.git
cd context7-mcp
- Install Dependencies:
npm install
- Build the Server:
npm run build
- Run the MCP Server:
You can run the server in a dedicated terminal. It needs to be running in the background for the linter to connect.
node dist/src/app/index.cjs --mode mcp
Keep this terminal open while you are using the Google GenAI SDK Linter.
You also need a Python interpreter installed and configured in your VS Code settings.
Extension Settings
This extension contributes the following settings:
google-genai-sdk-linter.pythonPath
: Path to the Python interpreter used by the linter. Defaults to python
.
Known Issues
- Currently, the Context7 documentation suggestions are static examples. Full dynamic documentation fetching would require a live Context7 MCP server integration.
Release Notes
0.0.2
- Updated
package.json
with repository URL and optimized activation events.
- Added MIT
LICENSE
file.
- Added extension icon.
- Resolved "Tool context7 was not contributed" error by correcting MCP tool invocation names.
- Fixed Mocha test environment setup issues ("ReferenceError: describe/test is not defined").
- Ensured Python linter correctly generates diagnostics for deprecated API usage and generation parameters.
0.0.1
Initial release of the Google GenAI SDK Linter.
- Detects deprecated
google.generativeai
imports.
- Enforces correct
types.GenerationConfig
usage for generation parameters.
- Provides contextual documentation suggestions via Context7 MCP server.
Following extension guidelines
Ensure that you've read through the extensions guidelines and follow the best practices for creating your extension.
Working with Markdown
You can author your README using Visual Studio Code. Here are some useful editor keyboard shortcuts:
- Split the editor (
Cmd+\
on macOS or Ctrl+\
on Windows and Linux).
- Toggle preview (
Shift+Cmd+V
on macOS or Shift+Ctrl+V
on Windows and Linux).
- Press
Ctrl+Space
(Windows, Linux, macOS) to see a list of Markdown snippets.
Enjoy!