Connect AI assistants like Claude Code and Claude Desktop to generate images using the Model Context Protocol (MCP). Uses the same Bearer token authentication as the REST API.
The Model Context Protocol is an open standard that lets AI assistants call external tools. Our MCP server exposes image generation as tools that AI assistants can invoke directly during a conversation.
Unlike the REST API (which is asynchronous), MCP tool calls are synchronous — the assistant submits a generation request, waits for it to finish, and receives the final image URL in one step.
/api/mcp
https://www.aiphotogenerator.net/api/mcp
Streamable HTTP transport. All communication happens over this single endpoint using JSON-RPC 2.0.
Uses the same API token as the REST API. Include it in the Authorization header:
Authorization: Bearer YOUR_API_TOKEN
You can find your API token in the user dropdown menu at the top right corner of the page.
Add the following to your MCP client configuration.
Add to your project's .mcp.json file:
{
"mcpServers": {
"aiphotogenerator": {
"type": "http",
"url": "https://www.aiphotogenerator.net/api/mcp",
"headers": {
"Authorization": "Bearer YOUR_API_TOKEN"
}
}
}
}
Add to your Claude Desktop config file (claude_desktop_config.json):
{
"mcpServers": {
"aiphotogenerator": {
"type": "http",
"url": "https://www.aiphotogenerator.net/api/mcp",
"headers": {
"Authorization": "Bearer YOUR_API_TOKEN"
}
}
}
}
generate_imageGenerate an AI image from a text prompt. The tool waits for generation to complete and returns the final image URL.
| Parameter | Type | Required | Description |
|---|---|---|---|
prompt |
string | Required | Text prompt describing the image to generate (max 1024 characters) |
model |
string | Optional | AI model key. Default: nano-banana. Use list_models to see all options. |
width |
integer | Optional | Image width in pixels (512–4096). Default: 1024 |
height |
integer | Optional | Image height in pixels (512–4096). Default: 1024 |
input_image_url |
string | Optional | URL of an input image for image-to-image generation |
On success, returns a JSON object:
{
"image_url": "https://...",
"image_id": "abc123xyz",
"credits_used": 5,
"credits_remaining": 95
}
list_modelsList all available AI models with their capabilities, supported dimensions, and credit costs. Takes no parameters.
Returns an array of model objects:
{
"models": [
{
"key": "nano-banana",
"name": "Nano Banana",
"description": "...",
"provider": "replicate",
"quality_rating": 4,
"pricing_rating": 5,
"supports_text_to_image": true,
"supports_image_to_image": false
}
]
}
Once configured, you can ask the AI assistant to generate images directly in conversation:
You: Generate a watercolor painting of a sunset over mountains
Claude: I'll generate that image for you.
[Calls generate_image with prompt "A watercolor painting of a sunset over mountains"]
Here's your image: https://...
Used 5 credits, 95 remaining.
You can also test the endpoint directly with curl:
curl -X POST https://www.aiphotogenerator.net/api/mcp \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/list",
"params": {}
}'
Each image generation costs credits based on the output dimensions and model used, identical to the REST API. The tool will return an error if you have insufficient credits.
Need more credits? Upgrade your plan or purchase additional credits.