This MCP server provides a complete implementation of the Midjourney Model Context Protocol, allowing you to generate high-quality images through the GPTNB API. It supports various image operations including generation, transformation, editing, face swapping, and description.
To use the MCP server, you'll need:
# Clone the repository
git clone <repository-url>
cd mj-mcp
# Install dependencies
pip install -r requirements.txt
# Or install as an editable package
pip install -e .
Set up your API credentials using environment variables:
# Windows
set GPTNB_API_KEY=your_api_key_here
set GPTNB_BASE_URL=https://aiclound.vip
# Linux/Mac
export GPTNB_API_KEY=your_api_key_here
export GPTNB_BASE_URL=https://aiclound.vip
Alternatively, create a .env
file in the project root:
GPTNB_API_KEY=your_api_key_here
GPTNB_BASE_URL=https://aiclound.vip
Start the MCP server using one of these methods:
# Direct execution
python src/server.py
# Or using MCP Inspector tool
npx @modelcontextprotocol/inspector python src/server.py
The server provides 6 core image manipulation tools:
Tool Name | Description | Key Parameters |
---|---|---|
imagine_image |
Generate images from text | prompt , aspect_ratio , base64_images |
blend_images |
Combine multiple images | base64_images , dimensions |
describe_image |
Analyze image content | base64_image |
change_image |
Transform existing images | task_id , action , index |
modal_edit |
Advanced image editing | task_id , action , prompt |
swap_face |
Replace faces in images | source_image , target_image |
There's also a utility tool for managing tasks:
Tool Name | Description | Key Parameters |
---|---|---|
get_task_status |
Check task progress | task_id |
To create a new image from a text prompt:
# Using MCP client
result = await session.call_tool("imagine_image", {
"prompt": "a beautiful sunset over mountains, digital art",
"aspect_ratio": "16:9"
})
To generate variations of a previously created image:
# Generate variations
result = await session.call_tool("change_image", {
"task_id": "previous_task_id",
"action": "VARIATION",
"index": 1
})
You can chain multiple operations together to create complex image workflows. For example:
imagine_image
change_image
modal_edit
Each operation returns a task ID that can be used to track progress or as input for subsequent operations.
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "midjourney" '{"command":"python","args":["src/server.py"]}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"midjourney": {
"command": "python",
"args": [
"src/server.py"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"midjourney": {
"command": "python",
"args": [
"src/server.py"
]
}
}
}
3. Restart Claude Desktop for the changes to take effect