Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions mcp-server/src/imageGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ export class ImageGenerator {
console.error(`DEBUG - Using image model: ${this.modelName}`);
}

private resolveModel(request: ImageGenerationRequest): string {
if (request.model && request.model !== this.modelName) {
console.error(
`DEBUG - Overriding model for this call: ${request.model} (server default: ${this.modelName})`,
);
}
return request.model || this.modelName;
}

private async openImagePreview(filePath: string): Promise<void> {
try {
const platform = process.platform;
Expand Down Expand Up @@ -265,7 +274,7 @@ export class ImageGenerator {
try {
// Make API call for each variation
const response = await this.ai.models.generateContent({
model: this.modelName,
model: this.resolveModel(request),
contents: [
{
role: 'user',
Expand Down Expand Up @@ -451,7 +460,7 @@ export class ImageGenerator {

try {
const response = await this.ai.models.generateContent({
model: this.modelName,
model: this.resolveModel(request),
contents: [
{
role: 'user',
Expand Down Expand Up @@ -574,7 +583,7 @@ export class ImageGenerator {
);

const response = await this.ai.models.generateContent({
model: this.modelName,
model: this.resolveModel(request),
contents: [
{
role: 'user',
Expand Down
42 changes: 42 additions & 0 deletions mcp-server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ class NanoBananaServer {
'Automatically open generated images in default viewer',
default: false,
},
model: {
type: 'string',
description:
"Overrides the server's default model for this single call (optional)",
},
},
required: ['prompt'],
},
Expand All @@ -127,6 +132,11 @@ class NanoBananaServer {
'Automatically open generated images in default viewer',
default: false,
},
model: {
type: 'string',
description:
"Overrides the server's default model for this single call (optional)",
},
},
required: ['prompt', 'file'],
},
Expand All @@ -152,6 +162,11 @@ class NanoBananaServer {
'Automatically open generated images in default viewer',
default: false,
},
model: {
type: 'string',
description:
"Overrides the server's default model for this single call (optional)",
},
},
required: ['prompt', 'file'],
},
Expand Down Expand Up @@ -210,6 +225,11 @@ class NanoBananaServer {
'Automatically open generated images in default viewer',
default: false,
},
model: {
type: 'string',
description:
"Overrides the server's default model for this single call (optional)",
},
},
required: ['prompt'],
},
Expand Down Expand Up @@ -267,6 +287,11 @@ class NanoBananaServer {
'Automatically open generated images in default viewer',
default: false,
},
model: {
type: 'string',
description:
"Overrides the server's default model for this single call (optional)",
},
},
required: ['prompt'],
},
Expand Down Expand Up @@ -326,6 +351,11 @@ class NanoBananaServer {
'Automatically open generated images in default viewer',
default: false,
},
model: {
type: 'string',
description:
"Overrides the server's default model for this single call (optional)",
},
},
required: ['prompt'],
},
Expand Down Expand Up @@ -392,6 +422,11 @@ class NanoBananaServer {
'Automatically open generated images in default viewer',
default: false,
},
model: {
type: 'string',
description:
"Overrides the server's default model for this single call (optional)",
},
},
required: ['prompt'],
},
Expand Down Expand Up @@ -424,6 +459,7 @@ class NanoBananaServer {
noPreview:
(args?.noPreview as boolean) ||
(args?.['no-preview'] as boolean),
model: args?.model as string,
};
response =
await this.imageGenerator.generateTextToImage(imageRequest);
Expand All @@ -439,6 +475,7 @@ class NanoBananaServer {
noPreview:
(args?.noPreview as boolean) ||
(args?.['no-preview'] as boolean),
model: args?.model as string,
};
response = await this.imageGenerator.editImage(editRequest);
break;
Expand All @@ -453,6 +490,7 @@ class NanoBananaServer {
noPreview:
(args?.noPreview as boolean) ||
(args?.['no-preview'] as boolean),
model: args?.model as string,
};
response = await this.imageGenerator.editImage(restoreRequest);
break;
Expand All @@ -468,6 +506,7 @@ class NanoBananaServer {
noPreview:
(args?.noPreview as boolean) ||
(args?.['no-preview'] as boolean),
model: args?.model as string,
};
response =
await this.imageGenerator.generateTextToImage(iconRequest);
Expand All @@ -483,6 +522,7 @@ class NanoBananaServer {
noPreview:
(args?.noPreview as boolean) ||
(args?.['no-preview'] as boolean),
model: args?.model as string,
};
response =
await this.imageGenerator.generateTextToImage(patternRequest);
Expand All @@ -499,6 +539,7 @@ class NanoBananaServer {
noPreview:
(args?.noPreview as boolean) ||
(args?.['no-preview'] as boolean),
model: args?.model as string,
};
response = await this.imageGenerator.generateStorySequence(
storyRequest,
Expand All @@ -516,6 +557,7 @@ class NanoBananaServer {
noPreview:
(args?.noPreview as boolean) ||
(args?.['no-preview'] as boolean),
model: args?.model as string,
};
response =
await this.imageGenerator.generateTextToImage(diagramRequest);
Expand Down
2 changes: 2 additions & 0 deletions mcp-server/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ export interface ImageGenerationRequest {
inputImage?: string;
outputCount?: number;
mode: 'generate' | 'edit' | 'restore';
// Overrides the server default model for a single call (NANOBANANA_MODEL / DEFAULT_MODEL)
model?: string;
// Batch generation options
styles?: string[];
variations?: string[];
Expand Down