### Quick Start: Run PRD Creator MCP Server via NPX Source: https://github.com/saml1211/prd-mcp-server/blob/main/README.md Quickly run the PRD Creator MCP server using npx without a global installation. This command downloads and executes the package directly, providing a fast way to get started. ```sh npx -y prd-creator-mcp ``` -------------------------------- ### Development Setup and Build Commands for MCP Server Source: https://github.com/saml1211/prd-mcp-server/blob/main/memory-bank/techContext.md Essential command-line instructions for setting up the PRD Creator MCP Server development environment, including cloning the repository, installing dependencies, building the project, running the server, and executing tests. ```Shell git clone ``` ```Shell npm install ``` ```Shell npm run build ``` ```Shell npm start ``` ```Shell npx @modelcontextprotocol/inspector node dist/index.js ``` ```Shell npm test ``` -------------------------------- ### Install Dependencies and Run Tests Source: https://github.com/saml1211/prd-mcp-server/blob/main/CONTRIBUTING.md Commands to install all necessary project dependencies using npm and then execute the test suite to ensure the current setup is functional and no regressions are introduced. ```bash npm install npm test ``` -------------------------------- ### Installation: Run PRD Creator MCP Server Locally Source: https://github.com/saml1211/prd-mcp-server/blob/main/README.md Start the PRD Creator MCP server locally after it has been built. This command launches the application, making it accessible for testing or direct use on your machine. ```bash npm start ``` -------------------------------- ### Quick Start: Display PRD Creator MCP CLI Help Source: https://github.com/saml1211/prd-mcp-server/blob/main/README.md Access the command-line interface help documentation for the PRD Creator MCP server. This provides an overview of available commands, options, and usage instructions. ```sh npx prd-creator-mcp --help ``` -------------------------------- ### Installation: Build PRD Creator MCP Server Project Source: https://github.com/saml1211/prd-mcp-server/blob/main/README.md Compile and build the PRD Creator MCP server project for production. This step processes source files into a deployable format, preparing the application for execution. ```bash npm run build ``` -------------------------------- ### Node.js Project Initialization and Dependency Installation Source: https://github.com/saml1211/prd-mcp-server/blob/main/prd-creator-implementation-plan.md Commands to set up a new Node.js project for the PRD Creator MCP Server. This includes initializing npm, configuring TypeScript, and installing core dependencies like @modelcontextprotocol/sdk, zod, winston, sqlite3, better-sqlite3, along with development dependencies such as jest, ts-jest, eslint, and prettier. ```bash # Create project directory mkdir prd-creator-mcp cd prd-creator-mcp # Initialize Node.js project with TypeScript npm init -y npm install typescript @types/node ts-node tsconfig-paths --save-dev npx tsc --init # Install core dependencies npm install @modelcontextprotocol/sdk zod winston sqlite3 better-sqlite3 # Development dependencies npm install jest ts-jest @types/jest eslint prettier --save-dev ``` -------------------------------- ### Implement PRD Creator Server with MCP SDK in TypeScript Source: https://github.com/saml1211/prd-mcp-server/blob/main/PRD.md This TypeScript example illustrates the foundational structure of a PRD (Product Requirements Document) Creator server built with the Model Context Protocol (MCP) SDK. It defines three key tools: `generate_prd` for creating PRDs from structured inputs, `validate_prd` for verifying PRD content against rules, and `extract_requirements` for parsing requirements from source text. It also establishes a `prd-templates` resource for dynamic template retrieval and demonstrates connecting the server via standard I/O transport, providing a complete, runnable server setup. ```typescript import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'; import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'; import { z } from 'zod'; import { generatePRD, validatePRD, extractRequirements } from './prd-utils.js'; // Create MCP server instance const server = new McpServer({ name: 'PRD Creator', version: '1.0.0', }); // Define PRD Generator tool server.tool( 'generate_prd', { productDescription: z.string(), targetAudience: z.string(), coreFeatures: z.array(z.string()), constraints: z.array(z.string()).optional(), templateName: z.string().optional(), }, async ({ productDescription, targetAudience, coreFeatures, constraints, templateName }) => { try { const prd = await generatePRD(productDescription, targetAudience, coreFeatures, constraints, templateName); return { content: [{ type: 'text', text: prd }], }; } catch (error) { return { content: [{ type: 'text', text: `Error generating PRD: ${error.message}` }], isError: true, }; } } ); // Define PRD Validator tool server.tool( 'validate_prd', { prdContent: z.string(), validationRules: z.array(z.string()).optional(), }, async ({ prdContent, validationRules }) => { try { const validationResults = await validatePRD(prdContent, validationRules); return { content: [{ type: 'text', text: JSON.stringify(validationResults, null, 2) }], }; } catch (error) { return { content: [{ type: 'text', text: `Error validating PRD: ${error.message}` }], isError: true, }; } } ); // Define Requirements Extractor tool server.tool( 'extract_requirements', { sourceText: z.string(), categoryFilter: z.string().optional(), }, async ({ sourceText, categoryFilter }) => { try { const requirements = await extractRequirements(sourceText, categoryFilter); return { content: [{ type: 'text', text: JSON.stringify(requirements, null, 2) }], }; } catch (error) { return { content: [{ type: 'text', text: `Error extracting requirements: ${error.message}` }], isError: true, }; } } ); // Define PRD Templates resource server.resource( 'prd-templates', new ResourceTemplate('prd://templates/{templateName}'), async (uri) => { const templateName = uri.pathname.split('/').pop(); try { const template = await getTemplate(templateName); return { contents: [{ uri: uri.href, text: template }], }; } catch (error) { return { contents: [], isError: true, error: `Template not found: ${templateName}`, }; } } ); // Start the server with stdio transport const transport = new StdioServerTransport(); await server.connect(transport); ``` -------------------------------- ### Example Response for Listing AI Providers Source: https://github.com/saml1211/prd-mcp-server/blob/main/README.md Demonstrates the JSON structure returned when listing all available AI providers and their availability status. ```json [ { "id": "openai", "name": "OpenAI", "available": true }, { "id": "anthropic", "name": "Anthropic Claude", "available": false }, { "id": "gemini", "name": "Google Gemini", "available": false }, { "id": "local", "name": "Local Model", "available": false }, { "id": "template", "name": "Template-based (No AI)", "available": true } ] ``` -------------------------------- ### Installation: Clone PRD Creator MCP Server Repository Source: https://github.com/saml1211/prd-mcp-server/blob/main/README.md Clone the PRD Creator MCP server's source code repository from GitHub. This command downloads all project files, allowing for local development or installation from source. ```bash git clone https://github.com/Saml1211/prd-mcp-server.git cd prd-mcp-server ``` -------------------------------- ### Installation: Install PRD Creator MCP Server Dependencies Source: https://github.com/saml1211/prd-mcp-server/blob/main/README.md Install all required Node.js package dependencies for the PRD Creator MCP server. This command uses npm to fetch and set up the necessary libraries for the project to run. ```bash npm install ``` -------------------------------- ### Install PRD-MCP-Server CLI Globally Source: https://github.com/saml1211/prd-mcp-server/blob/main/README.md Command to install the PRD-MCP-Server globally via npm, making its CLI available system-wide. ```bash npm install -g prd-creator-mcp ``` -------------------------------- ### Run PRD-MCP-Server CLI Globally Source: https://github.com/saml1211/prd-mcp-server/blob/main/README.md Command to execute the globally installed PRD-MCP-Server CLI. ```bash prd-creator-mcp ``` -------------------------------- ### Installation: Run PRD Creator MCP Server in Development Mode Source: https://github.com/saml1211/prd-mcp-server/blob/main/README.md Launch the PRD Creator MCP server in development mode with hot reload capabilities. This is ideal for active development, as changes to the source code will automatically trigger a reload. ```bash npm run dev ``` -------------------------------- ### Quick Start: Pull PRD Creator MCP Docker Image Source: https://github.com/saml1211/prd-mcp-server/blob/main/README.md Download the official Docker image for the PRD Creator MCP server. This command fetches the latest version from Docker Hub, preparing it for containerized execution. ```sh docker pull saml1211/prd-creator-mcp ``` -------------------------------- ### Quick Start: Run PRD Creator MCP Server in Docker Source: https://github.com/saml1211/prd-mcp-server/blob/main/README.md Execute the PRD Creator MCP server within a Docker container. The -i flag keeps stdin open for interactive use, and --rm ensures the container is removed automatically upon exit. ```sh docker run -i --rm saml1211/prd-creator-mcp ``` -------------------------------- ### Uninstall PRD-MCP-Server Global CLI Source: https://github.com/saml1211/prd-mcp-server/blob/main/README.md Command to remove the globally installed PRD-MCP-Server CLI from the system. ```bash npm uninstall -g prd-creator-mcp ``` -------------------------------- ### Unit Testing PRD Generator with Jest Mocks in TypeScript Source: https://github.com/saml1211/prd-mcp-server/blob/main/prd-creator-implementation-plan.md This TypeScript Jest test suite provides an example of unit testing the `generatePRD` function. It effectively uses `jest.mock` to isolate the `getTemplate` dependency, allowing the test to control the template content returned and verify the PRD generation logic and placeholder replacement independently. ```typescript // tests/tools/prd-generator.test.ts import { generatePRD } from '../../src/tools/prd-generator'; import { getTemplate } from '../../src/storage/templates'; // Mock the template storage jest.mock('../../src/storage/templates', () => ({ getTemplate: jest.fn(), })); describe('PRD Generator', () => { beforeEach(() => { jest.clearAllMocks(); }); test('should generate PRD with template replacement', async () => { // Mock the template (getTemplate as jest.Mock).mockResolvedValue({ content: '# {{PRODUCT_NAME}}\n\n{{PRODUCT_DESCRIPTION}}\n\n## Features\n\n{{CORE_FEATURES}}\n\n## Constraints\n\n{{CONSTRAINTS}}', }); const result = await generatePRD( 'A new product', 'Software developers', ['Feature 1', 'Feature 2'], ['Constraint 1'] ); expect(result).toContain('A new product'); expect(result).toContain('- Feature 1'); expect(result).toContain('- Feature 2'); expect(result).toContain('- Constraint 1'); }); }); ``` -------------------------------- ### Standard Product Requirements Document (PRD) Markdown Template Source: https://github.com/saml1211/prd-mcp-server/blob/main/prd-creator-implementation-plan.md This Markdown template provides a structured format for Product Requirements Documents (PRDs). It includes sections for product overview, target audience, core features, constraints, user stories, acceptance criteria, and timeline, utilizing placeholders (e.g., `{{PRODUCT_NAME}}`) for dynamic content generation. ```markdown # {{PRODUCT_NAME}} - Product Requirements Document ## Introduction ### Product Overview {{PRODUCT_DESCRIPTION}} ### Target Audience {{TARGET_AUDIENCE}} ## Core Features {{CORE_FEATURES}} ## Constraints and Limitations {{CONSTRAINTS}} ## User Stories *To be added by the product team* ## Acceptance Criteria *To be added for each feature* ## Timeline *To be determined* --- Generated on {{DATE}} ``` -------------------------------- ### PRD Creator MCP Server MVP Implementation Timeline Gantt Chart Source: https://github.com/saml1211/prd-mcp-server/blob/main/prd-creator-implementation-plan.md Illustrates the proposed 6-8 week implementation timeline for the Minimum Viable Product (MVP) of the PRD Creator MCP Server, broken down into five phases with specific tasks and durations. ```mermaid gantt title PRD Creator MCP Server - MVP Implementation dateFormat YYYY-MM-DD section Phase 1 Project Setup :a1, 2023-06-01, 3d Core MCP Implementation :a2, after a1, 7d section Phase 2 Database Setup :b1, after a2, 5d Template Storage :b2, after b1, 5d section Phase 3 PRD Generator Tool :c1, after b2, 7d PRD Validator Tool :c2, after c1, 7d section Phase 4 Template Resources :d1, after c2, 5d section Phase 5 Default Templates :e1, after d1, 3d Integration Testing :e2, after e1, 5d Documentation :e3, after e2, 3d ``` -------------------------------- ### Initialize and Run MCP Server with STDIO Transport Source: https://github.com/saml1211/prd-mcp-server/blob/main/prd-creator-implementation-plan.md This TypeScript snippet demonstrates how to set up and run a Model Context Protocol (MCP) server. It initializes logging, sets up storage, registers custom tools and resources, configures error handling, and connects the server using a standard I/O (STDIO) transport. The server is named 'PRD Creator' and runs asynchronously. ```typescript // src/index.ts import { McpServer } from '@modelcontextprotocol/sdk/server'; import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio'; import { configureLogging } from './config/logging'; import { registerTools } from './tools'; import { registerResources } from './resources'; import { initializeStorage } from './storage'; async function main() { // Configure logging const logger = configureLogging(); // Initialize storage await initializeStorage(); // Create MCP server const server = new McpServer({ name: 'PRD Creator', version: '0.1.0', }); // Register tools and resources registerTools(server); registerResources(server); // Handle errors server.onError = (error) => { logger.error('Server error:', error); }; // Connect using STDIO transport const transport = new StdioServerTransport(); logger.info('Starting PRD Creator MCP Server...'); await server.connect(transport); logger.info('PRD Creator MCP Server running with STDIO transport'); } main().catch((error) => { console.error('Fatal error:', error); process.exit(1); }); ``` -------------------------------- ### MCP Server Application Initialization and Module Registration in TypeScript Source: https://github.com/saml1211/prd-mcp-server/blob/main/prd-creator-implementation-plan.md This TypeScript code demonstrates the modular initialization pattern for an MCP server application. It defines entry points for registering various tools (like PRD generators and validators), registering resource handlers (like templates), and initializing persistent storage components (database and default templates), ensuring a structured application startup. ```typescript // src/tools/index.ts import { McpServer } from '@modelcontextprotocol/sdk/server'; import { registerPrdGeneratorTool } from './prd-generator'; import { registerPrdValidatorTool } from './prd-validator'; export function registerTools(server: McpServer) { registerPrdGeneratorTool(server); registerPrdValidatorTool(server); } ``` ```typescript // src/resources/index.ts import { McpServer } from '@modelcontextprotocol/sdk/server'; import { registerTemplateResources } from './templates'; export function registerResources(server: McpServer) { registerTemplateResources(server); } ``` ```typescript // src/storage/index.ts import { initializeDatabase } from './db'; import { initializeDefaultTemplates } from './templates'; export async function initializeStorage() { await initializeDatabase(); await initializeDefaultTemplates(); } ``` -------------------------------- ### Clone PRD Creator MCP Server Repository Source: https://github.com/saml1211/prd-mcp-server/blob/main/CONTRIBUTING.md Instructions to clone your forked PRD Creator MCP Server repository locally from GitHub and navigate into its directory to begin development. ```bash git clone https://github.com/Saml1211/prd-mcp-server.git cd prd-mcp-server ``` -------------------------------- ### Recommended Project Directory Structure for PRD Creator MCP Server Source: https://github.com/saml1211/prd-mcp-server/blob/main/prd-creator-implementation-plan.md The proposed directory structure for the PRD Creator MCP Server project, organizing source code into logical modules for configuration, core MCP implementation, storage, tools, resources, utilities, and templates, alongside test files and project configuration. ```plaintext prd-creator-mcp/ ├── src/ │ ├── config/ # Configuration management │ ├── core/ # Core MCP implementation │ ├── storage/ # Database and caching │ ├── tools/ # Tool implementations │ ├── resources/ # Resource implementations │ ├── utils/ # Utility functions │ ├── templates/ # Initial PRD templates │ └── index.ts # Main entry point ├── tests/ # Test files ├── tsconfig.json # TypeScript configuration ├── package.json # Project metadata └── README.md # Documentation ``` -------------------------------- ### View PRD-MCP-Server CLI Options Source: https://github.com/saml1211/prd-mcp-server/blob/main/README.md Command to display all available command-line options for the PRD-MCP-Server CLI. ```bash npx prd-creator-mcp --help ``` -------------------------------- ### Initialize SQLite Database and Define Schema for Templates Source: https://github.com/saml1211/prd-mcp-server/blob/main/prd-creator-implementation-plan.md This TypeScript code initializes a SQLite database using `better-sqlite3`. It ensures the data directory exists, opens or creates the `prd-creator.db` file, and defines two tables: `templates` and `template_versions`. It includes primary keys, foreign key constraints, and indexes for efficient data retrieval. A `getDatabase` function is provided to access the initialized database instance. ```typescript // src/storage/db.ts import BetterSqlite3 from 'better-sqlite3'; import { join } from 'path'; import { logger } from '../config/logging'; let db: BetterSqlite3.Database; export async function initializeDatabase() { const dbPath = join(process.cwd(), 'data', 'prd-creator.db'); logger.info(`Initializing SQLite database at ${dbPath}`); // Ensure data directory exists const fs = await import('fs/promises'); await fs.mkdir(join(process.cwd(), 'data'), { recursive: true }); // Create/open database db = new BetterSqlite3(dbPath); // Create tables if they don't exist db.exec(` CREATE TABLE IF NOT EXISTS templates ( id TEXT PRIMARY KEY, name TEXT NOT NULL, description TEXT, content TEXT NOT NULL, tags TEXT, version INTEGER NOT NULL DEFAULT 1, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ); CREATE TABLE IF NOT EXISTS template_versions ( id TEXT PRIMARY KEY, template_id TEXT NOT NULL, version INTEGER NOT NULL, content TEXT NOT NULL, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY (template_id) REFERENCES templates(id) ); -- Add indexes CREATE INDEX IF NOT EXISTS idx_templates_name ON templates(name); CREATE INDEX IF NOT EXISTS idx_template_versions_template_id ON template_versions(template_id); `); return db; } export function getDatabase(): BetterSqlite3.Database { if (!db) { throw new Error('Database not initialized. Call initializeDatabase() first.'); } return db; } ``` -------------------------------- ### Build PRD-MCP-Server Docker Image Source: https://github.com/saml1211/prd-mcp-server/blob/main/README.md Command to build the Docker image for the PRD-MCP-Server, tagging it as `prd-creator-mcp`. ```bash docker build -t prd-creator-mcp . ``` -------------------------------- ### Initialize Default Templates from Files in TypeScript Source: https://github.com/saml1211/prd-mcp-server/blob/main/prd-creator-implementation-plan.md Provides the `initializeDefaultTemplates` function to populate the database with predefined templates from a specified directory (`src/templates`). It checks for existing templates to prevent re-initialization and asynchronously reads markdown files to save them as default templates with a 'default' tag. ```typescript export async function initializeDefaultTemplates() { logger.info('Initializing default templates'); // Check if we already have templates const db = getDatabase(); const count = db.prepare('SELECT COUNT(*) as count FROM templates').get().count; if (count > 0) { logger.info(`Found ${count} existing templates, skipping initialization`); return; } // Add default templates const fs = await import('fs/promises'); const path = await import('path'); const templatesDir = path.join(process.cwd(), 'src', 'templates'); const files = await fs.readdir(templatesDir); for (const file of files) { if (file.endsWith('.md')) { const content = await fs.readFile(path.join(templatesDir, file), 'utf-8'); const name = file.replace('.md', ''); await saveTemplate({ name, description: `Default template: ${name}`, content, tags: ['default'] }); logger.info(`Added default template: ${name}`); } } } ``` -------------------------------- ### API Reference: `generate_prd` Tool for PRD Creation Source: https://github.com/saml1211/prd-mcp-server/blob/main/README.md Generate a complete Product Requirements Document using AI or a specified template. This tool accepts detailed product information, optional constraints, and AI provider configurations to produce a structured PRD. ```APIDOC generate_prd: productName: The name of the product productDescription: Description of the product targetAudience: Description of the target audience coreFeatures: Array of core feature descriptions constraints (optional): Array of constraints or limitations templateName (optional): Template name to use (defaults to "standard") providerId (optional): Specific AI provider to use (openai, anthropic, gemini, local, template) additionalContext (optional): Additional context or instructions for the AI provider providerOptions (optional): Provider-specific options like temperature, maxTokens, etc. ``` ```javascript { "productName": "TaskMaster Pro", "productDescription": "A task management application that helps users organize and prioritize their work efficiently.", "targetAudience": "Busy professionals and teams who need to manage multiple projects and deadlines.", "coreFeatures": [ "Task creation and management", "Priority setting", "Due date tracking", "Team collaboration" ], "constraints": [ "Must work offline", "Must support mobile and desktop platforms" ], "templateName": "comprehensive", "providerId": "openai", "additionalContext": "Focus on enterprise features and security", "providerOptions": { "temperature": 0.5, "maxTokens": 4000 } } ``` -------------------------------- ### Configure PRD-MCP-Server for Claude Desktop Source: https://github.com/saml1211/prd-mcp-server/blob/main/README.md JSON configuration snippet to add the PRD-MCP-Server to Claude Desktop's `mcpServers` settings, allowing it to be used as a PRD creator. ```json { "mcpServers": { "prd-creator": { "command": "npx", "args": ["-y", "prd-creator-mcp"] } } } ``` -------------------------------- ### Format and Lint Code for Consistency Source: https://github.com/saml1211/prd-mcp-server/blob/main/CONTRIBUTING.md Commands to automatically format and lint the code, ensuring it adheres to the project's established style guidelines and maintaining code quality. ```bash npm run lint npm run format ``` -------------------------------- ### MVP Architecture Diagram for PRD Creator MCP Server Source: https://github.com/saml1211/prd-mcp-server/blob/main/prd-creator-implementation-plan.md A visual representation of the PRD Creator MCP Server's architecture, distinguishing between the MVP scope and future expansion components. It illustrates the flow between client, transport, core protocol, tools, resources, storage, and the SQLite database. ```mermaid graph TD Client[MCP Client] <-->|MCP Protocol| Transport[Transport Layer] Transport -->|STDIO| LocalTransport[STDIO Transport] Transport <--> Core[Core Protocol Layer] Core <--> ToolsLayer[Tools Layer] Core <--> ResourcesLayer[Resources Layer] ToolsLayer --> PRDGenerator[PRD Generator] ToolsLayer --> Validator[PRD Validator] ResourcesLayer --> Templates[PRD Templates] ToolsLayer <--> Storage[Storage Layer] ResourcesLayer <--> Storage Storage <--> Database[(SQLite DB)] subgraph "MVP Scope" LocalTransport Core ToolsLayer ResourcesLayer PRDGenerator Validator Templates Storage Database end subgraph "Future Expansion" SSETransport[SSE Transport] ReqExtractor[Requirements Extractor] StoryGen[User Story Generator] CompAnalysis[Competitive Analysis] Components[Component Library] Guides[Best Practices] Examples[Examples Repository] Security[Security Layer] Integration[Integration Layer] end Transport -.->|Future| SSETransport ToolsLayer -.-> ReqExtractor ToolsLayer -.-> StoryGen ToolsLayer -.-> CompAnalysis ResourcesLayer -.-> Components ResourcesLayer -.-> Guides ResourcesLayer -.-> Examples Core -.-> Security Core -.-> Integration ``` -------------------------------- ### API Documentation for `validate_prd` Server Tool Source: https://github.com/saml1211/prd-mcp-server/blob/main/prd-creator-implementation-plan.md This section documents the `validate_prd` tool, which is registered with the `McpServer` to perform PRD validation. It specifies the expected input parameters and the structure of the validation results returned by the tool. ```APIDOC Tool Name: validate_prd Description: Validates Product Requirement Document (PRD) content against predefined rules. Input Schema (validatePrdSchema): prdContent: string (required) - The full content of the PRD to be validated. Must not be empty. validationRules: string[] (optional) - An array of rule IDs to apply. If empty or not provided, all default rules are used. Output: content: [{ type: 'text', text: JSON.stringify(validation, null, 2) }] validation: object results: array of ValidationResult rule: string - Name of the validation rule. passed: boolean - True if the rule passed, false otherwise. message: string - A message indicating the result of the validation. details?: string - Optional additional details about the validation. summary: object total: number - Total number of rules applied. passed: number - Number of rules that passed. failed: number - Number of rules that failed. score: number - Percentage of rules that passed (0-100). isError: boolean (optional) - True if an error occurred during validation. ``` -------------------------------- ### List All Templates (Metadata Only) in TypeScript Source: https://github.com/saml1211/prd-mcp-server/blob/main/prd-creator-implementation-plan.md Defines the `listTemplates` function to retrieve a list of all templates from the database, excluding their full content for efficiency. It orders results by name, parses tags, and formats timestamps for the returned objects. ```typescript export async function listTemplates(): Promise[]> { const db = getDatabase(); const templates = db.prepare(` SELECT id, name, description, tags, version, created_at, updated_at FROM templates ORDER BY name `).all(); return templates.map(t => ({ id: t.id, name: t.name, description: t.description, tags: t.tags ? JSON.parse(t.tags) : [], version: t.version, createdAt: new Date(t.created_at), updatedAt: new Date(t.updated_at) })); } ``` -------------------------------- ### TypeScript PRD Generator Tool Core Logic and Registration Source: https://github.com/saml1211/prd-mcp-server/blob/main/prd-creator-implementation-plan.md This TypeScript code defines the `generatePrdSchema` for input validation, the `generatePRD` asynchronous function for creating Product Requirements Documents by replacing placeholders in a template, and the `registerPrdGeneratorTool` function. The `registerPrdGeneratorTool` integrates the PRD generation functionality as a callable tool within the `McpServer` framework, handling both successful generation and error scenarios. ```typescript // src/tools/prd-generator.ts import { z } from 'zod'; import { McpServer } from '@modelcontextprotocol/sdk/server'; import { logger } from '../config/logging'; import { getTemplate } from '../storage/templates'; // Input schema export const generatePrdSchema = z.object({ productDescription: z.string().min(1, "Product description is required"), targetAudience: z.string().min(1, "Target audience is required"), coreFeatures: z.array(z.string()).min(1, "At least one core feature is required"), constraints: z.array(z.string()).optional(), templateName: z.string().optional() }); // Utility function for PRD generation async function generatePRD( productDescription: string, targetAudience: string, coreFeatures: string[], constraints?: string[], templateName: string = 'standard' ): Promise { logger.info(`Generating PRD using template: ${templateName}`); // Get the template const template = await getTemplate(templateName); // Simple template variable replacement let content = template.content; content = content.replace(/\{\{PRODUCT_DESCRIPTION\}\} /g, productDescription); content = content.replace(/\{\{TARGET_AUDIENCE\}\} /g, targetAudience); // Replace features list const featuresContent = coreFeatures.map(feature => `- ${feature}`).join('\n'); content = content.replace(/\{\{CORE_FEATURES\}\} /g, featuresContent); // Replace constraints if provided if (constraints && constraints.length > 0) { const constraintsContent = constraints.map(constraint => `- ${constraint}`).join('\n'); content = content.replace(/\{\{CONSTRAINTS\}\} /g, constraintsContent); } else { content = content.replace(/\{\{CONSTRAINTS\}\} /g, 'No specific constraints identified.'); } // Replace date content = content.replace(/\{\{DATE\}\} /g, new Date().toLocaleDateString()); return content; } // Register the tool with the server export function registerPrdGeneratorTool(server: McpServer) { server.tool( 'generate_prd', generatePrdSchema, async (params) => { try { const prd = await generatePRD( params.productDescription, params.targetAudience, params.coreFeatures, params.constraints, params.templateName ); return { content: [{ type: 'text', text: prd }] }; } catch (error) { logger.error(`Error generating PRD: ${error.message}`, { error }); return { content: [{ type: 'text', text: `Error generating PRD: ${error.message}` }], isError: true }; } } ); logger.info('Registered PRD Generator tool'); } ``` -------------------------------- ### Configure PRD-MCP-Server for Cursor MCP Client Source: https://github.com/saml1211/prd-mcp-server/blob/main/README.md JSON configuration snippet to add the PRD-MCP-Server to Cursor's MCP client configuration, enabling integration with the PRD creator. ```json { "mcpServers": { "prd-creator": { "command": "npx", "args": ["-y", "prd-creator-mcp"] } } } ``` -------------------------------- ### API Reference: `list_validation_rules` Tool Source: https://github.com/saml1211/prd-mcp-server/blob/main/README.md Retrieve a comprehensive list of all available validation rules supported by the PRD Creator MCP Server. This allows users to understand the criteria against which PRDs can be validated. ```APIDOC list_validation_rules: ``` -------------------------------- ### Save New Template to Database in TypeScript Source: https://github.com/saml1211/prd-mcp-server/blob/main/prd-creator-implementation-plan.md Provides the `saveTemplate` function to create and persist a new template entry in the database. It generates a unique ID, sets initial version and timestamps, and stringifies tags before insertion. It logs the creation of the new template. ```typescript export async function saveTemplate(template: Omit): Promise