midjourney-mcp
Version:
A Model Context Protocol server for Midjourney integration via MJ API
267 lines • 8.6 kB
JavaScript
/**
* TypeScript type definitions for MCP (Model Context Protocol) integration
*/
// ============================================================================
// Midjourney Tool Schemas
// ============================================================================
export const MIDJOURNEY_IMAGINE_TOOL = {
name: "midjourney_imagine",
description: "Generate images using Midjourney with text prompts. Supports various parameters like aspect ratio, quality, and style settings.",
inputSchema: {
type: "object",
properties: {
prompt: {
type: "string",
description: "The text prompt for image generation. Be descriptive and specific for best results."
},
aspect_ratio: {
type: "string",
description: "Image aspect ratio",
enum: ["1:1", "16:9", "9:16", "4:3", "3:4", "2:3", "3:2", "5:4", "4:5"],
default: "1:1"
},
quality: {
type: "string",
description: "Image quality setting",
enum: ["low", "medium", "high"],
default: "medium"
},
style: {
type: "string",
description: "Style mode for generation",
enum: ["raw", "stylize"],
default: "stylize"
},
model: {
type: "string",
description: "Midjourney model to use",
enum: ["midjourney", "niji", "niji-5", "niji-6"],
default: "midjourney"
},
chaos: {
type: "number",
description: "Chaos level (0-100) - higher values produce more varied results",
minimum: 0,
maximum: 100
},
stylize: {
type: "number",
description: "Stylization level (0-1000) - higher values are more artistic",
minimum: 0,
maximum: 1000
},
weird: {
type: "number",
description: "Weirdness level (0-3000) - higher values produce more unusual results",
minimum: 0,
maximum: 3000
},
seed: {
type: "number",
description: "Seed for reproducible results"
},
no: {
type: "string",
description: "Negative prompt - things to avoid in the image"
},
reference_images: {
type: "array",
items: {
type: "string"
},
description: "Array of base64 encoded reference images"
}
},
required: ["prompt"]
}
};
export const MIDJOURNEY_UPSCALE_TOOL = {
name: "midjourney_upscale",
description: "Upscale a specific image from a completed Midjourney generation task.",
inputSchema: {
type: "object",
properties: {
task_id: {
type: "string",
description: "The ID of the completed generation task"
},
index: {
type: "number",
description: "Which image to upscale (1-4, corresponding to top-left, top-right, bottom-left, bottom-right)",
minimum: 1,
maximum: 4
}
},
required: ["task_id", "index"]
}
};
export const MIDJOURNEY_VARIATION_TOOL = {
name: "midjourney_variation",
description: "Create variations of a specific image from a completed Midjourney generation task.",
inputSchema: {
type: "object",
properties: {
task_id: {
type: "string",
description: "The ID of the completed generation task"
},
index: {
type: "number",
description: "Which image to create variations of (1-4)",
minimum: 1,
maximum: 4
}
},
required: ["task_id", "index"]
}
};
export const MIDJOURNEY_REROLL_TOOL = {
name: "midjourney_reroll",
description: "Reroll/regenerate a Midjourney task with the same prompt but different results.",
inputSchema: {
type: "object",
properties: {
task_id: {
type: "string",
description: "The ID of the task to reroll"
}
},
required: ["task_id"]
}
};
export const MIDJOURNEY_BLEND_TOOL = {
name: "midjourney_blend",
description: "Blend 2-5 images together to create a new combined image.",
inputSchema: {
type: "object",
properties: {
images: {
type: "array",
items: {
type: "string"
},
description: "Array of 2-5 base64 encoded images to blend",
minItems: 2,
maxItems: 5
},
aspect_ratio: {
type: "string",
description: "Aspect ratio for the blended image",
enum: ["1:1", "16:9", "9:16", "4:3", "3:4", "2:3", "3:2"],
default: "1:1"
}
},
required: ["images"]
}
};
export const MIDJOURNEY_DESCRIBE_TOOL = {
name: "midjourney_describe",
description: "Generate text descriptions of an image that could be used as prompts.",
inputSchema: {
type: "object",
properties: {
image: {
type: "string",
description: "Base64 encoded image to describe"
}
},
required: ["image"]
}
};
export const MIDJOURNEY_GET_TASK_TOOL = {
name: "midjourney_get_task",
description: "Get the status and results of a Midjourney task by ID.",
inputSchema: {
type: "object",
properties: {
task_id: {
type: "string",
description: "The ID of the task to check"
}
},
required: ["task_id"]
}
};
export const MIDJOURNEY_ACTION_TOOL = {
name: "midjourney_action",
description: "Execute a button action on a completed Midjourney task (like Zoom, Pan, etc.).",
inputSchema: {
type: "object",
properties: {
task_id: {
type: "string",
description: "The ID of the task with available actions"
},
action: {
type: "string",
description: "The action to perform (button label or custom ID)"
}
},
required: ["task_id", "action"]
}
};
// ============================================================================
// Tool Registry
// ============================================================================
export const ALL_MIDJOURNEY_TOOLS = [
MIDJOURNEY_IMAGINE_TOOL,
MIDJOURNEY_UPSCALE_TOOL,
MIDJOURNEY_VARIATION_TOOL,
MIDJOURNEY_REROLL_TOOL,
MIDJOURNEY_BLEND_TOOL,
MIDJOURNEY_DESCRIBE_TOOL,
MIDJOURNEY_GET_TASK_TOOL,
MIDJOURNEY_ACTION_TOOL,
];
// ============================================================================
// Helper Functions
// ============================================================================
export function getToolByName(name) {
return ALL_MIDJOURNEY_TOOLS.find(tool => tool.name === name);
}
export function isValidToolName(name) {
return ALL_MIDJOURNEY_TOOLS.some(tool => tool.name === name);
}
export function createTextContent(text) {
return {
type: 'text',
text
};
}
export function createImageContent(data, mimeType = 'image/png') {
return {
type: 'image',
data,
mimeType
};
}
export function createResourceContent(uri, mimeType, text) {
const resource = { uri };
if (mimeType !== undefined)
resource.mimeType = mimeType;
if (text !== undefined)
resource.text = text;
return {
type: 'resource',
resource
};
}
export function createToolResult(content, isError = false) {
return {
content,
isError
};
}
export function createErrorResult(message) {
return {
content: [createTextContent(`Error: ${message}`)],
isError: true
};
}
export function createSuccessResult(message, additionalContent = []) {
return {
content: [createTextContent(message), ...additionalContent],
isError: false
};
}
//# sourceMappingURL=mcp.js.map