architecture.md•3.27 kB
# MCP Prompt Enhancer Architecture
This document describes the architecture of the MCP Prompt Enhancer server, which is designed to intelligently enhance prompts with relevant context from the user's project.
## Architecture Diagram
```mermaid
flowchart TD
subgraph Client["Client"]
Cline["Cline (Claude CLI)"]
MCPConfig["MCP Server Registry"]
end
subgraph Server["MCP Prompt Enhancer Server"]
STDIO["STDIO Interface"]
PE["PromptEnhancer"]
PCM["ProjectContextManager"]
TT["TaskTracker"]
Logger["Logger"]
end
subgraph Features["Core Features"]
CF1["Framework Detection"]
CF2["Task Type Inference"]
CF3["Focus Area Detection"]
CF4["Context Prioritization"]
CF5["Adaptive Prompt Generation"]
end
Cline -- "Registers" --> MCPConfig
MCPConfig -- "Configures" --> Cline
Cline -- "JSON Request via STDIO" --> STDIO
STDIO -- "JSON Response via STDIO" --> Cline
STDIO -- "Process Request" --> PE
PE -- "Get Project Context" --> PCM
PE -- "Track Task Context" --> TT
PCM -- "Analyze Files" --> FS["File System"]
PCM -- "Git History" --> Git["Git Repository"]
PE -- "Log Operations" --> Logger
PCM -- "Log Operations" --> Logger
TT -- "Log Operations" --> Logger
PCM --> CF1
TT --> CF2
TT --> CF3
PE --> CF4
PE --> CF5
```
## Component Descriptions
### Client Side
- **Cline (Claude CLI)**: Anthropic's official CLI tool for Claude that sends requests to and receives responses from the MCP Prompt Enhancer server via STDIO.
- **MCP Server Registry**: Configuration that registers the Prompt Enhancer as an available MCP server for Cline to utilize.
### Server Side
- **STDIO Interface**: Handles JSON-based communication over standard input/output streams.
- **PromptEnhancer**: Core component that combines project context with the user's prompt.
- **ProjectContextManager**: Analyzes and manages project-level context including file structure, dependencies, and code patterns.
- **TaskTracker**: Detects task type and focus area from the prompt and tracks relevant files.
- **Logger**: Provides logging functionality across components.
### Core Features
- **Framework Detection**: Identifies frameworks and libraries used in the project.
- **Task Type Inference**: Determines the type of task (debugging, creation, etc.) from the prompt.
- **Focus Area Detection**: Identifies the part of the codebase the prompt is focused on.
- **Context Prioritization**: Selects the most relevant context based on task type and focus area.
- **Adaptive Prompt Generation**: Combines the original prompt with selected context.
## Data Flow
1. Cline sends a JSON request to the MCP Prompt Enhancer server via STDIO
2. The server processes the request based on the action type
3. For `enhance_prompt`, the server:
- Analyzes the project context if needed
- Determines task type and focus area
- Selects relevant context
- Enhances the prompt with the selected context
4. The server returns a JSON response with the enhanced prompt
5. Cline receives the response and uses the enhanced prompt with Claude to provide better assistance to the user