Skip to content

Conversation

vanman2024
Copy link
Owner

Summary

This PR fixes critical issues with the v0 MCP server and adds enhanced features for better UI component generation.

Fixes #3

Changes Made

🐛 Bug Fixes

  • Fixed code extraction saving entire AI responses with markdown artifacts
  • Improved regex patterns to properly extract code from markdown blocks
  • Fixed multi-file parsing to detect file="path" markers and create separate files
  • Enhanced file path handling for proper directory structure creation

✨ New Features

  • Added write_to_file parameter for direct file creation during generation
  • Implemented v0_update_file function for in-place file updates
  • Added v0_create_feature for complete feature generation with multiple components
  • Enhanced improve_component with file writing capability

🛡️ Error Handling & Validation

  • Added RateLimiter class (10 calls/minute default)
  • Input validation (empty prompts, max 10000 chars)
  • Tech stack validation with warnings for unknown values
  • Retry logic (3 attempts, 5-second delays)
  • Security validation for file paths (prevent directory traversal)
  • 60-second timeout for API calls

Testing

  • Multi-file generation with proper paths
  • Code extraction without artifacts
  • Rate limiting under load
  • File update functionality
  • Feature generation with multiple components

Example Usage

# Generate and write component directly
await generate_component(
    prompt="Create a user profile card",
    write_to_file=True,
    target_directory="components"
)

# Update existing file
await v0_update_file(
    file_path="components/UserCard.tsx",
    improvements="Add loading state and error handling"
)

# Create complete feature
await v0_create_feature(
    feature_description="User management system",
    components_needed=["UserList", "UserForm", "UserProfile"],
    api_endpoints=["user-crud", "user-auth"]
)

🤖 Generated with Claude Code

Co-Authored-By: Claude [email protected]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix v0 server code extraction and add enhanced features
1 participant