Skip to main content
Glama

enhance_prompt

Improve prompt quality by applying optimal engineering techniques like chain-of-thought reasoning based on intent analysis.

Instructions

Enhance a prompt with the best prompt engineering technique for its intent.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
promptYesThe raw prompt to enhance
techniqueNoForce a specific technique ID (optional)

Implementation Reference

  • The implementation of the `enhance_prompt` tool within the `dispatch` function in `bin/prompte-mcp.js`. It validates input, handles technique forcing, calls the `enhance` engine, updates session stats, and formats the result.
    case 'enhance_prompt': {
      const { prompt, technique: forceTechnique } = args;
      if (!prompt) throw new Error('prompt is required');
    
      let overrides = {};
      if (forceTechnique) {
        const { getTechniqueNames } = await import('../src/techniques/library.js');
        const others = getTechniqueNames().filter(id => id !== forceTechnique);
        overrides = { preferredTechniques: [forceTechnique], disabledTechniques: others };
      }
      const result = await enhance(prompt, overrides);
    
      sessionStats.enhanced++;
      if (result.technique) sessionStats.accepted++;
      else sessionStats.skipped++;
    
      // techniqueInstruction tells Claude how to apply the technique with its own
      // intelligence rather than using the static template verbatim.
      const techniqueInstruction = result.technique
        ? `Apply the ${result.technique.name} technique when answering: ${result.technique.description}.`
        : null;
    
      return {
        original: result.original,
        techniqueInstruction,
        technique: result.technique,
        intent: result.intent,
        confidence: result.confidence,
        bypassed: result.bypassed,
        // enhanced is still included for the UserPromptSubmit hook, which needs
        // a ready-to-use string before Claude sees the prompt at all.
        enhanced: result.enhanced,
      };
    }
  • The core `enhance` function in `src/engine/index.js` which orchestrates classification, technique scoring, and prompt rewriting.
    export async function enhance(prompt, overrideConfig = {}) {
      const globalConfig = getConfig();
      const projectConfig = getProjectConfig();
      const config = { ...globalConfig, ...projectConfig, ...overrideConfig };
    
      if (shouldBypass(prompt, config)) {
        return {
          original: prompt,
          enhanced: prompt.startsWith(config.bypassPrefix) ? prompt.slice(config.bypassPrefix.length).trimStart() : prompt,
          technique: null,
          intent: null,
          confidence: null,
          classifierMode: null,
          bypassed: true,
        };
      }
    
      const classification = classify(prompt);
      const { intent, confidence, techniqueScores, mode } = classification;
    
      const ranked = scoreTechniques(techniqueScores, config);
      const best = ranked[0];
    
      if (best.score < 0) {
        // All techniques disabled
        return {
          original: prompt,
          enhanced: prompt,
          technique: null,
          intent,
          confidence,
          classifierMode: mode,
          bypassed: false,
        };
      }
    
      const enhanced = best.technique.apply(prompt);
    
      return {
        original: prompt,
        enhanced,
        technique: {
          id: best.technique.id,
          name: best.technique.name,
          description: best.technique.description,
        },
        intent,
        confidence,
        classifierMode: mode,
        bypassed: false,
        score: best.score,
      };
    }
  • MCP tool registration for `enhance_prompt` in `bin/prompte-mcp.js`.
    {
      name: 'enhance_prompt',
      description: 'Enhance a prompt with the best prompt engineering technique for its intent.',
      inputSchema: {
        type: 'object',
        properties: {
          prompt: { type: 'string', description: 'The raw prompt to enhance' },
          technique: { type: 'string', description: 'Force a specific technique ID (optional)' },
        },
        required: ['prompt'],
      },
    },
Behavior3/5

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

Without annotations, the description carries full burden. It reveals intelligent selection logic ('best... for its intent') but fails to disclose return format, whether this is a pure function, or what occurs when intent classification is ambiguous.

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?

Single efficient sentence with no redundancy. However, given zero annotations and no output schema, it is under-specified rather than appropriately concise.

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?

Covers the primary transformation intent but omits critical context for a utility tool: return value structure, relationship to list_techniques for discovering technique IDs, and behavior when explicit technique parameter conflicts with auto-selected intent.

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?

Schema coverage is 100% with clear descriptions. The description adds context that 'technique' relates to 'prompt engineering' and implies optional automatic selection, but does not detail parameter interaction patterns or valid technique ID formats.

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

Purpose4/5

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

Clear action verb 'Enhance' with specific resource 'prompt' and domain context 'prompt engineering technique'. Mentions automatic selection based on 'intent', distinguishing it from generic prompt processing. However, lacks specificity about output format.

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

Usage Guidelines2/5

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

Provides no guidance on when to use the optional 'technique' parameter versus automatic selection, nor does it reference sibling tool 'list_techniques' which users might need to call first to discover available technique IDs.

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/AlanRoybal/prompte-mcp'

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