当前位置: 首页 > Skill >

Tmp.OKbRyOLlhm

Tmp.OKbRyOLlhm

Tmp.OKbRyOLlhm

使用Google Gemini模型通过MCP生成和编辑图像、视频和音乐。适用于用户请求生成、创建或编辑图像(Gemini / Nano Banan...)

1.0.3 2026.11.24 949
获取Skill文件查看使用说明
作 者:许澄 许可证: 更新时间:2026.11.24
本文目录展开

gemini-mcp

MCP server for Google Gemini media generation — natural-language image, video, and music creation via the Gemini API (Nano Banana / Nano Banana Pro images, omni video, Lyria music).

  • npm: npmjs.com/package/@chrischall/gemini-mcp
  • Source: github.com/chrischall/gemini-mcp

Setup

Option A — npx (recommended)

Add to .mcp.json in your project or ~/.claude/mcp.json:

{
  "mcpServers": {
    "gemini": {
      "command": "npx",
      "args": ["-y", "@chrischall/gemini-mcp"],
      "env": {
        "GEMINI_API_KEY": "your-api-key-here"
      }
    }
  }
}

Option B — from source

git clone https://github.com/chrischall/gemini-mcp
cd gemini-mcp
npm install && npm run build

Then add to .mcp.json:

{
  "mcpServers": {
    "gemini": {
      "command": "node",
      "args": ["/path/to/gemini-mcp/dist/index.js"],
      "env": {
        "GEMINI_API_KEY": "your-api-key-here"
      }
    }
  }
}

Or use a .env file in the project directory with GEMINI_API_KEY=<value>.

Getting your API key

  1. Go to aistudio.google.com/apikey
  2. Create an API key (requires a Google account)
  3. Copy the key and set it as GEMINI_API_KEY

Note: Image generation requires a billing-enabled Google Cloud project.

Environment Variables

Variable Required Description
GEMINI_API_KEY Yes Your Google Gemini API key
GEMINI_IMAGE_MODEL No Override the default image model (default: gemini-3.1-flash-image)
GEMINI_OUTPUT_DIR No Default directory for saved images (default: current working directory)
GEMINI_INPUT_DIR No Directory to resolve bare input-image filenames against (e.g. point at Cowork's uploads/ folder so images: ["house.jpg"] works)

Tools

Models

Tool Description
gemini_list_models List available Gemini image models and the current default

Which model to pick (per-call model, or GEMINI_IMAGE_MODEL):

Model When to use Reference-image caps (of 14 max)
gemini-3.1-flash-image (Nano Banana 2) The versatile generalist workhorse for all tasks — balances speed with state-of-the-art 4K generation, world knowledge, and reliable text rendering; excels at multi-reference-image processing and consistency. Only model with video input + image_search grounding 10 objects + 4 characters + 3 style refs
gemini-3-pro-image (Nano Banana Pro) The premium choice for the most complex visual tasks — highest world knowledge, advanced localization, accurate brand consistency, precision creative control 6 objects + 5 characters
gemini-3.1-flash-lite-image (Nano Banana 2 Lite) The fastest/cheapest for simple tasks — 1K output only, no Google Search grounding 14 objects (no character consistency)

Image Generation

Tool Description
gemini_image_generate(prompt, count?, images?, images_base64?, video_url?, video_path?, google_search?, seed?, filename?, model?, aspect_ratio?, image_size?, thinking_level?, output_dir?, inline?) Generate image(s) from a text prompt (optionally image-conditioned via images/images_base64, or video-conditioned via video_url/video_path)
gemini_image_edit(prompt, images?, images_base64?, google_search?, seed?, filename?, model?, aspect_ratio?, image_size?, thinking_level?, output_dir?, inline?) Edit or compose input image(s) — by path (images) or value (images_base64: data URI or raw base64) — with a text instruction. Requires ≥1 input
gemini_image_set(master_prompt, scenes? | count?, reference_mode?, master_images?, master_images_base64?, google_search?, seed?, basename?, model?, thinking_level?, ...) Master image (optionally seeded from a reference photo) plus N consistent images referencing it

Multi-turn (Interactions API)

Tool Description
gemini_interact(input, previous_interaction_id?, continue_last?, images?, images_base64?, video_url?, video_path?, google_search?, search_types?, model?, aspect_ratio?, image_size?, thinking_level?, filename?, output_dir?, inline?) Preferred tool for iterative refinement. Generate/edit via Gemini's Interactions API. Returns an interaction_id; pass it back as previous_interaction_id (or set continue_last: true to reuse the session's most recent one) to iteratively refine the same image conversationally — do NOT start a new interaction or re-upload the image per tweak. Output is JPEG.

