ImageGen.McpHost
0.1.0
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet tool install --global ImageGen.McpHost --version 0.1.0
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest
dotnet tool install --local ImageGen.McpHost --version 0.1.0
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=ImageGen.McpHost&version=0.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
nuke :add-package ImageGen.McpHost --version 0.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
ImageGen MCP Server
A provider-agnostic Model Context Protocol server for AI image generation.
Switch between Stability AI and Google Gemini Imagen using runtime tool arguments — your MCP client never notices the change.
Features
- Three MCP tools:
image_gen_generate,image_gen_get_credits,image_gen_info - Two providers out of the box: Stability AI (sd3-large, core) and Google Gemini Imagen 3
- Fail-fast startup — validates config before the server accepts any connections
- Polly resilience — automatic retries with jitter on transient 5xx / 429 errors
- FluentValidation — prompt length, aspect ratio, and step range are checked before any HTTP call
- Hexagonal Architecture — add a new provider by implementing one interface, touching zero existing files
- All logs → stderr — stdout is reserved exclusively for MCP JSON-RPC traffic
Quick Start
1. Prerequisites
- .NET 10 SDK
- A Stability AI or Google Gemini API key
2. Build
git clone https://github.com/your-org/Mcp.Server.ImageGen
cd Mcp.Server.ImageGen
dotnet build ImageGen.slnx
3. Configure & Run
Stability AI:
$env:STABILITY_API_KEY = "sk-..."
dotnet run --project ImageGen.McpHost
Google Gemini:
$env:GEMINI_API_KEY = "AIza..."
dotnet run --project ImageGen.McpHost
4. Connect to Claude Desktop
Add to %APPDATA%\Claude\claude_desktop_config.json:
{
"mcpServers": {
"image-gen": {
"command": "dotnet",
"args": ["run", "--project", "C:\\path\\to\\ImageGen.McpHost", "--no-build"],
"env": {
"STABILITY_API_KEY": "sk-..."
}
}
}
}
Environment Variables (API Keys Only)
| Variable | Required | Description |
|---|---|---|
STABILITY_API_KEY |
✅ for Stability provider | Stability AI API key |
GEMINI_API_KEY |
✅ for Gemini provider | Google AI Studio API key |
Tool Reference
image_gen_generate
prompt (required) Text description of the image
aspect_ratio 1:1 | 16:9 | 9:16 | 4:3 | 3:4 | 2:3 | 3:2 | 21:9 | 9:21 | 4:5 | 5:4
steps 1–150, default 30
seed optional integer for reproducibility
model provider-specific model name override
Returns the absolute path of the saved image file.
image_gen_get_credits
Returns remaining credits for the active provider (Stability AI only; Gemini returns N/A).
image_gen_info
Returns the active provider name, supported models, and output directory.
Solution Structure
ImageGen.slnx
├── ImageGen.Domain/ Pure interfaces, value objects, exceptions
├── ImageGen.Application/ Use cases, ProviderFactory, FluentValidation, MCP tools
├── ImageGen.Infrastructure/ StabilityAdapter, GeminiAdapter, Polly, ImageFileHelper
├── ImageGen.McpHost/ Console host — thin bootstrap, fail-fast config check
├── ImageGen.Tests/ xUnit tests: validators, use cases, adapters (mocked HTTP)
└── Documentation/ DocFX documentation site
Running Tests
dotnet test ImageGen.slnx
All tests run without network access — HTTP responses are intercepted by FakeHttpMessageHandler.
Building the Docs
dotnet tool restore
dotnet build Documentation/Documentation.csproj
# Output: _site/
Adding a New Provider
See Adding a New Provider — four steps, only the Infrastructure layer is touched.
License
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
This package has no dependencies.