diff --git a/mcp-server/src/imageGenerator.ts b/mcp-server/src/imageGenerator.ts index 41e865a..00b9c6b 100644 --- a/mcp-server/src/imageGenerator.ts +++ b/mcp-server/src/imageGenerator.ts @@ -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 { try { const platform = process.platform; @@ -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', @@ -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', @@ -574,7 +583,7 @@ export class ImageGenerator { ); const response = await this.ai.models.generateContent({ - model: this.modelName, + model: this.resolveModel(request), contents: [ { role: 'user', diff --git a/mcp-server/src/index.ts b/mcp-server/src/index.ts index 40ce958..ea10d79 100644 --- a/mcp-server/src/index.ts +++ b/mcp-server/src/index.ts @@ -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'], }, @@ -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'], }, @@ -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'], }, @@ -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'], }, @@ -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'], }, @@ -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'], }, @@ -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'], }, @@ -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); @@ -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; @@ -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; @@ -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); @@ -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); @@ -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, @@ -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); diff --git a/mcp-server/src/types.ts b/mcp-server/src/types.ts index 61f5bc4..6c152f9 100644 --- a/mcp-server/src/types.ts +++ b/mcp-server/src/types.ts @@ -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[];