Skip to main content
Glama

enhance_prompt_gemini

Improve AI prompts using Gemini strategies like few-shot examples and output formatting to increase response quality and clarity.

Instructions

prompt improvement|gemini strategies|quality improvement|prompt enhancement|gemini strategies|quality improvement - Enhance prompts using Gemini API prompting strategies (Few-Shot, Output Format, Context)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
promptYesThe original prompt to enhance
agent_roleNoThe role of the agent that will receive this prompt (e.g., "Specification Agent", "Planning Agent")
strategiesNoSpecific Gemini strategies to apply. If not provided, all strategies will be applied.

Implementation Reference

  • Main handler function implementing the enhance_prompt_gemini tool. Applies selected Gemini prompting strategies (few-shot, output-format, etc.) to enhance the input prompt and returns a structured result with enhancements.
    export async function enhancePromptGemini(args: { prompt: string; agent_role?: string; strategies?: string[]; }): Promise<ToolResult> { const { prompt, agent_role, strategies } = args; const allStrategies = ['few-shot', 'output-format', 'context-placement', 'decomposition', 'parameters']; const strategiesToApply = strategies && strategies.length > 0 ? strategies : allStrategies; const enhancements: PromptEnhancement[] = []; // 1. Few-Shot Examples if (strategiesToApply.includes('few-shot')) { enhancements.push({ strategy: 'Add Few-Shot Examples', description: 'Add 2-3 high-quality examples to guide the model to learn patterns', applied: addFewShotExamples(prompt, agent_role), improvement: 'Improve consistency by clarifying format, expression, and scope' }); } // 2. Output Format Specification if (strategiesToApply.includes('output-format')) { enhancements.push({ strategy: 'Output Format Specification', description: 'Specify structured format with XML tags or markdown headers', applied: specifyOutputFormat(prompt, agent_role), improvement: 'Clarify desired response structure for easier parsing' }); } // 3. Context Placement if (strategiesToApply.includes('context-placement')) { enhancements.push({ strategy: 'Context Placement Optimization', description: 'Place long context before specific requests (Gemini 3 optimization)', applied: optimizeContextPlacement(prompt), improvement: 'Help model utilize context more effectively' }); } // 4. Prompt Decomposition if (strategiesToApply.includes('decomposition')) { enhancements.push({ strategy: 'Prompt Decomposition', description: 'Decompose complex tasks into multiple steps and chain them', applied: decomposePrompt(prompt, agent_role), improvement: 'Improve output quality at each step, easier debugging' }); } // 5. Parameter Tuning Suggestions if (strategiesToApply.includes('parameters')) { enhancements.push({ strategy: 'Parameter Tuning Suggestions', description: 'Suggest optimal values for Temperature, Top-K, Top-P, Max Tokens', applied: suggestParameters(prompt, agent_role), improvement: 'Optimize model behavior for task type' }); } const result = { original_prompt: prompt, agent_role: agent_role || 'Generic Agent', strategies_applied: strategiesToApply, enhancements, enhanced_prompt: combineEnhancements(prompt, enhancements), summary: generateSummary(enhancements) }; const output = formatOutput(result); return { content: [{ type: 'text', text: output }] }; }
  • ToolDefinition schema defining the input schema, description, and annotations for the enhance_prompt_gemini tool.
    export const enhancePromptGeminiDefinition: ToolDefinition = { name: 'enhance_prompt_gemini', description: 'prompt improvement|gemini strategies|quality improvement|prompt enhancement|gemini strategies|quality improvement - Enhance prompts using Gemini API prompting strategies (Few-Shot, Output Format, Context)', inputSchema: { type: 'object', properties: { prompt: { type: 'string', description: 'The original prompt to enhance' }, agent_role: { type: 'string', description: 'The role of the agent that will receive this prompt (e.g., "Specification Agent", "Planning Agent")' }, strategies: { type: 'array', items: { type: 'string', enum: ['few-shot', 'output-format', 'context-placement', 'decomposition', 'parameters'] }, description: 'Specific Gemini strategies to apply. If not provided, all strategies will be applied.' } }, required: ['prompt'] }, annotations: { title: 'Enhance Prompt (Gemini Strategies)', audience: ['user', 'assistant'] } };
  • src/index.ts:686-687 (registration)
    Registration of the tool handler in the main switch statement for tool execution dispatching.
    case 'enhance_prompt_gemini': return await enhancePromptGemini(args as any) as CallToolResult;
  • src/index.ts:153-153 (registration)
    Inclusion of the tool definition in the tools array for MCP server listing.
    enhancePromptGeminiDefinition,
  • src/index.ts:75-75 (registration)
    Import statement bringing in the handler and definition for use in the MCP server.
    import { enhancePromptGemini, enhancePromptGeminiDefinition } from './tools/prompt/enhancePromptGemini.js';

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ssdeanx/ssd-ai'

If you have feedback or need assistance with the MCP directory API, please join our Discord server