🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

mcp-imagenate

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mcp-imagenate

MCP server and embeddable library for image generation using multiple providers (Google Gemini, OpenAI, BFL FLUX)

latest
Source
npmnpm
Version
0.3.1
Version published
Maintainers
1
Created
Source

mcp-imagenate

mcp-imagenate

An MCP server for image generation using multiple providers: Google Gemini, OpenAI (gpt-image), and BFL FLUX.

Providers & Models

Google Gemini (Nano Banana)

NameModel IDBest for
nano-banana-2gemini-3.1-flash-image-previewFast, high-volume generation
nano-banana-progemini-3-pro-image-previewHighest quality output

OpenAI

NameModel IDBest for
gpt-image-2gpt-image-2Latest generation, improved detail

BFL FLUX

NameModel IDBest for
flux-2-kleinklein-4bFast, lightweight generation
flux-2-propro-previewBalanced quality and speed
flux-2-maxmaxMaximum quality

Requirements

  • Node.js 18+
  • At least one provider API key

Installation

npx mcp-imagenate

Or install globally:

npm install -g mcp-imagenate

Setup

Set API keys for the providers you want to use:

# Google Gemini (at least one)
export GEMINI_API_KEY=your_key_here
# or
export NANO_BANANA_API_KEY=your_key_here

# OpenAI (at least one)
export OPENAI_API_KEY=your_key_here
# or
export GPT_IMAGE_API_KEY=your_key_here

# BFL FLUX
export BFL_API_KEY=your_key_here

Claude Desktop

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "mcp-imagenate": {
      "command": "npx",
      "args": ["mcp-imagenate"],
      "env": {
        "GEMINI_API_KEY": "your_key_here",
        "NANO_BANANA_OUTPUT_DIR": "/path/to/image/output"
      }
    }
  }
}

Environment Variables

VariableRequiredDescription
GEMINI_API_KEY*Google AI Studio API key
NANO_BANANA_API_KEY*Alternative to GEMINI_API_KEY (takes precedence)
OPENAI_API_KEY*OpenAI API key
GPT_IMAGE_API_KEY*Alternative to OPENAI_API_KEY (takes precedence)
BFL_API_KEY*BFL FLUX API key
NANO_BANANA_OUTPUT_DIRNoBase directory for saved images. When set, all output and input paths are sandboxed within this directory. Recommended for production.

* At least one provider API key must be set.

Tool: generate_image

Parameters

ParameterTypeDefaultDescription
promptstring (1-32,000 chars)-Text prompt describing the image
modelsee Models above"gpt-image-2"Model to use (available models depend on configured API keys)
resolution"1K" | "2K" | "4K""1K"Output image resolution
aspectRatiosee below"1:1"Aspect ratio of the image
mode"image" | "image_and_text""image"Return image only, or image with description (Google models only)
thinking"none" | "auto""auto"Controls model thinking (Google models only)
outputDirstring"."Directory where images will be saved
inputImagesstring[]-File paths of images to send alongside the prompt (Google models, and OpenAI gpt-image models via the images.edit endpoint)

Supported aspect ratios

1:1, 2:3, 3:2, 3:4, 4:3, 9:16, 16:9, 21:9

Response

Returns a JSON object:

{
  "model": "gemini-3.1-flash-image-preview",
  "savedFiles": ["/path/to/image-1.png"],
  "settings": {
    "resolution": "1K",
    "aspectRatio": "9:16",
    "mode": "image"
  },
  "description": "..."
}

description is only present when mode is "image_and_text".

Use as a library

Besides the standalone MCP server, this package can be embedded in another host — an app, or another MCP server that wants to expose image generation as its own tool.

import { createRegistry, generateImageToDisk } from "mcp-imagenate";

// Keys are passed in explicitly; nothing here reads process.env.
const registry = createRegistry({ openai: myOpenAIKey, google: myGoogleKey });

if (registry.models.length === 0) {
  throw new Error("No image provider is configured");
}

const outcome = await generateImageToDisk({
  registry,
  prompt: "a calico cat asleep on a warm keyboard",
  model: registry.defaultModel!,
  aspectRatio: "16:9",
  outputDir: "/somewhere/to/write",
  // outputBaseDir defaults to null, meaning no path sandboxing. Set it to a
  // directory to confine both output and input paths within that directory.
});

console.log(outcome.savedFiles);

The library entry point never reads process.env, writes to stdio, or exits the process. To read keys from the conventional environment variables anyway, use the keysFromEnv() helper. The standalone server is available at mcp-imagenate/server.

ExportPurpose
createRegistry(keys)Build a registry of the models available for the given keys
keysFromEnv(env?)Read provider keys from environment variables
generateImageToDisk(options)Generate images and write them to disk
resolveOutputDir / resolveInputImagePathPath sandboxing helpers (opt-in)

Security

  • Path sandboxing: When NANO_BANANA_OUTPUT_DIR is set, both output and input image paths are sandboxed within this directory. Symlinks that resolve outside the sandbox are rejected. For library embedders this is opt-in via outputBaseDir, since the host usually controls which paths reach the call.
  • Input validation: Input images are validated for format (PNG/JPEG/WEBP/GIF) and size (max 20 MB).
  • API key validation: The server exits immediately if no API keys are configured. The library reports this as an empty registry instead, leaving the decision to the host.

License

MIT

Keywords

mcp

FAQs

Package last updated on 25 Jul 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts