Skip to content

External MCP Server Integration for "Enhance PromptΒ #6631

@alphaDev23

Description

@alphaDev23

What specific problem does this solve?

Feature Request: External MCP Server Integration for "Enhance Prompt"

πŸ”„ Summary

This feature request proposes adding support in RooCode to route the "Enhance Prompt" functionality through an external MCP (Model Context Protocol) server. The purpose is to allow advanced users to replace RooCode's default LLM-based enhancement with a custom enhancement pipeline, such as one powered by DSPy (see https://dspy.ai/api/) memory injection, or other structured prompt augmentation systems.

This enhancement should be user-configurable through the RooCode settings interface and easily extendable in future updates.


βš–οΈ Motivation

Currently, the "Enhance Prompt" button in RooCode rewrites user prompts using a static system prompt and routes the input through the default model provider. While this improves clarity and completeness, it lacks modularity, memory access, and extensibility.

Many developers and researchers want:

  • Programmatic control over prompt enhancement
  • Integration of memory/context into prompt transformations
  • Feedback-driven rewriting (e.g., CoT, ReAct, few-shot injection)
  • Support for DSPy and other LLM orchestration systems

βš™οΈ Proposed Feature

1. New Settings (in settings.json or internal config store):

"enhancePrompt.useExternalServer": true,
"enhancePrompt.endpoint": "http://localhost:8000/enhance"

2. Expected Request Payload (POST to external MCP endpoint):

{
  "prompt": "raw user prompt",
  "context": [
    { "role": "user", "content": "..." },
    { "role": "assistant", "content": "..." }
  ],
  "model": "gpt-4"
}

3. Expected Response:

{
  "enhancedPrompt": "rewritten or optimized prompt"
}

πŸ–ŒοΈ Code Changes

File: src/core/webview/messageEnhancer.ts

Add import:

import fetch from "node-fetch"; // or use global fetch in Electron

Modify inside enhanceMessage():

if (settings.enhancePrompt?.useExternalServer) {
  try {
    const response = await fetch(settings.enhancePrompt.endpoint, {
      method: "POST",
      headers: { "Content-Type": "application/json" },
      body: JSON.stringify({
        prompt: userPrompt,
        context: contextMessages,
        model: this.llm?.modelID ?? "unknown"
      })
    });

    const result = await response.json();
    return result.enhancedPrompt ?? userPrompt;
  } catch (err) {
    console.error("Failed to enhance prompt via external server:", err);
    // Fallback to default logic
  }
}

// Existing internal enhancement logic...

πŸ’‘ Benefits

  • βœ… Allows prompt enhancement logic to be modular, externalized, and testable.
  • βœ… Supports local DSPy servers, memory augmentation, retrieval, chain-of-thought rewriting, and more.
  • βœ… Makes RooCode more extensible for power users, research workflows, and enterprise setups.
  • βœ… Compatible with future DSPy features like multi-objective prompt optimization.
  • βœ… Fully backward compatible and optional.

πŸ” Optional Enhancements (Future Work)

  • UI toggle in Settings > Experimental to enable/disable external MCP routing.
  • Logging panel to show prompt transformation previews.
  • Ability to test multiple enhancement strategies via dropdown.

πŸ‘ Summary for Developers

To implement this:

  1. Add two new settings.
  2. Wrap the enhanceMessage() logic in a conditional that checks for useExternalServer.
  3. POST prompt + context to the configured endpoint.
  4. Use the returned enhanced prompt.
  5. Fallback to existing internal logic if the request fails or the setting is disabled.

This enables seamless external override of RooCode's Enhance Prompt system with almost zero impact on the current user base.

Additional context (optional)

No response

Roo Code Task Links (Optional)

No response

Request checklist

  • I've searched existing Issues and Discussions for duplicates
  • This describes a specific problem with clear impact and context

How will we know it works? (Acceptance Criteria - REQUIRED if contributing, optional otherwise)

No response

Technical considerations (REQUIRED if contributing, optional otherwise)

No response

Trade-offs and risks (REQUIRED if contributing, optional otherwise)

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue/PR - TriageNew issue. Needs quick review to confirm validity and assign labels.enhancementNew feature or requestproposal

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions