Skip to main content
Glama
crazyrabbitLTC

Vibe-Coder MCP Server

generate_prd

Create product requirement documents for software features by providing a feature ID to define specifications and development guidelines.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
featureIdYes

Implementation Reference

  • The main handler function for the 'generate_prd' tool. Validates featureId, checks if clarifications are complete, calls generatePRD helper, stores the PRD in the feature, and returns a success message with resource URI.
    const generatePrdHandler: ToolHandler<z.infer<typeof GeneratePrdSchema>> = async (params) => {
      try {
        const { featureId } = GeneratePrdSchema.parse(params);
        
        // Validate feature ID
        const featureResult = validateFeatureId(featureId);
        if (!featureResult.valid) {
          return createToolErrorResponse(featureResult.message);
        }
        
        const feature = featureResult.data;
        
        // Check if clarifications are complete
        if (!isClarificationComplete(feature)) {
          return clarificationIncompleteError(getClarificationStatus(feature));
        }
        
        // Generate PRD
        const prdDoc = generatePRD(feature);
        
        // Store the document
        feature.prdDoc = prdDoc;
        updateFeature(featureId, feature);
        
        return {
          content: [{
            type: "text",
            text: `PRD generated for feature ${feature.name}. You can view it using the resource URI: feature://${feature.id}/prd`
          }]
        };
      } catch (error) {
        if (error instanceof z.ZodError) {
          const errorMessage = error.errors.map(e => `${e.path.join('.')}: ${e.message}`).join(', ');
          return createToolErrorResponse(`Validation error: ${errorMessage}`);
        }
        return createToolErrorResponse(error instanceof Error ? error.message : "Unknown error");
      }
    };
  • Zod schema defining the input for generate_prd tool: requires a featureId string.
    const GeneratePrdSchema = z.object({
      featureId: z.string().min(1)
    });
  • Registers the generate_prd tool with the toolRegistry, providing the handler, description, JSON schema for inputs, and example parameters.
      'generate_prd', 
      generatePrdHandler,
      'Generate a PRD document based on clarification responses',
      {
        type: "object",
        properties: {
          featureId: {
            type: "string",
            description: "ID of the feature"
          }
        },
        required: ["featureId"]
      },
      [
        { featureId: "feature-123" }
      ]
    );
  • Helper function that generates the full PRD markdown document from the feature's clarification responses, extracts objectives/requirements/specs, formats into sections, and stores it via documentStorage.
    export function generatePRD(feature: Feature): string {
      const { name, description, clarificationResponses } = feature;
      
      // Find specific clarification responses
      const problemResponse = clarificationResponses.find(r => 
        r.question.toLowerCase().includes('what specific problem') ||
        r.question.toLowerCase().includes('what problem')
      );
      
      const usersResponse = clarificationResponses.find(r => 
        r.question.toLowerCase().includes('target users')
      );
      
      const requirementsResponse = clarificationResponses.find(r => 
        r.question.toLowerCase().includes('key requirements')
      );
      
      const technicalResponse = clarificationResponses.find(r => 
        r.question.toLowerCase().includes('technical constraints') ||
        r.question.toLowerCase().includes('technical considerations')
      );
      
      const metricsResponse = clarificationResponses.find(r => 
        r.question.toLowerCase().includes('measure') && 
        r.question.toLowerCase().includes('success')
      );
      
      const dependenciesResponse = clarificationResponses.find(r => 
        r.question.toLowerCase().includes('dependencies')
      );
      
      const risksResponse = clarificationResponses.find(r => 
        r.question.toLowerCase().includes('risks') ||
        r.question.toLowerCase().includes('challenges')
      );
      
      // Extract structured information
      const objectives = extractObjectivesFromClarifications(clarificationResponses);
      const requirements = extractRequirementsFromClarifications(clarificationResponses);
      const technicalSpecs = extractTechnicalSpecsFromClarifications(clarificationResponses);
      
      // Format the PRD
      const prd = `# ${name} - Product Requirements Document
    
    ## 1. Introduction
    
    ### 1.1 Purpose
    ${problemResponse ? problemResponse.answer : description}
    
    ### 1.2 Scope
    This document outlines the requirements and specifications for the ${name} feature.
    
    ### 1.3 Background
    ${description}
    
    ## 2. Product Overview
    
    ### 2.1 Product Description
    ${description}
    
    ### 2.2 Target Users
    ${usersResponse ? usersResponse.answer : 'To be determined during development.'}
    
    ## 3. Functional Requirements
    
    ${requirements.map((req, index) => `### 3.${index + 1} ${req}`).join('\n\n')}
    
    ## 4. Non-Functional Requirements
    
    ### 4.1 Technical Constraints
    ${technicalResponse ? technicalResponse.answer : 'No specific technical constraints identified.'}
    
    ### 4.2 Performance Requirements
    ${technicalSpecs.filter(spec => 
      spec.toLowerCase().includes('performance') || 
      spec.toLowerCase().includes('speed') ||
      spec.toLowerCase().includes('time') ||
      spec.toLowerCase().includes('fast')
    ).map(spec => `- ${spec}`).join('\n') || 'No specific performance requirements identified.'}
    
    ## 5. Success Metrics
    
    ### 5.1 Key Performance Indicators
    ${metricsResponse ? metricsResponse.answer : 'Success metrics to be determined.'}
    
    ## 6. Dependencies
    
    ### 6.1 System Dependencies
    ${dependenciesResponse ? dependenciesResponse.answer : 'No specific dependencies identified.'}
    
    ## 7. Risks and Challenges
    
    ### 7.1 Identified Risks
    ${risksResponse ? risksResponse.answer : 'Risks to be assessed during development.'}
    
    ## 8. Milestones and Implementation Plan
    
    Refer to the Implementation Plan document for detailed phases and tasks.
    
    ---
    
    Generated on: ${formatDate(new Date())}
    `;
    
      // Store the generated PRD in the document storage system
      documentStorage.storeDocument(feature.id, DocumentType.PRD, prd)
        .catch(error => console.error(`Failed to store PRD document: ${error}`));
      
      return prd;
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/crazyrabbitLTC/mcp-vibecoder'

If you have feedback or need assistance with the MCP directory API, please join our Discord server