Skip to content

Configuration ​

img-mcp is configured through environment variables. No config files are required.

Required variables ​

VariableDescriptionExample
GOOGLE_API_KEYYour Google Gemini API keyAIza...

Get your key from Google AI Studio.

Optional variables ​

VariableDescriptionDefault
GOOGLE_IMAGE_MODELDefault Nano Banana model IDgemini-3.1-flash-image

You can override the model per request using the model argument of generate_image.

Example environment ​

bash
export GOOGLE_API_KEY="AIza..."
export GOOGLE_IMAGE_MODEL="gemini-3.1-flash-image"

Setting variables in MCP host configs ​

Most hosts let you define environment variables directly in the server config:

json
{
  "mcpServers": {
    "img-mcp": {
      "command": "npx",
      "args": ["-y", "img-mcp"],
      "env": {
        "GOOGLE_API_KEY": "AIza...",
        "GOOGLE_IMAGE_MODEL": "gemini-3.1-flash-image"
      }
    }
  }
}

Optional dependency: background removal ​

The remove_background tool uses @imgly/background-removal-node, which is licensed under AGPL-3.0. To keep img-mcp under MIT, this package is an optional peer dependency.

Install it to enable background removal:

bash
npm install -g @imgly/background-removal-node

If the package is missing when remove_background is called, img-mcp returns an error with installation instructions.

Released under the MIT License.