server.py•10.6 kB
#!/usr/bin/env python3
from fastmcp import FastMCP
from typing import Dict, List, Any, Optional
import json
from PIL import Image
import requests
from io import BytesIO
import base64
app = FastMCP("dieter-rams")
DIETER_RAMS_PRINCIPLES = {
1: {
"title": "Good design is innovative",
"description": "It does not copy existing product forms, nor does it produce any kind of novelty for the sake of it. The essence of innovation must be clearly recognizable in the final product."
},
2: {
"title": "Good design makes a product useful",
"description": "A product is bought to be used. It has to satisfy certain criteria, not only functional, but also psychological and aesthetic."
},
3: {
"title": "Good design is aesthetic",
"description": "The aesthetic quality of a product is integral to its usefulness because products we use every day affect our person and our well-being."
},
4: {
"title": "Good design makes a product understandable",
"description": "It clarifies the product's structure. Better still, it can make the product talk. At best, it is self-explanatory."
},
5: {
"title": "Good design is unobtrusive",
"description": "Products fulfilling a purpose are like tools. They are neither decorative objects nor works of art. Their design should therefore be both neutral and restrained."
},
6: {
"title": "Good design is honest",
"description": "It does not make a product more innovative, powerful or valuable than it really is. It does not attempt to manipulate the consumer."
},
7: {
"title": "Good design is long-lasting",
"description": "It avoids being fashionable and therefore never appears antiquated. Unlike fashionable design, it lasts many years."
},
8: {
"title": "Good design is thorough down to the last detail",
"description": "Nothing must be arbitrary or left to chance. Care and accuracy in the design process show respect for the user."
},
9: {
"title": "Good design is environmentally-friendly",
"description": "Design makes an important contribution to the preservation of the environment. It conserves resources and minimizes physical and visual pollution."
},
10: {
"title": "Good design is as little design as possible",
"description": "Less, but better – because it concentrates on the essential aspects, and the products are not burdened with non-essentials."
}
}
def score_principle(principle_id: int, evidence: str, context: str = "") -> Dict[str, Any]:
"""Score a single principle based on evidence."""
principle = DIETER_RAMS_PRINCIPLES[principle_id]
# Simple scoring logic - could be enhanced with ML
score = 5 # Default neutral score
feedback = []
evidence_lower = evidence.lower()
# Principle-specific scoring
if principle_id == 1: # Innovation
if any(word in evidence_lower for word in ["unique", "novel", "innovative", "breakthrough"]):
score += 2
if any(word in evidence_lower for word in ["copy", "imitation", "clone"]):
score -= 2
elif principle_id == 2: # Usefulness
if any(word in evidence_lower for word in ["functional", "useful", "practical", "solves"]):
score += 2
if any(word in evidence_lower for word in ["useless", "impractical", "gimmick"]):
score -= 2
elif principle_id == 4: # Understandable
if any(word in evidence_lower for word in ["clear", "intuitive", "obvious", "self-explanatory"]):
score += 2
if any(word in evidence_lower for word in ["confusing", "complex", "unclear", "mysterious"]):
score -= 2
elif principle_id == 10: # Less but better
if any(word in evidence_lower for word in ["minimal", "simple", "essential", "clean"]):
score += 2
if any(word in evidence_lower for word in ["cluttered", "excessive", "overwhelming", "bloated"]):
score -= 2
# Clamp score between 1-10
score = max(1, min(10, score))
return {
"principle_id": principle_id,
"title": principle["title"],
"score": score,
"max_score": 10,
"evidence": evidence,
"feedback": feedback
}
@app.tool()
def evaluate_design(
product_name: str,
description: str,
evidence: Dict[str, str],
image_url: Optional[str] = None
) -> Dict[str, Any]:
"""
Evaluate a product design against all 10 Dieter Rams principles.
Args:
product_name: Name of the product being evaluated
description: Brief description of the product
evidence: Dictionary mapping principle numbers (as strings) to evidence text
image_url: Optional URL to product image for visual analysis
Returns:
Complete evaluation report with scores and recommendations
"""
results = []
total_score = 0
for principle_id in range(1, 11):
principle_evidence = evidence.get(str(principle_id), "No evidence provided")
result = score_principle(principle_id, principle_evidence)
results.append(result)
total_score += result["score"]
overall_score = total_score / 10
# Generate overall assessment
if overall_score >= 8:
assessment = "Excellent design that strongly embodies Dieter Rams' principles"
elif overall_score >= 6:
assessment = "Good design with room for improvement in some areas"
elif overall_score >= 4:
assessment = "Adequate design that needs significant refinement"
else:
assessment = "Design requires major rework to align with good design principles"
return {
"product_name": product_name,
"description": description,
"overall_score": round(overall_score, 2),
"assessment": assessment,
"principle_scores": results,
"recommendations": generate_recommendations(results)
}
@app.tool()
def principle_check(principle_id: int, evidence: str) -> Dict[str, Any]:
"""
Check a specific design principle against provided evidence.
Args:
principle_id: Which principle to check (1-10)
evidence: Description of how the product relates to this principle
Returns:
Detailed analysis of the specific principle
"""
if principle_id < 1 or principle_id > 10:
return {"error": "Principle ID must be between 1 and 10"}
result = score_principle(principle_id, evidence)
principle = DIETER_RAMS_PRINCIPLES[principle_id]
return {
"principle": principle,
"evaluation": result,
"suggestions": get_principle_suggestions(principle_id, result["score"])
}
@app.tool()
def get_principles() -> Dict[str, Any]:
"""
Get all 10 Dieter Rams principles with descriptions.
Returns:
Complete list of principles and their descriptions
"""
return {
"principles": DIETER_RAMS_PRINCIPLES,
"total_count": 10,
"philosophy": "Less, but better - Weniger, aber besser"
}
@app.tool()
def suggest_improvements(
current_scores: Dict[str, int],
focus_areas: Optional[List[str]] = None
) -> Dict[str, Any]:
"""
Suggest specific improvements based on principle scores.
Args:
current_scores: Dictionary of principle IDs to scores (1-10)
focus_areas: Optional list of specific areas to focus on
Returns:
Prioritized improvement suggestions
"""
suggestions = []
for principle_id_str, score in current_scores.items():
principle_id = int(principle_id_str)
if score < 7: # Focus on lower scores
suggestions.extend(get_principle_suggestions(principle_id, score))
# Sort by priority (lowest scores first)
suggestions.sort(key=lambda x: x.get("priority", 5))
return {
"suggestions": suggestions[:5], # Top 5 suggestions
"philosophy": "Focus on the principles with the lowest scores for maximum impact"
}
def generate_recommendations(results: List[Dict[str, Any]]) -> List[str]:
"""Generate actionable recommendations based on evaluation results."""
recommendations = []
# Find the lowest scoring principles
low_scores = [r for r in results if r["score"] < 6]
low_scores.sort(key=lambda x: x["score"])
for result in low_scores[:3]: # Top 3 lowest
principle_id = result["principle_id"]
if principle_id == 4: # Understandable
recommendations.append("Simplify the user interface and make core functions more obvious")
elif principle_id == 10: # Less but better
recommendations.append("Remove non-essential features and focus on core functionality")
elif principle_id == 2: # Useful
recommendations.append("Validate that all features serve a genuine user need")
elif principle_id == 5: # Unobtrusive
recommendations.append("Reduce visual noise and decorative elements")
elif principle_id == 8: # Thorough
recommendations.append("Pay attention to finishing details and edge cases")
if not recommendations:
recommendations.append("Continue refining the design while maintaining current quality")
return recommendations
def get_principle_suggestions(principle_id: int, score: int) -> List[Dict[str, Any]]:
"""Get specific suggestions for improving a principle score."""
suggestions = []
priority = 10 - score # Lower scores get higher priority
if principle_id == 1: # Innovation
if score < 7:
suggestions.append({
"principle": 1,
"suggestion": "Focus on solving problems in new ways rather than copying existing solutions",
"priority": priority
})
elif principle_id == 4: # Understandable
if score < 7:
suggestions.append({
"principle": 4,
"suggestion": "Use clear visual hierarchy and familiar interaction patterns",
"priority": priority
})
elif principle_id == 10: # Less but better
if score < 7:
suggestions.append({
"principle": 10,
"suggestion": "Remove features that don't directly serve the core purpose",
"priority": priority
})
return suggestions
if __name__ == "__main__":
app.run()