claude-foundry-image
claude-foundry-image
Claude Code 插件,为每个项目和每次对话提供由你自己的 Azure AI Foundry 部署(MAI 图像 API,例如 MAI-Image-2.5-Pro)支持的图像生成器。
MCP 服务器 (
server/server.mjs) — 需要 Node ≥ 18,零依赖。工具:generate_image,edit_image,check_config。技能
generate-image— 教导 Claude 何时使用这些工具,如何将一行提示扩展为可用的提示、有效的尺寸,以及写文件的路径。技能
setup— 一次性配置向导。
图像写入磁盘;只有文件路径进入对话。上下文中不包含 base64。
安装
claude plugin marketplace add jpaarhuis/claude-foundry-imageclaude plugin install foundry-image@jpaarhuis或者在交互式会话中:/plugin → Marketplaces → 添加 jpaarhuis/claude-foundry-image → 安装 foundry-image。
Related MCP server: gpt-image-mcp
配置(一次性)
服务器从环境变量读取其设置。将它们放在 ~/.claude/settings.json 的 env 下 — 一个文件,所有平台,仅 Claude Code 可见:
{
"env": {
"MAI_IMAGE_ENDPOINT": "https://<resource>.services.ai.azure.com/mai/v1/images/generations",
"MAI_IMAGE_DEPLOYMENT": "MAI-Image-2.5-Pro",
"MAI_IMAGE_API_KEY": "<key>",
"MAI_IMAGE_OUTPUT_DIR": "C:/Users/<you>/Pictures/ai"
}
}或者将它们设置为操作系统用户环境变量(Windows 上使用 setx,macOS/Linux 上在 shell 配置文件中使用 export)。无论哪种方式,都需要重启 Claude Code。
然后,在任何会话中:"运行 check_config" 或 /foundry-image:setup 进行引导式配置。
变量 | 必需 | 含义 |
| 是 | 以 |
| 是 | Foundry 中的部署名称 |
| 是 | 资源密钥 |
| 否 | 默认输出文件夹;如果未设置则回退到操作系统临时目录 |
使用
只需询问:"为 README 创建一个英雄图像,深色,等距,无文字"。Claude 会扩展提示,选择尺寸,写入 PNG(如果属于仓库则写入仓库内部)并返回路径。
工具参数,供参考:
工具 | 参数 |
|
|
|
|
| — |
MAI API 的尺寸规则:每边 ≥ 768 像素,且宽度 × 高度 ≤ 1,048,576 像素。因此 1024x1024、1024x768、1280x800 有效;1024x1536 和 1920x1080 无效。
为什么使用环境变量而不是配置文件或设置对话框?
Claude Code 插件没有每个插件的秘密存储或设置 UI。约定 — 与官方 GitHub 插件为其 PAT 使用的约定相同 — 是在插件的 .mcp.json 中使用 ${VAR} 扩展,由用户一次性设置变量。settings.json → env 是阻力最小的位置:它随你的 Claude Code 配置文件一起迁移,适用于每个项目,并在插件更新后仍然存在。
如果希望密钥不在纯文本文件中,可以在登录时从密钥存储(Key Vault、1Password CLI、Windows 凭据管理器)将其加载到环境中 — 服务器不关心变量来自哪里。
开发
npm test运行离线冒烟测试:MCP 握手、工具列表、尺寸保护、缺少配置的错误,并检查 check_config 从不泄露密钥。
许可证
MIT
Available Tools
3 toolscheck_configA
Report whether the Foundry image server is configured (which environment variables are set, endpoint and deployment in use, output directory). Never reveals the API key. Call this first when a generation fails with a configuration error.
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description must disclose behavioral traits. It states the tool reports config status without revealing the API key, which is a notable safety disclosure. However, it does not explicitly declare read-only behavior, potential delays, or what happens if the server is unreachable. The disclosure is adequate but not thorough.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description consists of two efficient sentences with zero wasted words. The first sentence front-loads the tool's purpose and scope, the second adds usage guidance. It is appropriately sized for the tool's simplicity.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a zero-parameter diagnostic tool with no output schema, the description covers what it reports, what it excludes, and when to invoke it. It lacks details on output format, but given the context (image generation siblings), the provided information is sufficient for an agent to select and invoke correctly.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
There are no parameters (0 params), so per the rubric baseline is 4. The description adds no parameter info, but none is needed. Schema coverage is trivially 100%.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool reports configuration status of the Foundry image server, listing specific elements (environment variables, endpoint, deployment, output directory) and explicitly excludes revealing the API key. It distinguishes from sibling tools (edit_image, generate_image) which are about image manipulation, not config checking.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description explicitly advises 'Call this first when a generation fails with a configuration error,' providing clear when-to-use guidance. It also states what it does not reveal (API key), which implicitly guides against expecting that output. No explicit when-not or alternatives, but sibling differentiation is sufficient.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
edit_imageA
Edit an existing PNG or JPEG with gpt-image-2 on Azure AI Foundry, following a text instruction. The result is written to disk as a PNG and the tool returns its path. The source file is never modified.
| Name | Required | Description | Default |
|---|---|---|---|
| image | Yes | Path to the source PNG or JPEG. | |
| prompt | Yes | What to change in the image. | |
| output_path | No | Where to write the result. Must end in .png. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
The description says the result is written to disk as a PNG and the source file is never modified, which are useful behavioral details. However, with no annotations provided, the description carries full burden. It does not disclose if the operation is reversible, whether it requires any specific authentication or permissions, or any side effects (e.g., whether it overwrites existing output files silently). It mentions the output is a PNG even if the source is JPEG, which is valuable. Overall, it provides moderate transparency but lacks some important details.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is very concise: three sentences covering purpose, output format, and behavioral assurance. No superfluous words. It is front-loaded with the core action and a clear summary. Each sentence adds distinct value.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool has three parameters (all with schema descriptions), no output schema, no annotations, and no nested objects, the description provides the essential context for an editing operation with output to disk. It explains the return value (path to the result) despite there being no output schema. However, it does not specify if the prompt can be a plain text instruction or requires specific formatting, nor does it list supported edit capabilities (e.g., only simple changes? complex edits?). For a tool with no annotations, this leaves some gaps in completeness.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100% (all three parameters have descriptions in the schema), so the baseline is 3. The tool description adds value beyond the schema by confirming that 'image' must be a path to a PNG or JPEG, 'prompt' is a text instruction for editing, and 'output_path' must end with '.png'. The description contextually reinforces the parameter meanings, helping the agent understand their roles beyond the schema's property descriptions.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states that this tool edits existing PNG or JPEG images using gpt-image-2 on Azure AI Foundry, following a text instruction. It also specifies that the result is saved to disk as a PNG and the source file is never modified. This provides a specific verb (edit), resource (PNG/JPEG image), and distinct operation (following a text prompt). It distinguishes edit from the sibling generate_image (which likely creates new images instead of editing existing ones).
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description mentions the supported image formats (PNG, JPEG) and that the source file remains unchanged, but it does not provide explicit guidance on when to use this tool versus the sibling tools check_config or generate_image. There is no 'when to use' or 'when not to use' advice, and no mention of prerequisites (e.g., image must exist, must be a supported format). The agent is left to infer usage context from the tool name and input schema.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
generate_imageA
Generate a PNG image with gpt-image-2 on Azure AI Foundry. The image is written to disk and the tool returns its path; it is not returned inline. Use a detailed prompt covering subject, style, composition, lighting and colors. Each side must be at least 768 pixels and width x height must not exceed 1048576 pixels, so 1024x1024, 768x1024 and 1024x768 are valid but 1024x1536 is not.
| Name | Required | Description | Default |
|---|---|---|---|
| width | No | Image width in pixels. Default 1024. | |
| height | No | Image height in pixels. Default 1024. | |
| prompt | Yes | Description of the image to generate. | |
| output_path | No | Where to write the PNG. Must end in .png. Relative paths resolve against the current working directory. Defaults to a timestamped file in the output directory. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full burden. It clearly discloses that the image is written to disk and the path is returned (not inline), and it specifies dimension constraints. However, it does not disclose error behavior, permission requirements, rate limits, or what happens if constraints are violated, leaving room for improvement.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is two sentences, front-loaded with the core purpose and output format, followed by prompt guidance and constraints. Every sentence is necessary and informative, with no redundancy or wasted words. It is highly efficient.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool has 4 parameters, no output schema, and no annotations, the description covers the essential aspects: purpose, output format, constraints, and prompt advice. It is mostly complete but lacks details on error handling, performance, or any prerequisites, which would be nice to have for a generation tool.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 100%, so the description adds value beyond the schema by explaining the dimension constraints (min 768px sides, max 1048576 total pixels) and examples of valid sizes. It also adds context about prompt quality. The fact that the tool returns the path is not in the schema but is in the description. This meaningfully supplements the parameter definitions.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool generates a PNG image using gpt-image-2 on Azure AI Foundry, and distinguishes it from the sibling tools 'edit_image' (editing) and 'check_config' (configuration checking). The verb 'generate' and resource 'PNG image' are specific, and the output behavior (written to disk, returns path) is explicitly noted.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides actionable guidance: 'Use a detailed prompt covering subject, style, composition, lighting and colors.' It also gives explicit dimension constraints (minimum side 768px, max total pixels 1048576) with valid examples. However, it does not explicitly state when to use this tool versus alternatives (e.g., edit_image), nor does it mention any prerequisites or context for using the tool.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
3 tool updates
v1.0.0- First observed
check_config - First observed
edit_image - First observed
generate_image
TDQS
Scored across 3 tools
Each tool has a clearly distinct purpose: check_config is diagnostic, edit_image modifies an existing image, generate_image creates a new one. No overlap or ambiguity.
All tools follow a consistent verb_noun snake_case pattern: check_config, edit_image, generate_image. No mixing of styles.
Three tools is well-scoped for an image generation and editing server. Each tool serves a necessary function without bloat or deficiency.
The core lifecycle of generation and editing is covered, but there is no tool for deleting images or enumerating previously generated files. These are minor gaps that agents can work around.
Maintenance
Related MCP Connectors
Focused MCP server for OpenAI image/audio generation (v2.0.0). Wraps endpoints via HAPI CLI.
MCP server for Qwen Image 3 AI image generation
Use AI models for chat, image, and video generation from Claude Code and other MCP hosts.
MCP server for OpenAI API (chat completions, image generation, embeddings) via AceDataCloud
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceMCP server that enables Claude Code to generate images using Google's Gemini image generation models.MIT
- AlicenseAqualityDmaintenanceAn MCP server that enables Claude Code and Claude Desktop to generate and edit images using OpenAI's gpt-image-2 model, with results saved to disk.2MIT
- FlicenseNot gradedqualityCmaintenanceMCP server for generating and editing images using gpt-image-2. Enables image creation, editing, listing, and retrieval via natural language tools.-
- AlicenseAqualityCmaintenanceAn MCP server that enables generating images via OpenAI and images/videos via Google Gemini (including Veo video generation), saving outputs to local asset folders. It integrates with Claude Code and any MCP client using your own API keys.3MIT