Successfully enabled the context-aware prompt tools that were previously defined but never registered in the MCP server.
File: src/mcp_server/mcp_app.py
Line: 173
from src.mcp_server.tools.context_aware_prompt import register_context_aware_toolsFile: src/mcp_server/mcp_app.py
Line: 195
register_context_aware_tools(self.mcp)The following three context-aware prompt tools are now registered and available via MCP:
Purpose: Generate context-aware prompts based on query and context
Parameters:
query(str): User query or requestcontext(Optional[Dict]): Optional context informationprompt_type(str): Type of prompt - "search", "analysis", "explanation", "comparison", "recommendation"
Returns:
prompt: Generated context-aware promptprompt_type: Type of prompt usedhas_context: Whether context was providedcontext_length: Length of contextquery_length: Length of query
Example Usage:
result = await generate_contextual_prompt(
query="How does authentication work?",
context={"framework": "FastAPI", "language": "Python"},
prompt_type="explanation"
)Purpose: Extract relevant keywords from text for context understanding
Parameters:
text(str): Text to analyzemax_keywords(int): Maximum number of keywords to extract (default: 10)
Returns:
keywords: List of extracted keywordscount: Number of keywords extractedtext_length: Length of input textunique_words: Number of unique words found
Example Usage:
result = await extract_context_keywords(
text="This is a Python FastAPI application with authentication and database integration",
max_keywords=5
)
# Returns: ["python", "fastapi", "application", "authentication", "database"]Purpose: Optimize prompts based on context type and desired response format
Parameters:
prompt(str): Original prompt to optimizecontext_type(str): Type of context - "code", "documentation", "analysis", "troubleshooting", "learning", "general"response_format(str): Desired format - "detailed", "concise", "technical", "practical", "educational"
Returns:
optimized_prompt: Enhanced prompt with context guidelinesoriginal_prompt: Original promptcontext_type: Context type usedresponse_format: Response format usedcontext_instruction: Context-specific instruction addedformat_instruction: Format-specific instruction added
Example Usage:
result = await optimize_prompt_for_context(
prompt="Explain how to implement authentication",
context_type="code",
response_format="practical"
)Before: 10 tool categories registered
After: 11 tool categories registered
The MCP server now registers:
- ✅ Health Tools
- ✅ Capability Tools
- ✅ Indexing Tools
- ✅ Vector Tools
- ✅ Search Tools
- ✅ Pattern Search Tools
- ✅ Cross-Language Tools
- ✅ Query Understanding Tools
- ✅ Indexing Optimization Tools
- ✅ Prompt Tools
- ✅ Context-Aware Prompt Tools (NEW)
cd deployment/docker
docker-compose restart context-serverdocker logs context-server | grep -i "context-aware"Expected output:
INFO: Registered context-aware prompt tools
- Close Claude Code CLI completely
- Wait 5 seconds
- Reopen Claude Code CLI
Ask Claude:
What MCP tools are available from the Context server?
You should see the three new tools listed:
generate_contextual_promptextract_context_keywordsoptimize_prompt_for_context
Test 1: Generate Contextual Prompt
Use the generate_contextual_prompt tool to create a search prompt for "authentication functions" with context about Python and FastAPI.
Test 2: Extract Keywords
Use the extract_context_keywords tool to extract keywords from this text: "This Python application uses FastAPI for REST API development with PostgreSQL database and Redis caching"
Test 3: Optimize Prompt
Use the optimize_prompt_for_context tool to optimize this prompt: "How do I implement caching?" for code context with practical response format.
- ✅
src/mcp_server/mcp_app.py(added import and registration) - ✅
CONTEXT_AWARE_TOOLS_ENABLED.md(this documentation)
src/mcp_server/tools/context_aware_prompt.py(existing tool definitions)src/mcp_server/stdio_full_mcp.py(uses mcp_app.py's register_tools method)
These tools enable:
- Better prompt engineering for AI interactions
- Context-aware query enhancement for more relevant results
- Keyword extraction for understanding user intent
- Prompt optimization for different use cases (code, docs, analysis, etc.)
After verifying the tools work correctly, you may want to:
- Test the tools with real queries in Claude Code CLI
- Integrate these tools into your workflow for enhanced code search
- Consider enabling other optional tools if needed (cache management, query optimization, etc.)