get_learned_preferences
Retrieve automatically learned user preferences with confidence scores from AI correction patterns, enabling personalized configuration updates.
Instructions
Get all learned preferences with confidence scores (automatically learned from corrections)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| category | No | Filter by category (optional) | |
| min_confidence | No | Minimum confidence threshold |
Implementation Reference
- src/mcp_standards/server.py:204-215 (registration)MCP tool registration including name, description, and input schema for get_learned_preferences.Tool( name="get_learned_preferences", description="Get all learned preferences with confidence scores (automatically learned from corrections)", inputSchema={ "type": "object", "properties": { "category": {"type": "string", "description": "Filter by category (optional)"}, "min_confidence": {"type": "number", "description": "Minimum confidence threshold", "default": 0.7}, }, }, ), Tool(
- src/mcp_standards/server.py:560-578 (handler)Main handler function for the get_learned_preferences tool, delegates to PatternExtractor and formats response.async def _get_learned_preferences( self, category: Optional[str] = None, min_confidence: float = 0.7 ) -> Dict[str, Any]: """Get learned preferences with confidence scores""" try: preferences = self.pattern_extractor.get_learned_preferences( category=category, min_confidence=min_confidence ) return { "success": True, "preferences": preferences, "count": len(preferences), "category": category or "all" } except Exception as e: return {"success": False, "error": str(e)}
- Core helper function that queries the tool_preferences SQLite table to retrieve learned preferences filtered by category and confidence.def get_learned_preferences( self, category: Optional[str] = None, min_confidence: float = 0.7 ) -> List[Dict[str, Any]]: """Get all learned preferences, optionally filtered""" with sqlite3.connect(self.db_path) as conn: conn.row_factory = sqlite3.Row if category: cursor = conn.execute(""" SELECT * FROM tool_preferences WHERE category = ? AND confidence >= ? ORDER BY confidence DESC, apply_count DESC """, (category, min_confidence)) else: cursor = conn.execute(""" SELECT * FROM tool_preferences WHERE confidence >= ? ORDER BY confidence DESC, apply_count DESC """, (min_confidence,)) return [dict(row) for row in cursor.fetchall()]