feat: add comprehensive environment and trending analysis prompt templates

Environment Analysis Templates:
- analyze_environment_dependencies: Analyze current Python environment and dependencies
- check_outdated_packages: Check for outdated packages with update priorities
- generate_update_plan: Create comprehensive package update plans with strategies

Trending Analysis Templates:
- analyze_daily_trends: Analyze daily PyPI download trends and popular packages
- find_trending_packages: Discover trending packages over different time periods
- track_package_updates: Track recent package updates and releases

Key Features:
- Follow standard MCP workflow with {{parameter}} template variables
- Support environment analysis (uvx pip list integration ready)
- Enable trending package discovery and popularity analysis
- Provide structured update planning with different strategies
- Include comprehensive parameter validation and documentation
- Add usage examples and integration guides

All templates follow the established MCP prompt workflow:
1. User calls tool → MCP client sends request
2. Tool function executes → Collects necessary data and parameters
3. Call Prompt generator → Pass parameters to corresponding generator
4. Load template → Get template with {{parameter}} placeholders
5. Parameter replacement → Replace {{parameter_name}} with actual values
6. Return final prompt → As tool's response back to AI

Updated documentation and README with new template examples and usage patterns.

Signed-off-by: longhao <hal.long@outlook.com>
This commit is contained in:
longhao 2025-05-29 16:36:58 +08:00 committed by Hal
parent 4bdf38d455
commit d63ef02ef3
6 changed files with 989 additions and 0 deletions

View File

