# PRD Creator MCP Server

A specialized Model Context Protocol (MCP) server dedicated to creating Product Requirements Documents. This MCP server enables AI systems connected to MCP clients to generate detailed, well-structured product requirement documents through a standardized protocol interface.

## Features

- **PRD Generator**: Create complete PRDs based on product descriptions, user stories, and requirements
- **AI-Driven Generation**: Generate high-quality PRDs using multiple AI providers
- **Multi-Provider Support**: Choose from OpenAI, Google Gemini, Anthropic Claude, or local models
- **Provider Configuration**: Customize provider options for each PRD generation
- **Fallback Mechanism**: Gracefully falls back to template-based generation when AI is unavailable
- **PRD Validator**: Validate PRD completeness against industry standards and customizable rule sets
- **Template Resources**: Access a library of PRD templates for different product types
- **MCP Protocol Support**: Implements the Model Context Protocol for seamless integration with MCP clients

## Installation

### Prerequisites

- Node.js v16 or higher
- npm or yarn

### Install from source

1. Clone the repository:
```bash
git clone https://github.com/yourusername/prd-creator-mcp.git
cd prd-creator-mcp
```

2. Install dependencies:
```bash
npm install
```

3. Build the project:
```bash
npm run build
```

## Usage

### Running the server

The canonical way to run this MCP server is using npx:

```bash
npx prd-creator-mcp
```

This launches the server using STDIO transport, making it fully compatible with all MCP clients and inspector tools. No installation is required; npx will fetch and execute the latest version from the npm registry.

### Inspecting the server

To inspect the running server with the MCP Inspector UI, run:

```bash
npx @modelcontextprotocol/inspector npx prd-creator-mcp
```

## Distribution & CLI Usage

### Install Globally (optional)

You may also install the MCP server globally to expose the CLI (`prd-creator-mcp`):

```bash
npm install -g prd-creator-mcp
```

Then run:

```bash
prd-creator-mcp
```

### Command Reference

- `prd-creator-mcp`
  Runs the MCP server (STDIO transport).
  Use directly via npx or as a globally installed CLI for integration with MCP clients and tools.

### Uninstall

To remove the global CLI:

```bash
npm uninstall -g prd-creator-mcp
```

### Configuration & Customization

- **Environment Variables**:  
  Copy `.env.example` to `.env` and modify as needed.  
  Key options include provider API keys, logging settings, and DB location.
- **Templates & Rules**:  
  Customize templates in `src/templates/` and validation rules in `src/storage/validation-rules.ts`.

### Cross-Platform Support

- Fully tested on Node.js v16+ for macOS, Linux, and Windows (CMD/PowerShell).
- The CLI works identically on all platforms via `npx` or global install.
- No Unix-specific dependencies; paths and spawns are OS-agnostic.

### Troubleshooting

- **Permission denied:** Ensure `dist/index.js` is executable; on Unix, run `chmod +x dist/index.js`.
- **“Command not found”:** Ensure your global npm bin directory is in your PATH.
- **Build errors:** Run `npm run build` before direct usage.
- **Provider errors:** Check your `.env` for required API keys.
- **Unexpected exits:** Review logs (default: console, can be configured in `.env`).
### Verifying CLI Install

After installation or using npx, run:

```bash
prd-creator-mcp --help
```

or

```bash
npx prd-creator-mcp --help
```

### Adding to MCP client configuration

To use the PRD Creator MCP Server with an MCP client (like Claude Desktop or Cursor), add it to your MCP settings:

For Claude Desktop (on macOS), add to `~/Library/Application Support/Claude/claude_desktop_config.json`:

```json
{
  "mcpServers": {
    "prd-creator": {
      "command": "node",
      "args": ["/path/to/prd-creator-mcp/dist/index.js"],
      "disabled": false
    }
  }
}
```

### Docker Usage

Build the Docker image:

```bash
docker build -t prd-creator-mcp .
```

Run the container (STDIO mode):

```bash
docker run --rm prd-creator-mcp
```

### Available Tools

The server provides the following tools:

#### 1. `generate_prd`

Generate a complete PRD document using AI or template-based generation.

Parameters:
- `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.

Example:
```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
  }
}
```

#### 2. `validate_prd`

Validate a PRD document against best practices.

Parameters:
- `prdContent`: The PRD content to validate
- `validationRules` (optional): Array of validation rule IDs to check

Example:
```javascript
{
  "prdContent": "# My Product\n\n## Introduction\n...",
  "validationRules": ["has-introduction", "minimum-length"]
}
```

#### 3. `list_validation_rules`

List all available validation rules.

#### 4. `list_ai_providers`

List all available AI providers and their availability status.

Example response:
```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
  }
]
```

### Available Resources

The server provides access to PRD templates through the following URI pattern:

- `prd://templates/{templateName}`

Available templates:
- `standard`: A basic PRD template with essential sections
- `comprehensive`: A detailed PRD template with expanded sections

## Development

### Project Structure

```
prd-creator-mcp/
├── src/
│   ├── config/            # Configuration management
│   ├── storage/           # Database and caching
│   ├── tools/             # Tool implementations
│   ├── resources/         # Resource implementations
│   ├── templates/         # Initial PRD templates
│   └── index.ts           # Main entry point
├── tests/                 # Test files
├── dist/                  # Compiled output
└── README.md              # Documentation
```

### Running Tests

```bash
npm test
```

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## Contributing

Please read [CONTRIBUTING.md](CONTRIBUTING.md) and [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) before contributing.

## Configuration

### Environment Variables

Copy `.env.template` to `.env` and configure the following variables:

```
# Server configuration
LOG_LEVEL=info

# AI Provider Configuration
DEFAULT_AI_PROVIDER=openai

# OpenAI Configuration
OPENAI_API_KEY=your_openai_api_key_here
OPENAI_MODEL=gpt-4

# Anthropic Configuration
ANTHROPIC_API_KEY=your_anthropic_api_key_here
ANTHROPIC_MODEL=claude-3-opus-20240229

# Google Gemini Configuration
GEMINI_API_KEY=your_gemini_api_key_here
GEMINI_MODEL=gemini-pro

# Local LLM Configuration
LOCAL_MODEL_API_URL=http://localhost:11434/api
LOCAL_MODEL_NAME=llama3
```

---

Developed by Sam Lyndon