Video & Music (preview — funded account)

Tool Description
gemini_video_generate(prompt, aspect_ratio?, task?, images?, images_base64?, from_clipboard?, previous_interaction_id?, continue_last?, model?, filename?, output_dir?, timeout_ms?, idempotency_key?, async?) Generate a short video via the Gemini omni model: text_to_video (default), image_to_video / reference_to_video (supply reference image[s]), or edit (with previous_interaction_id / continue_last). aspect_ratio is 16:9 or 9:16. Written to disk as MP4. Runs long — use async: true + gemini_get_result, or raise timeout_ms.
gemini_music_generate(prompt, model?, audio_format?, images?, images_base64?, from_clipboard?, previous_interaction_id?, continue_last?, filename?, output_dir?, inline?, timeout_ms?, idempotency_key?, async?) Generate music from a prompt (mood/genre/instruments/structure/lyrics) via a Lyria model: lyria-3-clip-preview (~30s, default) or lyria-3-pro-preview (longer, WAV-capable). audio_format mp3 (default) or wav (Pro-only). Written to disk as MP3/WAV, or returned inline.

Async / idempotency (any generation tool)

Tool Description
gemini_get_result(job_id) Fetch a generation started with async: true. Returns running while in flight, then the normal result on completion. Lets a long video/music/image generation outlive a host's tools/call timeout. All generation tools also accept idempotency_key — a repeat call with the same key returns the recorded result (reused: true) instead of billing again.

Workflows

Generate a single image:

gemini_image_generate(prompt: "a red maple leaf on white background, studio photo")
→ returns path to saved PNG

Generate multiple variations:

gemini_image_generate(prompt: "a cartoon fox", count: 4, output_dir: "/tmp/foxes")
→ returns paths to 4 PNG files

Edit an existing image:

gemini_image_edit(prompt: "make the background blue", images: ["/path/to/image.png"])
→ returns path to edited PNG

Generate a consistent set (master + scenes):

gemini_image_set(
  master_prompt: "a cartoon fox named Rusty, orange fur, blue scarf",
  scenes: ["Rusty waving hello", "Rusty eating an apple", "Rusty sleeping"]
)
→ returns paths to master + 3 scene images, all consistent

Generate variations of a concept:

gemini_image_set(
  master_prompt: "minimalist logo for a coffee shop",
  count: 5
)
→ returns master + 5 variations

Use a reference photo by value (when you have the bytes):

gemini_image_edit(
  prompt: "place this house on a vintage travel-poster background",
  images_base64: ["data:image/jpeg;base64,/9j/4AAQ..."]   // or raw base64
)
→ returns path to the edited image

images_base64 is for bytes you actually have — a file you Read/encode, a URL you fetch, or a data: URI the user pastes as text.

Iterate on ONE image conversationally (multi-turn):

r1 = gemini_interact(input: "a cozy reading nook, watercolor")
   → { images: [...], interaction_id: "v1_abc…" }
r2 = gemini_interact(input: "add a sleeping cat on the chair",
                     previous_interaction_id: r1.interaction_id)
   → refined image that preserves r1; returns a NEW interaction_id