@ -186,6 +186,124 @@ Generate a detailed migration checklist prompt.
}
```
### Environment Analysis Templates
#### 9. `analyze_environment_dependencies`
Generate a prompt for analyzing current environment dependencies.
**Parameters:**
- `environment_type` (optional): Type of environment (local, virtual, docker, conda)
- `python_version` (optional): Python version in the environment
- `project_path` (optional): Path to the project directory
**Use Case:** When you need to analyze your current Python environment and check for outdated packages.
**Example:**
```json
{
"environment_type": "virtual",
"python_version": "3.11",
"project_path": "/path/to/project"
}
```
#### 10. `check_outdated_packages`
Generate a prompt for checking outdated packages with update priorities.
**Parameters:**
- `package_filter` (optional): Filter packages by name pattern
- `severity_level` (optional): Focus level (all, security, major, minor)
- `include_dev_dependencies` (optional): Include development dependencies
**Use Case:** When you want to identify and prioritize package updates.
**Example:**
```json
{
"package_filter": "django*",
"severity_level": "security",
"include_dev_dependencies": true
}
```
#### 11. `generate_update_plan`
Generate a prompt for creating comprehensive package update plans.
**Parameters:**
- `update_strategy` (optional): Update strategy (conservative, balanced, aggressive)
- `environment_constraints` (optional): Environment constraints or requirements
- `testing_requirements` (optional): Testing requirements before updates
**Use Case:** When you need a structured plan for updating packages in your environment.
**Example:**
```json
{
"update_strategy": "balanced",
"environment_constraints": "Production environment, zero downtime required",
"testing_requirements": "Full test suite + integration tests"
}
```
### Trending Analysis Templates
#### 12. `analyze_daily_trends`
Generate a prompt for analyzing daily PyPI download trends.
**Parameters:**
- `date` (optional): Specific date to analyze (YYYY-MM-DD) or 'today'
- `category` (optional): Package category to focus on (web, data, ml, etc.)
- `limit` (optional): Number of top packages to analyze (5-50)
**Use Case:** When you want to understand what packages are trending on PyPI.
**Example:**
```json
{
"date": "today",
"category": "machine-learning",
"limit": 20
}
```
#### 13. `find_trending_packages`
Generate a prompt for discovering trending packages over time periods.
**Parameters:**
- `time_period` (optional): Time period for trend analysis (daily, weekly, monthly)
- `trend_type` (optional): Type of trends to focus on (rising, declining, new, all)
- `domain` (optional): Specific domain or category (web, ai, data, etc.)
**Use Case:** When you want to discover packages that are gaining or losing popularity.
**Example:**
```json
{
"time_period": "weekly",
"trend_type": "rising",
"domain": "web-development"
}
```
#### 14. `track_package_updates`
Generate a prompt for tracking recent package updates and releases.
**Parameters:**
- `time_range` (optional): Time range for update tracking (today, week, month)
- `update_type` (optional): Type of updates to track (all, major, security, new)
- `popular_only` (optional): Focus only on popular packages (>1M downloads)
**Use Case:** When you want to stay informed about recent package updates and releases.
**Example:**
```json
{
"time_range": "week",
"update_type": "security",
"popular_only": true
}
```
## 🚀 Usage Examples
### In Claude Desktop

View File

@ -217,6 +217,16 @@ The server provides the following MCP tools:
17. **plan_package_migration** - Generate comprehensive package migration plan prompts
18. **generate_migration_checklist** - Generate detailed migration checklist prompts
### Environment Analysis Templates
19. **analyze_environment_dependencies** - Generate prompts for analyzing current environment dependencies
20. **check_outdated_packages** - Generate prompts for checking outdated packages with update priorities
21. **generate_update_plan** - Generate prompts for creating comprehensive package update plans
### Trending Analysis Templates
22. **analyze_daily_trends** - Generate prompts for analyzing daily PyPI download trends
23. **find_trending_packages** - Generate prompts for discovering trending packages over time periods
24. **track_package_updates** - Generate prompts for tracking recent package updates and releases
> 📖 **Learn more about prompt templates**: See [PROMPT_TEMPLATES.md](PROMPT_TEMPLATES.md) for detailed documentation and examples.
## Usage Examples
@ -254,6 +264,18 @@ Once configured in your MCP client (Claude Desktop, Cline, Cursor, Windsurf), yo
- "Help me resolve dependency conflicts with a structured prompt"
- "Generate a security audit prompt for my production packages"
### Environment Analysis
- "Analyze my current Python environment dependencies and check for outdated packages"
- "Check which packages in my environment have security updates available"
- "Generate an update plan for my production environment with conservative strategy"
- "Help me identify packages that need immediate updates vs. planned updates"
### Trending Analysis
- "What are the most downloaded Python packages today?"
- "Show me trending packages in the machine learning domain this week"
- "Track recent security updates and new package releases"
- "Find rising packages in web development that I should consider"
### Example Conversations
**User**: "Check if Django 4.2 is compatible with Python 3.9"

View File

@ -9,6 +9,11 @@ from .dependency_management import (
plan_version_upgrade,
resolve_dependency_conflicts,
)
from .environment_analysis import (
analyze_environment_dependencies,
check_outdated_packages,
generate_update_plan,
)
from .migration_guidance import (
generate_migration_checklist,
plan_package_migration,
@ -18,6 +23,11 @@ from .package_analysis import (
compare_packages,
suggest_alternatives,
)
from .trending_analysis import (
analyze_daily_trends,
find_trending_packages,
track_package_updates,
)
__all__ = [
# Package Analysis
@ -28,7 +38,15 @@ __all__ = [
"resolve_dependency_conflicts",
"plan_version_upgrade",
"audit_security_risks",
# Environment Analysis
"analyze_environment_dependencies",
"check_outdated_packages",
"generate_update_plan",
# Migration Guidance
"plan_package_migration",
"generate_migration_checklist",
# Trending Analysis
"analyze_daily_trends",
"find_trending_packages",
"track_package_updates",
]

View File

@ -0,0 +1,291 @@
"""Environment analysis prompt templates for PyPI MCP server."""
from typing import Annotated
from fastmcp import Context
from pydantic import Field
class Message:
"""Simple message class for prompt templates."""
def __init__(self, text: str, role: str = "user"):
self.text = text
self.role = role
async def analyze_environment_dependencies(
environment_type: Annotated[
str,
Field(description="Type of environment (local, virtual, docker, conda)")
] = "local",
python_version: Annotated[
str | None,
Field(description="Python version in the environment")
] = None,
project_path: Annotated[
str | None,
Field(description="Path to the project directory")
] = None,
ctx: Context | None = None,
) -> str:
"""Generate a prompt template for analyzing environment dependencies.
This prompt template helps analyze the current Python environment dependencies,
check for outdated packages, and provide upgrade recommendations.
Returns a template string with {{environment_type}}, {{python_version}}, and {{project_path}} variables.
"""
template = """Please analyze the Python environment dependencies {{environment_info}}.
## 🔍 Environment Analysis Request
I need to analyze my current Python environment to understand:
### Current Environment Status
- List all installed packages and their versions (use `{{command_prefix}}pip list`)
- Identify the Python version and environment type
- Check for any conflicting or problematic installations
### Package Version Analysis
- Compare installed versions with latest available on PyPI
- Identify outdated packages that have newer versions
- Highlight packages with security updates available
- Check for packages with major version updates
### Dependency Health Check
- Analyze dependency relationships and conflicts
- Identify unused or redundant packages
- Check for packages with known vulnerabilities
- Assess overall environment health
## 📊 Detailed Analysis Framework
### For Each Package, Provide:
1. **Current vs Latest Version**
- Installed version
- Latest stable version on PyPI
- Version gap analysis (patch/minor/major updates)
2. **Update Priority Assessment**
- Security updates (HIGH priority)
- Bug fixes and stability improvements (MEDIUM priority)
- New features and enhancements (LOW priority)
3. **Compatibility Impact**
- Breaking changes in newer versions
- Dependency chain effects
- Potential conflicts with other packages
### Environment Optimization Recommendations
- Packages safe to update immediately
- Packages requiring careful testing before update
- Packages to avoid updating (due to breaking changes)
- Cleanup recommendations for unused packages
## 🚀 Action Plan
Provide a prioritized action plan with:
- Immediate updates (security and critical fixes)
- Planned updates (with testing requirements)
- Long-term upgrade strategy
- Environment maintenance best practices
Please include specific commands for package management and update procedures."""
return template
async def check_outdated_packages(
package_filter: Annotated[
str | None,
Field(description="Filter packages by name pattern (optional)")
] = None,
severity_level: Annotated[
str,
Field(description="Focus level: all, security, major, minor")
] = "all",
include_dev_dependencies: Annotated[
bool,
Field(description="Include development dependencies in analysis")
] = True,
ctx: Context | None = None,
) -> str:
"""Generate a prompt template for checking outdated packages.
This prompt template helps identify and prioritize outdated packages
in the current environment with specific focus criteria.
Returns a template string with {{package_filter}}, {{severity_level}}, and {{dev_deps}} variables.
"""
template = """Please check for outdated packages in my Python environment {{filter_info}}.
## 🔍 Outdated Package Analysis
Focus on {{severity_level}} updates{{dev_deps_text}}.
### Analysis Scope
- Check all installed packages against PyPI latest versions
- Identify packages with available updates
- Categorize updates by severity and importance
- Assess update risks and benefits
## 📋 Update Categories
### 🚨 Security Updates (Critical)
- Packages with known security vulnerabilities
- CVE fixes and security patches
- Immediate action required packages
### 🔧 Bug Fixes & Stability (Important)
- Critical bug fixes
- Stability improvements
- Performance enhancements
### ✨ Feature Updates (Optional)
- New features and capabilities
- API improvements
- Non-breaking enhancements
### ⚠️ Major Version Updates (Careful)
- Breaking changes
- API modifications
- Requires thorough testing
## 📊 For Each Outdated Package, Provide:
1. **Version Information**
- Current version installed
- Latest available version
- Release date of latest version
- Version type (patch/minor/major)
2. **Update Assessment**
- Change log highlights
- Breaking changes (if any)
- Security implications
- Dependency impact
3. **Recommendation**
- Update priority (High/Medium/Low)
- Testing requirements
- Rollback considerations
- Best update timing
## 🎯 Prioritized Update Plan
Create a step-by-step update plan:
1. **Immediate Updates** (security and critical fixes)
2. **Planned Updates** (important improvements)
3. **Future Considerations** (major version upgrades)
4. **Monitoring Setup** (track future updates)
Include specific pip/uv commands for each update category."""
return template
async def generate_update_plan(
update_strategy: Annotated[
str,
Field(description="Update strategy: conservative, balanced, aggressive")
] = "balanced",
environment_constraints: Annotated[
str | None,
Field(description="Environment constraints or requirements")
] = None,
testing_requirements: Annotated[
str | None,
Field(description="Testing requirements before updates")
] = None,
ctx: Context | None = None,
) -> str:
"""Generate a prompt template for creating package update plans.
This prompt template helps create comprehensive update plans for Python environments
with specific strategies and constraints.
Returns a template string with {{strategy}}, {{constraints}}, and {{testing}} variables.
"""
template = """Please create a comprehensive package update plan using a {{strategy}} strategy{{constraints_text}}{{testing_text}}.
## 🎯 Update Strategy: {{strategy}}
### Strategy Guidelines
- **Conservative**: Only security and critical bug fixes
- **Balanced**: Security fixes + stable improvements + selected features
- **Aggressive**: Latest versions with careful testing
## 📋 Update Plan Framework
### Phase 1: Pre-Update Assessment
1. **Environment Backup**
- Create requirements.txt snapshot
- Document current working state
- Set up rollback procedures
2. **Dependency Analysis**
- Map dependency relationships
- Identify potential conflicts
- Plan update order
3. **Risk Assessment**
- Categorize packages by update risk
- Identify critical dependencies
- Plan testing scope
### Phase 2: Staged Update Execution
#### Stage 1: Critical Security Updates
- Packages with known vulnerabilities
- Zero-day fixes and security patches
- Immediate deployment candidates
#### Stage 2: Stability Improvements
- Bug fixes and performance improvements
- Compatibility updates
- Low-risk enhancements
#### Stage 3: Feature Updates
- New functionality additions
- API improvements
- Non-breaking enhancements
#### Stage 4: Major Version Updates
- Breaking changes requiring code updates
- Comprehensive testing required
- Gradual rollout recommended
### Phase 3: Validation & Monitoring
#### Testing Protocol
- Unit test execution
- Integration testing
- Performance regression testing
- User acceptance testing
#### Deployment Strategy
- Development environment first
- Staging environment validation
- Production deployment with monitoring
- Rollback procedures ready
## 🔧 Implementation Commands
Provide specific commands for:
1. **Environment preparation**
2. **Package updates by category**
3. **Testing and validation**
4. **Rollback procedures**
## 📊 Success Metrics
Define success criteria:
- All tests passing
- No performance degradation
- Security vulnerabilities addressed
- Functionality maintained
Include monitoring setup for ongoing package management."""
return template

View File

@ -0,0 +1,363 @@
"""Trending analysis prompt templates for PyPI MCP server."""
from typing import Annotated, Literal
from fastmcp import Context
from pydantic import Field
class Message:
"""Simple message class for prompt templates."""
def __init__(self, text: str, role: str = "user"):
self.text = text
self.role = role
async def analyze_daily_trends(
date: Annotated[
str | None,
Field(description="Specific date to analyze (YYYY-MM-DD) or 'today'")
] = "today",
category: Annotated[
str | None,
Field(description="Package category to focus on (web, data, ml, etc.)")
] = None,
limit: Annotated[
int,
Field(description="Number of top packages to analyze", ge=5, le=50)
] = 20,
ctx: Context | None = None,
) -> str:
"""Generate a prompt template for analyzing daily PyPI trends.
This prompt template helps analyze the most downloaded packages on PyPI
for a specific day and understand trending patterns.
Returns a template string with {{date}}, {{category_filter}}, and {{limit}} variables.
"""
template = """Please analyze the daily PyPI download trends for {{date}}{{category_filter}}.
## 📊 Daily PyPI Trends Analysis
Show me the top {{limit}} most downloaded Python packages and provide insights into current trends.
### Download Statistics Analysis
- **Top Downloaded Packages**: List the most popular packages by download count
- **Download Numbers**: Specific download counts for each package
- **Growth Patterns**: Compare with previous days/weeks if possible
- **Market Share**: Relative popularity within the ecosystem
## 🔍 Trend Analysis Framework
### For Each Top Package, Analyze:
1. **Package Overview**
- Package name and primary purpose
- Current version and release status
- Maintainer and community info
2. **Download Metrics**
- Daily download count
- Weekly/monthly trends (if available)
- Growth rate and momentum
- Geographic distribution (if available)
3. **Ecosystem Context**
- Category/domain (web, data science, ML, etc.)
- Competing packages in same space
- Integration with other popular packages
- Enterprise vs. individual usage patterns
### Trending Insights
#### 🚀 Rising Stars
- Packages with significant growth
- New packages gaining traction
- Emerging technologies and frameworks
#### 📈 Steady Leaders
- Consistently popular packages
- Foundational libraries and tools
- Mature ecosystem components
#### 📉 Declining Trends
- Packages losing popularity
- Potential reasons for decline
- Alternative packages gaining ground
## 🎯 Market Intelligence
### Technology Trends
- What technologies are developers adopting?
- Which frameworks are gaining momentum?
- What problem domains are hot?
### Developer Behavior
- Package selection patterns
- Adoption speed of new technologies
- Community preferences and choices
### Ecosystem Health
- Diversity of popular packages
- Innovation vs. stability balance
- Open source project vitality
## 📋 Actionable Insights
Provide recommendations for:
- **Developers**: Which packages to consider for new projects
- **Maintainers**: Opportunities for package improvement
- **Organizations**: Technology adoption strategies
- **Investors**: Emerging technology trends
Include specific download numbers, growth percentages, and trend analysis."""
return template
async def find_trending_packages(
time_period: Annotated[
Literal["daily", "weekly", "monthly"],
Field(description="Time period for trend analysis")
] = "weekly",
trend_type: Annotated[
Literal["rising", "declining", "new", "all"],
Field(description="Type of trends to focus on")
] = "rising",
domain: Annotated[
str | None,
Field(description="Specific domain or category (web, ai, data, etc.)")
] = None,
ctx: Context | None = None,
) -> str:
"""Generate a prompt template for finding trending packages.
This prompt template helps identify packages that are trending up or down
in the PyPI ecosystem over specific time periods.
Returns a template string with {{time_period}}, {{trend_type}}, and {{domain_filter}} variables.
"""
template = """Please identify {{trend_type}} trending Python packages over the {{time_period}} period{{domain_filter}}.
## 📈 Trending Package Discovery
Focus on packages showing significant {{trend_type}} trends in downloads and adoption.
### Trend Analysis Criteria
#### For {{trend_type}} Packages:
- **Rising**: Packages with increasing download velocity
- **Declining**: Packages losing popularity or downloads
- **New**: Recently published packages gaining traction
- **All**: Comprehensive trend analysis across categories
### Time Period: {{time_period}}
- **Daily**: Last 24-48 hours trend analysis
- **Weekly**: 7-day trend patterns and changes
- **Monthly**: 30-day trend analysis and momentum
## 🔍 Discovery Framework
### Trend Identification Metrics
1. **Download Growth Rate**
- Percentage increase/decrease in downloads
- Velocity of change (acceleration/deceleration)
- Consistency of trend direction
2. **Community Engagement**
- GitHub stars and forks growth
- Issue activity and resolution
- Community discussions and mentions
3. **Release Activity**
- Recent version releases
- Update frequency and quality
- Feature development pace
### For Each Trending Package, Provide:
#### 📊 Trend Metrics
- Current download numbers
- Growth/decline percentage
- Trend duration and stability
- Comparison with similar packages
#### 🔍 Package Analysis
- **Purpose and Functionality**: What problem does it solve?
- **Target Audience**: Who is using this package?
- **Unique Value Proposition**: Why is it trending?
- **Competition Analysis**: How does it compare to alternatives?
#### 🚀 Trend Drivers
- **Technology Shifts**: New frameworks or paradigms
- **Community Events**: Conferences, tutorials, viral content
- **Industry Adoption**: Enterprise or startup usage
- **Integration Opportunities**: Works well with popular tools
## 🎯 Trend Categories
### 🌟 Breakout Stars
- New packages with explosive growth
- Innovative solutions to common problems
- Next-generation tools and frameworks
### 📈 Steady Climbers
- Consistent growth over time
- Building solid user base
- Proven value and reliability
### ⚡ Viral Hits
- Sudden popularity spikes
- Social media or community driven
- May need sustainability assessment
### 🔄 Comeback Stories
- Previously popular packages regaining traction
- Major updates or improvements
- Community revival efforts
## 📋 Strategic Insights
### For Developers
- Which trending packages to evaluate for projects
- Early adoption opportunities and risks
- Technology direction indicators
### For Package Maintainers
- Competitive landscape changes
- Opportunities for collaboration
- Feature gaps in trending solutions
### For Organizations
- Technology investment directions
- Skill development priorities
- Strategic technology partnerships
Include specific trend data, growth metrics, and actionable recommendations."""
return template
async def track_package_updates(
time_range: Annotated[
Literal["today", "week", "month"],
Field(description="Time range for update tracking")
] = "today",
update_type: Annotated[
Literal["all", "major", "security", "new"],
Field(description="Type of updates to track")
] = "all",
popular_only: Annotated[
bool,
Field(description="Focus only on popular packages (>1M downloads)")
] = False,
ctx: Context | None = None,
) -> str:
"""Generate a prompt template for tracking recent package updates.
This prompt template helps track and analyze recent package updates
on PyPI with filtering and categorization options.
Returns a template string with {{time_range}}, {{update_type}}, and {{popularity_filter}} variables.
"""
template = """Please track and analyze Python package updates from {{time_range}}{{popularity_filter}}.
## 📦 Package Update Tracking
Focus on {{update_type}} updates and provide insights into recent changes in the Python ecosystem.
### Update Analysis Scope
- **Time Range**: {{time_range}}
- **Update Type**: {{update_type}} updates
- **Package Selection**: {{popularity_description}}
## 🔍 Update Categories
### 🚨 Security Updates
- CVE fixes and security patches
- Vulnerability remediation
- Security-related improvements
### 🎯 Major Version Updates
- Breaking changes and API modifications
- New features and capabilities
- Architecture improvements
### 🔧 Minor Updates & Bug Fixes
- Bug fixes and stability improvements
- Performance enhancements
- Compatibility updates
### 🌟 New Package Releases
- Brand new packages published
- First stable releases (1.0.0)
- Emerging tools and libraries
## 📊 For Each Update, Provide:
### Update Details
1. **Package Information**
- Package name and description
- Previous version New version
- Release date and timing
2. **Change Analysis**
- Key changes and improvements
- Breaking changes (if any)
- New features and capabilities
- Bug fixes and security patches
3. **Impact Assessment**
- Who should update and when
- Compatibility considerations
- Testing requirements
- Migration effort (for major updates)
### Ecosystem Impact
- **Dependency Effects**: How updates affect dependent packages
- **Community Response**: Developer adoption and feedback
- **Integration Impact**: Effects on popular development stacks
## 🎯 Update Insights
### 🔥 Notable Updates
- Most significant updates of the period
- High-impact changes for developers
- Security-critical updates requiring immediate attention
### 📈 Trend Patterns
- Which types of updates are most common
- Package maintenance activity levels
- Ecosystem health indicators
### ⚠️ Breaking Changes Alert
- Major version updates with breaking changes
- Migration guides and resources
- Timeline recommendations for updates
### 🌟 Innovation Highlights
- New features and capabilities
- Emerging patterns and technologies
- Developer experience improvements
## 📋 Action Recommendations
### Immediate Actions
- Critical security updates to apply now
- High-priority bug fixes
- Compatibility updates needed
### Planned Updates
- Major version upgrades requiring testing
- Feature updates worth evaluating
- Performance improvements to consider
### Monitoring Setup
- Packages to watch for future updates
- Automated update strategies
- Dependency management improvements
Include specific version numbers, release notes highlights, and update commands."""
return template

View File

@ -8,14 +8,20 @@ from fastmcp import FastMCP
from .core.exceptions import InvalidPackageNameError, NetworkError, PackageNotFoundError
from .prompts import (
analyze_daily_trends,
analyze_environment_dependencies,
analyze_package_quality,
audit_security_risks,
check_outdated_packages,
compare_packages,
find_trending_packages,
generate_migration_checklist,
generate_update_plan,
plan_package_migration,
plan_version_upgrade,
resolve_dependency_conflicts,
suggest_alternatives,
track_package_updates,
)
from .tools import (
check_python_compatibility,
@ -715,6 +721,177 @@ async def generate_migration_checklist_prompt(
return messages[0].text
# Environment Analysis Prompts
@mcp.prompt()
async def analyze_environment_dependencies_prompt(
environment_type: str = "local",
python_version: str | None = None,
project_path: str | None = None
) -> str:
"""Generate a prompt for analyzing environment dependencies."""
# Step 3: Call Prompt generator
template = await analyze_environment_dependencies(environment_type, python_version, project_path)
# Step 5: Parameter replacement
result = template.replace("{{environment_type}}", environment_type)
# Handle environment info
env_info = f"({environment_type} environment)"
if python_version:
env_info += f" with Python {python_version}"
if project_path:
env_info += f" at {project_path}"
result = result.replace("{{environment_info}}", env_info)
# Handle command prefix based on environment
command_prefix = "uvx " if environment_type in ["virtual", "uv"] else ""
result = result.replace("{{command_prefix}}", command_prefix)
# Step 7: Return final prompt
return result
@mcp.prompt()
async def check_outdated_packages_prompt(
package_filter: str | None = None,
severity_level: str = "all",
include_dev_dependencies: bool = True
) -> str:
"""Generate a prompt for checking outdated packages."""
# Step 3: Call Prompt generator
template = await check_outdated_packages(package_filter, severity_level, include_dev_dependencies)
# Step 5: Parameter replacement
result = template.replace("{{severity_level}}", severity_level)
# Handle filter info
if package_filter:
filter_info = f" (filtering by: {package_filter})"
else:
filter_info = ""
result = result.replace("{{filter_info}}", filter_info)
# Handle dev dependencies
if include_dev_dependencies:
dev_deps_text = " including development dependencies"
else:
dev_deps_text = " excluding development dependencies"
result = result.replace("{{dev_deps_text}}", dev_deps_text)
# Step 7: Return final prompt
return result
@mcp.prompt()
async def generate_update_plan_prompt(
update_strategy: str = "balanced",
environment_constraints: str | None = None,
testing_requirements: str | None = None
) -> str:
"""Generate a prompt for creating package update plans."""
# Step 3: Call Prompt generator
template = await generate_update_plan(update_strategy, environment_constraints, testing_requirements)
# Step 5: Parameter replacement
result = template.replace("{{strategy}}", update_strategy)
# Handle constraints
if environment_constraints:
constraints_text = f"\n\nEnvironment constraints: {environment_constraints}"
else:
constraints_text = ""
result = result.replace("{{constraints_text}}", constraints_text)
# Handle testing requirements
if testing_requirements:
testing_text = f"\n\nTesting requirements: {testing_requirements}"
else:
testing_text = ""
result = result.replace("{{testing_text}}", testing_text)
# Step 7: Return final prompt
return result
# Trending Analysis Prompts
@mcp.prompt()
async def analyze_daily_trends_prompt(
date: str = "today",
category: str | None = None,
limit: int = 20
) -> str:
"""Generate a prompt for analyzing daily PyPI trends."""
# Step 3: Call Prompt generator
template = await analyze_daily_trends(date, category, limit)
# Step 5: Parameter replacement
result = template.replace("{{date}}", date)
result = result.replace("{{limit}}", str(limit))
# Handle category filter
if category:
category_filter = f" focusing on {category} packages"
else:
category_filter = ""
result = result.replace("{{category_filter}}", category_filter)
# Step 7: Return final prompt
return result
@mcp.prompt()
async def find_trending_packages_prompt(
time_period: str = "weekly",
trend_type: str = "rising",
domain: str | None = None
) -> str:
"""Generate a prompt for finding trending packages."""
# Step 3: Call Prompt generator
template = await find_trending_packages(time_period, trend_type, domain)
# Step 5: Parameter replacement
result = template.replace("{{time_period}}", time_period)
result = result.replace("{{trend_type}}", trend_type)
# Handle domain filter
if domain:
domain_filter = f" in the {domain} domain"
else:
domain_filter = ""
result = result.replace("{{domain_filter}}", domain_filter)
# Step 7: Return final prompt
return result
@mcp.prompt()
async def track_package_updates_prompt(
time_range: str = "today",
update_type: str = "all",
popular_only: bool = False
) -> str:
"""Generate a prompt for tracking recent package updates."""
# Step 3: Call Prompt generator
template = await track_package_updates(time_range, update_type, popular_only)
# Step 5: Parameter replacement
result = template.replace("{{time_range}}", time_range)
result = result.replace("{{update_type}}", update_type)
# Handle popularity filter
if popular_only:
popularity_filter = " (popular packages only)"
popularity_description = "Popular packages with >1M downloads"
else:
popularity_filter = ""
popularity_description = "All packages in the ecosystem"
result = result.replace("{{popularity_filter}}", popularity_filter)
result = result.replace("{{popularity_description}}", popularity_description)
# Step 7: Return final prompt
return result
@click.command()
@click.option(
"--log-level",