# saml1211/prd-mcp-server architecture

> Architecture diagram of the GitHub repository saml1211/prd-mcp-server, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/saml1211/prd-mcp-server
- Repository: https://github.com/saml1211/prd-mcp-server

## Overview

##### Project type and purpose
- This is a specialized MCP (Model Context Protocol) server whose sole purpose is to generate and validate Product Requirements Documents (PRDs).
- It exposes three main “tools” over an MCP‐compatible STDIO interface:
- generate_prd
- validate_prd
- list_validation_rules

##### File structure
- Top‐level folders under `src/`:
- config/ – logging and other configuration
- storage/ – handles DB connections and template persistence
- resources/ – MCP resource registrations, including URI resolvers
- templates/ – built‐in markdown template files (standard & comprehensive)
- tools/ – implementations of the PRD generator, validator, and rule lister
- Entry point: `src/index.ts` orchestrates CLI/stdio transport and tool routing.
- Auxiliary scripts: `generate-sample-prd.js` for demo, plus CI/dev artifacts like `tsconfig.json`, `package.json`.

##### README for architecture hints
- Protocol: STDIO-based MCP server
- Protocol handlers map incoming requests to the appropriate tool module
- Storage layer may use an on‐disk DB or in‐memory cache to store templates and rules

## Diagram (Mermaid)

```mermaid
flowchart LR
    subgraph "MCP Client"
        C["MCP Client"]:::external
    end

    subgraph "MCP Server"
        direction LR
        I["Entry Point / Protocol Adapter<br/>(index.ts)"]:::code
        CFG["Configuration Module<br/>(logging.ts)"]:::code
        TOOLS["Tools Module<br/>(index.ts)"]:::code
        RES["Resources Module<br/>(index.ts)"]:::code
        TPLRes["Template URI Resolver<br/>(templates.ts)"]:::code
        STOR["Storage Module<br/>(index.ts)"]:::code
        DB["Database Adapter<br/>(db.ts)"]:::storage
        TPLStore["Storage Template Handler<br/>(templates.ts)"]:::storage
        TPL["Built-in Templates<br/>(standard.md,<br/>comprehensive.md)"]:::static

        I --> CFG
        I --> TOOLS
        I --> RES
        I --> STOR

        TOOLS --> PRDGen["generate_prd<br/>(prd-generator.ts)"]:::code
        TOOLS --> PRDVal["validate_prd<br/>(prd-validator.ts)"]:::code
        TOOLS --> LRules["list_validation_rules<br/>(prd-validator.ts)"]:::code

        RES --> TPLRes
        TPLRes --> TPL

        STOR --> DB
        STOR --> TPLStore
        TPLStore --> TPL
    end

    C -->|"MCP StdIO"| I
    I -->|"Response"| C

    click I "https://github.com/saml1211/prd-mcp-server/blob/main/src/index.ts"
    click CFG "https://github.com/saml1211/prd-mcp-server/blob/main/src/config/logging.ts"
    click TOOLS "https://github.com/saml1211/prd-mcp-server/blob/main/src/tools/index.ts"
    click PRDGen "https://github.com/saml1211/prd-mcp-server/blob/main/src/tools/prd-generator.ts"
    click PRDVal "https://github.com/saml1211/prd-mcp-server/blob/main/src/tools/prd-validator.ts"
    click LRules "https://github.com/saml1211/prd-mcp-server/blob/main/src/tools/prd-validator.ts"
    click RES "https://github.com/saml1211/prd-mcp-server/blob/main/src/resources/index.ts"
    click TPLRes "https://github.com/saml1211/prd-mcp-server/blob/main/src/resources/templates.ts"
    click STOR "https://github.com/saml1211/prd-mcp-server/blob/main/src/storage/index.ts"
    click DB "https://github.com/saml1211/prd-mcp-server/blob/main/src/storage/db.ts"
    click TPLStore "https://github.com/saml1211/prd-mcp-server/blob/main/src/storage/templates.ts"
    click TPL "https://github.com/saml1211/prd-mcp-server/blob/main/src/templates/standard.md"
    click TPL "https://github.com/saml1211/prd-mcp-server/blob/main/src/templates/comprehensive.md"

    classDef code fill:#ADD8E6,stroke:#000;
    classDef storage fill:#90EE90,stroke:#000;
    classDef static fill:#FFFF99,stroke:#000;
    classDef external fill:#f0f0f0,stroke:#000,stroke-dasharray: 5 5;
```