r3 = gemini_interact(input: "warmer lighting", continue_last: true)
   → same chain, without threading the id (uses the session's most recent interaction)

Prefer this over re-running gemini_image_edit when you're making a series of incremental edits — the model keeps the prior result in context. Every result echoes interaction_id (and previous_interaction_id when chaining) plus a hint with the exact follow-up call.

Generate a video (preview — runs long, use async):

job = gemini_video_generate(prompt: "a paper boat sailing down a rain gutter, cinematic",
                            aspect_ratio: "16:9", async: true)
   → { job_id, status: "running" }   (returns immediately — no host timeout)
gemini_get_result(job_id: job.job_id)
   → "running" until done, then the MP4 path on disk
# Animate a still instead: gemini_video_generate(prompt: "…", task: "image_to_video", images: ["/path/still.png"])

Generate music (preview):

gemini_music_generate(prompt: "warm lo-fi hip hop, mellow Rhodes, vinyl crackle, 70bpm")
   → ~30s MP3 on disk (lyria-3-clip-preview)
# Longer / WAV: gemini_music_generate(prompt: "…", model: "lyria-3-pro-preview", audio_format: "wav")

⚠️ Chat-pasted/attached images can't be fed to these tools directly. A pasted image reaches the assistant as a vision block — the assistant can SEE it but never receives the original bytes, and the host doesn't write it to disk. So neither images (no file exists) nor images_base64 (the bytes can't be reconstructed from a downscaled vision rendering) is obtainable from a paste. To use a real reference photo, the user must make the bytes available: save the file and give its path (→ images), drop it into the project dir, paste it as a data: URI in text, or host it at a URL (fetch → base64 → images_base64). This is a host/Cowork limitation, not an MCP one.

Two built-in ways to get past the unreachable-paste problem without any manual extraction:

  • from_clipboard: true (macOS) — the tool reads the image off the system clipboard itself (osascript), downscales it, and uses it. The user just needs to copy the image (⌘C — distinct from pasting it inline into chat, which doesn't keep it on the clipboard). Works on every image tool: gemini_image_edit(prompt: "…", from_clipboard: true).
  • GEMINI_INPUT_DIR — point it at a folder (e.g. Cowork's uploads/); then a bare filename resolves against it: gemini_image_edit(prompt: "…", images: ["house.jpg"]).

Prompting playbook

Condensed from Google's official Nano Banana prompting guide. Core rule: describe the scene, don't list keywords — narrative sentences beat tag soups.

Best practices:

  • Be hyper-specific. "Ornate elven plate armor, etched with silver leaf patterns" beats "fantasy armor".
  • Give context & intent. "Create a logo for a high-end minimalist skincare brand" beats "create a logo".
  • Iterate conversationally (gemini_interact): "warmer lighting", "same, but more serious expression".
  • Step-by-step for complex scenes. "First, a misty forest background. Then a stone altar in the foreground. Finally a glowing sword on the altar."
  • Semantic negatives. Describe what you want positively — "an empty, deserted street" — instead of "no cars".
  • Camera language controls composition. Wide-angle / macro / low-angle perspective / 85mm portrait lens / three-point softbox lighting.

Generation templates (abbreviated):

  • Photorealistic: photorealistic [shot type] of [subject] in [setting], [lighting], shot from [angle] with [lens]
  • Sticker/illustration: [style] sticker of [subject] doing [activity], bold outlines, cel-shading, [palette], white background
  • Text in image: create a [type] for [brand] with the text "[exact text]" in a [font style] — Gemini renders text well; Pro is best for professional assets. Tip: generate the wording first, then ask for the image containing it.
  • Product shot: high-resolution studio-lit photo of [product] on [surface], [lighting setup], [angle], sharp focus on [detail]
  • Minimalist/negative space: single [subject] in [frame position], vast empty [color] background — for text-overlay backgrounds.
  • Comic/storyboard: make a 3 panel comic in [style]; put the character in [scene] (Pro or 3.1 Flash).

Editing templates (abbreviated):

  • Add/remove: using the provided image of [subject], [add/remove] [element]; match the original style/lighting/perspective
  • Inpaint (semantic mask): change only the [element] to [new element]; keep everything else exactly the same
  • Style transfer: transform the photo of [subject] into the style of [artist/style]; preserve composition
  • Compose: take the [element from image 1] and place it with [element from image 2]; adjust lighting/shadows to match
  • Detail preservation: describe the critical element (face, logo) in detail and say it must "remain completely unchanged"
  • Sketch → finished: turn this rough sketch of [subject] into a [style] photo; keep [features], add [details]
  • Character 360°: iterate angles via gemini_interact ("in profile looking right"), feeding prior outputs back for consistency

Notes

  • Input images accept either file paths (images / master_images) or base64/data-URI values (images_base64 / master_images_base64).
  • seed makes a result reproducible; it's echoed in the result metadata (a random one is chosen + echoed when omitted). count>1 uses seed, seed+1, … so the images differ. Determinism isn't fully guaranteed by the model.
  • filename/basename set the output name (extension stripped); names never overwrite (a -2, -3 suffix is added). The result echoes the absolute path(s), model, seed, and aspect/size.
  • No edit-strength control. Gemini exposes no denoise/strength knob, and Nano Banana over-preserves the input — big structural edits ("move/remove/shrink", add a mat border) are often ignored. Workarounds: reroll with a different seed, raise thinking_level to high, use forceful wording, do layout changes (padding/borders) externally, or use gemini_interact multi-turn.
  • thinking_level (minimal/high, Gemini 3 models) controls reasoning depth — high can improve complex compositions/edits at higher latency/cost.
  • Model text. When the model returns a caption/explanation (mostly Gemini 3 Pro), it's surfaced as text in the result metadata.
  • google_search: true grounds the image in live Google Search (current events, weather, real data — great for infographics). The result metadata includes grounding with the queries run and the sources ({uri, title}) used. (gemini_interact surfaces grounding.queries — the Interactions API returns no clean source list.)
  • search_types (gemini_interact only): ["web_search", "image_search"] picks the grounding search types (setting it implies google_search). image_search (gemini-3.1-flash-image only) pulls web images via Google Image Search as visual references — useful for real-world subjects (a specific butterfly species, a landmark, a product). ⚠️ Two catches: Google ToS require displaying the returned grounding.search_suggestions HTML chips to the user, and image_search won't depict real people from web images.
  • video_url (a public YouTube URL, on gemini_image_generate / gemini_interact) generates an image from a video reference — requires a Flash model (e.g. model: "gemini-3.1-flash-image"). For a local video file, use video_path instead: the file is uploaded to the Gemini Files API (streamed from disk, 2 GB max), waited to ACTIVE, and referenced by its files/… uri. The result metadata echoes video_file ({uri, name, expires}, ~48h retention) — reuse that uri as video_url in later calls to skip re-uploading.
  • gemini_interact is the multi-turn path: it returns an interaction_id; thread it back via previous_interaction_id for conversational refinement. Output is JPEG only. (The Interactions API is GA as of 2026-07; it uses a different request shape than the generate/edit/set tools.)
  • output_dir per-call overrides $GEMINI_OUTPUT_DIR overrides cwd. inline: true returns bytes (with a metadata text block) instead of writing.
  • count and scenes are mutually exclusive in gemini_image_set; reference_mode: "chain" references the previous image instead of the master.
  • Aspect ratios: 1:1, 16:9, 9:16, 4:3, 3:4, 2:3, 3:2, … · Image sizes: 512 (0.5K, Flash only), 1K, 2K, 4K. 4K is the max native output — true 18×24 in @ 300 DPI (5400×7200) needs an external upscale step.
  • All generated images carry a SynthID watermark (Google).
  • The model can mis-render text/Roman numerals (e.g. years) — verify any text in the output; it's a model limitation, not a tool setting.
  • Best-performance languages: EN, plus ar, de, es-MX, fr, hi, id, it, ja, ko, pt-BR, ru, ua, vi, zh-CN — prefer prompting in one of these.
  • Asking the model for "N images" in one prompt is unreliable (documented limitation) — use the count parameter instead; it makes N independent calls with distinct seeds.
  • Server logs to stderr only — stdout is reserved for JSON-RPC.

推荐文章

更多
PHP时间戳与日期字符串相互转换方法详解

本文介绍PHP中时间数值(Unix时间戳)与日期字符串之间的相互转换方法。通过strtotime和date函数,实现将当前时间、指定日期转换为时间戳,以及将时间戳格式化为可读的日期时间字符串,并提供相关在线计算工具推荐。

2025.11.30 1,036
PHP日期转时间戳时区偏差怎么解决

在 PHP 中将日期字符串转换为时间戳时,若未显式指定时区,默认使用脚本配置的 date.timezone 或系统时区。当服务器时区与业务逻辑预期(如 UTC )不一致时,会产生偏差。解决核心是确保输入字符串携带明确时区信息,或在转换前统一设置时区上下文。

2026.10.24 1,031
JavaScript中利用replace结合正则实现replaceAll效果

JavaScript原生仅支持replace()进行单次或全局替换,缺乏类似Java的replaceAll()便捷方法。本文总结四种在JS中实现全量替换的方案:使用带g标志的正则、带gm标志的正则、扩展String原型以及split后join。通过对比代码示例,展示各方法的实现细节与适用场景,帮助开发者根据需求选择最优解。

2025.04.29 1,020
PHP跨域配置:怎么安全地允许指定域名而非使用通配符

在 PHP 中安全地允许指定域名跨域,核心是解析请求头中的 Origin ,验证其是否在白名单内,然后动态设置 Access-Control-Allow-Origin 响应头。不要使用通配符 * ,也不要硬编码单一域名。

2025.03.29 1,019
PHP实现基础文件上传:HTML表单与$_FILES处理流程

在 HTML 表单中设置 enctype="multipart/form-data" ,并在 PHP 后端通过 $_FILES 数组接收文件,调用 move_uploaded_file() 将临时文件移动到目标目录即可完成上传。

2026.09.07 1,016
OpenAI的Jalapeno芯片未落地,教你分辨300兆瓦算力消息

OpenAI计划在SB Energy租赁的数据中心部署约300兆瓦自研Jalapeno推理芯片,但目前双方仍处于洽谈阶段,交易细节与上线时间表均未公布。本文带你按报道原文核实项目所处阶段,厘清芯片发布、电力功率与实际推理算力的边界,并将融资意向与签约、开工、投运节点分开追踪,避免误将规划容量计入现有算力。

2026.12.02 1,014
Skill 文件
  • SKILL.md
    • gemini-mcp
    • Setup
      • Option A — npx (recommended)
      • Option B — from source
      • Getting your API key
    • Environment Variables
    • Tools
      • Models
      • Image Generation
      • Multi-turn (Interactions API)
      • Video & Music (preview — funded account)
      • Async / idempotency (any generation tool)
    • Workflows
    • Prompting playbook
    • Notes
  • 项目或源文件

相关 Skill

更多
service-qa-coach service-qa-coach Review support quality for chat, email, phone, social DM, or marketplace service teams. Use when a team needs a QA scorecard, failure-mode analysis, coaching plan, calibration checklist, or service-improvement brief without live ticketing, CRM, or contact-center system access.
高中数学作业批改助手 高中数学作业批改助手 >图片识别 直接读取学生手写作答照片,识别公式、符号、步骤 🧮 自动推导 根据题目自动生成参考答案和评分细则,无需教师预设 📊 逐步给分 每个关键步骤独立评分,体现过程分 📝 结构化报告 输出含识别内容、参考答案、逐步评分、改进建议的完整报告 🗂 批量批改 支持一次性批改多道题,最终汇总得分表
Vibration Analysis Vibration Analysis 分析来自CMS趋势、RMS/峰值、频谱及SCADA报警的风机传动链(主轴、齿轮箱、发电机)振动数据。
Traditional Bone Tool Making Basics Traditional Bone Tool Making Basics Use when you need custom, durable, repairable tools like awls, needles, scrapers, harpoons, or fishing hooks made from local animal bones or antlers and comm...
音频混音工具 音频混音工具 名称:Sound Mixing Tool(标识 sound-mixing-tool) 短简介(≤60字):音乐/音效响度精确对齐 + 融合混音工作流:用 ffmpeg 两段式 loudnorm 把多组素材 LUFS 偏差压到 <0.10,再最小干预融合、导出可进引擎的独立分轨。 标签/关键词:音频混音 响度匹配 LUFS ffmpeg 游戏音频 音效设计 Wwise FMOD 分轨导出 后期处理 触发词:混音 · 响度匹配 · LUFS 对齐 · MIX 版本 · 音乐音效分轨 · 融合 · 不打架 · 不能盖住 适用场景 :游戏音频集成、影视短视频配乐、播客后期