generate_prd
Create comprehensive Product Requirements Documents (PRDs) from project ideas using AI analysis and industry best practices for GitHub project management.
Instructions
Generate a comprehensive Product Requirements Document (PRD) from a project idea using AI analysis and industry best practices
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectIdea | Yes | ||
| projectName | Yes | ||
| targetUsers | No | ||
| timeline | No | ||
| complexity | Yes | ||
| author | Yes | ||
| stakeholders | No | ||
| includeResearch | Yes | ||
| industryContext | No |
Input Schema (JSON Schema)
{
"properties": {
"author": {
"type": "string"
},
"complexity": {
"type": "string"
},
"includeResearch": {
"type": "string"
},
"industryContext": {
"type": "string"
},
"projectIdea": {
"type": "string"
},
"projectName": {
"type": "string"
},
"stakeholders": {
"items": {
"type": "string"
},
"type": "array"
},
"targetUsers": {
"items": {
"type": "string"
},
"type": "array"
},
"timeline": {
"type": "string"
}
},
"required": [
"projectIdea",
"projectName",
"complexity",
"author",
"includeResearch"
],
"type": "object"
}
Implementation Reference
- Main handler function executeGeneratePRD that orchestrates PRD generation using PRDGenerationService, validates completeness, formats response, and handles AI errors gracefully.async function executeGeneratePRD(args: GeneratePRDArgs): Promise<MCPResponse> { const prdService = new PRDGenerationService(); try { // Generate comprehensive PRD from project idea const prd = await prdService.generatePRDFromIdea({ projectIdea: args.projectIdea, projectName: args.projectName, targetUsers: args.targetUsers, timeline: args.timeline, complexity: args.complexity, author: args.author, stakeholders: args.stakeholders }); // Validate PRD completeness const validation = await prdService.validatePRDCompleteness(prd); // Format response const summary = formatPRDGenerationSummary(prd, validation); return ToolResultFormatter.formatSuccess('generate_prd', { summary, prd, validation, completenessScore: validation.score, isComplete: validation.isComplete }); } catch (error) { process.stderr.write(`Error in generate_prd tool: ${error}\n`); // Check if this is an AI availability error const errorMessage = error instanceof Error ? error.message : 'Unknown error'; const isAIUnavailable = errorMessage.includes('AI service is not available') || errorMessage.includes('API key') || errorMessage.includes('provider'); if (isAIUnavailable) { const aiErrorSummary = formatAIUnavailableMessage('generate_prd', errorMessage); return ToolResultFormatter.formatSuccess('generate_prd', { content: [{ type: 'text', text: aiErrorSummary }], success: false, aiAvailable: false }); } return ToolResultFormatter.formatSuccess('generate_prd', { content: [{ type: 'text', text: `# Failed to generate PRD\n\n**Error:** ${errorMessage}\n\nPlease check your input parameters and try again.` }], success: false }); } }
- Tool definition generatePRDTool including input schema (generatePRDSchema), description, and usage examples for MCP tool registration.export const generatePRDTool: ToolDefinition<GeneratePRDArgs> = { name: "generate_prd", description: "Generate a comprehensive Product Requirements Document (PRD) from a project idea using AI analysis and industry best practices", schema: generatePRDSchema as unknown as ToolSchema<GeneratePRDArgs>, examples: [ { name: "Generate PRD for task management app", description: "Create a comprehensive PRD for a new task management application", args: { projectIdea: "A modern task management application with AI-powered prioritization, team collaboration features, and integration with popular development tools like GitHub and Slack", projectName: "TaskFlow AI", targetUsers: ["software developers", "project managers", "small teams"], timeline: "6 months", complexity: "medium", author: "product-team", stakeholders: ["engineering", "design", "marketing"], includeResearch: true, industryContext: "productivity software" } } ] }; // Export the execution function for the tool registry export { executeGeneratePRD };
- src/infrastructure/tools/ToolRegistry.ts:191-199 (registration)Registration of generatePRDTool in the central ToolRegistry singleton during initialization of built-in tools.// Register AI task management tools this.registerTool(addFeatureTool); this.registerTool(generatePRDTool); this.registerTool(parsePRDTool); this.registerTool(getNextTaskTool); this.registerTool(analyzeTaskComplexityTool); this.registerTool(expandTaskTool); this.registerTool(enhancePRDTool); this.registerTool(createTraceabilityMatrixTool);
- src/index.ts:362-363 (registration)Dispatcher in main server index.ts that routes call_tool requests for 'generate_prd' directly to executeGeneratePRD.case "generate_prd": return await executeGeneratePRD(args);
- Core helper service method generatePRDFromIdea that performs AI-powered PRD generation and validation, called by the tool handler.async generatePRDFromIdea(params: { projectIdea: string; projectName: string; targetUsers?: string[]; timeline?: string; complexity?: 'low' | 'medium' | 'high'; author: string; stakeholders?: string[]; }): Promise<PRDDocument> { try { // Validate input if (!params.projectIdea.trim()) { throw new Error('Project idea is required'); } if (!params.projectName.trim()) { throw new Error('Project name is required'); } // Generate PRD using AI const generatedPRD = await this.aiProcessor.generatePRDFromIdea({ projectIdea: params.projectIdea, targetUsers: params.targetUsers?.join(', '), timeline: params.timeline, complexity: params.complexity }); // Enhance with provided metadata const enhancedPRD: PRDDocument = { ...generatedPRD, title: params.projectName, author: params.author, stakeholders: params.stakeholders || [], version: '1.0.0' }; // Validate the generated PRD const validatedPRD = PRDDocumentSchema.parse(enhancedPRD); return validatedPRD; } catch (error) { process.stderr.write(`Error generating PRD from idea: ${error instanceof Error ? error.message : String(error)}\n`); throw new Error(`Failed to generate PRD: ${error instanceof Error ? error.message : 'Unknown error'}`); } }