Skip to main content
Glama

enhance_prompt_gemini

Read-onlyIdempotent

Improve AI prompts using Gemini API strategies like Few-Shot examples and structured formatting to increase response quality and clarity.

Instructions

프롬프트 개선|제미나이 전략|품질 향상|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 Gemini prompting strategies (few-shot, output-format, etc.) to enhance the input prompt, generates structured output with improvements.
    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: 'Few-Shot 예시 추가',
          description: '2-3개의 고품질 예시를 추가하여 모델이 패턴을 학습하도록 유도',
          applied: addFewShotExamples(prompt, agent_role),
          improvement: '형식, 표현, 범위를 명확히 하여 일관성 향상'
        });
      }
    
      // 2. Output Format Specification
      if (strategiesToApply.includes('output-format')) {
        enhancements.push({
          strategy: '출력 형식 명시화',
          description: 'XML 태그나 마크다운 헤더로 구조화된 형식 지정',
          applied: specifyOutputFormat(prompt, agent_role),
          improvement: '원하는 응답 구조를 명확히 하여 파싱 용이성 향상'
        });
      }
    
      // 3. Context Placement
      if (strategiesToApply.includes('context-placement')) {
        enhancements.push({
          strategy: '컨텍스트 배치 최적화',
          description: '긴 컨텍스트를 특정 요청 전에 배치 (Gemini 3 최적화)',
          applied: optimizeContextPlacement(prompt),
          improvement: '모델이 컨텍스트를 더 효과적으로 활용'
        });
      }
    
      // 4. Prompt Decomposition
      if (strategiesToApply.includes('decomposition')) {
        enhancements.push({
          strategy: '프롬프트 분해',
          description: '복잡한 작업을 여러 단계로 분해하여 체인화',
          applied: decomposePrompt(prompt, agent_role),
          improvement: '각 단계의 출력 품질 향상, 디버깅 용이'
        });
      }
    
      // 5. Parameter Tuning Suggestions
      if (strategiesToApply.includes('parameters')) {
        enhancements.push({
          strategy: '매개변수 튜닝 제안',
          description: 'Temperature, Top-K, Top-P, Max Tokens 최적 값 제안',
          applied: suggestParameters(prompt, agent_role),
          improvement: '작업 유형에 맞는 모델 동작 최적화'
        });
      }
    
      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 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'],
        readOnlyHint: true,
        destructiveHint: false,
        idempotentHint: true,
        openWorldHint: false
      }
    };
  • src/index.ts:155-212 (registration)
    Registration of the tool handler in the toolHandlers object used for dynamic dispatch in callToolRequest handler.
    const toolHandlers: Record<string, ToolHandler> = {
      // Time & UI
      'get_current_time': getCurrentTime,
      'preview_ui_ascii': previewUiAscii,
    
      // Memory - Basic
      'save_memory': saveMemory,
      'recall_memory': recallMemory,
      'update_memory': updateMemory,
      'delete_memory': deleteMemory,
      'list_memories': listMemories,
      'prioritize_memory': prioritizeMemory,
    
      // Memory - Graph (v2.0 NEW)
      'link_memories': linkMemories,
      'get_memory_graph': getMemoryGraph,
      'search_memories_advanced': searchMemoriesAdvanced,
      'create_memory_timeline': createMemoryTimeline,
    
      // Memory - Session Context (v2.1 NEW)
      'get_session_context': getSessionContext,
    
      // Code Analysis
      'find_symbol': findSymbol,
      'find_references': findReferences,
      'analyze_dependency_graph': analyzeDependencyGraph,
    
      // Code Quality
      'get_coding_guide': getCodingGuide,
      'apply_quality_rules': applyQualityRules,
      'validate_code_quality': validateCodeQuality,
      'analyze_complexity': analyzeComplexity,
      'check_coupling_cohesion': checkCouplingCohesion,
      'suggest_improvements': suggestImprovements,
    
      // Thinking
      'create_thinking_chain': createThinkingChain,
      'analyze_problem': analyzeProblem,
      'step_by_step_analysis': stepByStepAnalysis,
      'format_as_plan': formatAsPlan,
    
      // Planning
      'generate_prd': generatePrd,
      'create_user_stories': createUserStories,
      'analyze_requirements': analyzeRequirements,
      'feature_roadmap': featureRoadmap,
    
      // Prompt
      'enhance_prompt': enhancePrompt,
      'analyze_prompt': analyzePrompt,
      'enhance_prompt_gemini': enhancePromptGemini,
    
      // Reasoning
      'apply_reasoning_framework': applyReasoningFramework,
    
      // Analytics (v2.0 NEW)
      'get_usage_analytics': getUsageAnalytics
    };
  • src/index.ts:88-145 (registration)
    Registration of the tool definition in the tools array returned by listToolsRequest handler.
    const tools = [
      // Core Utilities (2)
      getCurrentTimeDefinition,
      previewUiAsciiDefinition,
    
      // Memory Management - Basic (6)
      saveMemoryDefinition,
      recallMemoryDefinition,
      updateMemoryDefinition,
      deleteMemoryDefinition,
      listMemoriesDefinition,
      prioritizeMemoryDefinition,
    
      // Memory Management - Graph (4) - v2.0 NEW
      linkMemoriesDefinition,
      getMemoryGraphDefinition,
      searchMemoriesAdvancedDefinition,
      createMemoryTimelineDefinition,
    
      // Memory Management - Session Context (1) - v2.1 NEW
      getSessionContextDefinition,
    
      // Code Analysis - Semantic (2)
      findSymbolDefinition,
      findReferencesDefinition,
    
      // Code Analysis - Advanced (1) - v2.0 NEW
      analyzeDependencyGraphDefinition,
    
      // Code Quality (6)
      getCodingGuideDefinition,
      applyQualityRulesDefinition,
      validateCodeQualityDefinition,
      analyzeComplexityDefinition,
      checkCouplingCohesionDefinition,
      suggestImprovementsDefinition,
    
      // Thinking & Planning (8)
      createThinkingChainDefinition,
      analyzeProblemDefinition,
      stepByStepAnalysisDefinition,
      formatAsPlanDefinition,
      generatePrdDefinition,
      createUserStoriesDefinition,
      analyzeRequirementsDefinition,
      featureRoadmapDefinition,
    
      // Prompt Engineering (3)
      enhancePromptDefinition,
      analyzePromptDefinition,
      enhancePromptGeminiDefinition,
    
      // Reasoning (1)
      applyReasoningFrameworkDefinition,
    
      // Analytics (1) - v2.0 NEW
      getUsageAnalyticsDefinition
    ];
  • Supporting helper functions that implement individual Gemini strategies and format the final output.
    }
    
    // Helper methods
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already provide clear behavioral hints (readOnlyHint: true, destructiveHint: false, idempotentHint: true), but the description adds valuable context by specifying that it applies 'Gemini API prompting strategies' and lists specific techniques. This clarifies the tool's approach beyond the generic safety profile indicated by annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is efficiently structured as a tag-like list of keywords followed by a clarifying parenthetical explanation. While somewhat unconventional in format, it conveys essential information without redundancy. The front-loaded keywords make the core purpose immediately apparent, though the pipe-separated format could be more readable.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with comprehensive annotations and full schema coverage but no output schema, the description provides adequate context about the enhancement approach and strategy scope. However, it doesn't describe what the enhanced prompt output looks like or any limitations of the Gemini strategies, leaving some behavioral aspects unspecified despite good annotation coverage.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 100% schema description coverage, the input schema already documents all three parameters thoroughly. The description mentions 'strategies' generically but doesn't add meaningful semantic context beyond what the schema provides about parameters like 'agent_role' or 'strategies' enum values. Baseline score of 3 is appropriate given comprehensive schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with specific verbs ('Enhance prompts') and resources ('using Gemini API prompting strategies'), listing specific strategies like Few-Shot, Output Format, and Context. It distinguishes from the sibling 'enhance_prompt' tool by specifying 'Gemini strategies' in both the description and title annotation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context through 'Gemini API prompting strategies' and lists strategy names, but doesn't explicitly state when to use this tool versus alternatives like 'enhance_prompt' or other analysis tools. No guidance on prerequisites or exclusions is provided, leaving usage context partially inferred rather than clearly defined.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/su-record/hi-ai'

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