Genesis MCP Ecosystem Update: This tooling is part of the Genesis MCP Suite. Explore the Interactive MCP Config & .cursorrules Builder, inspect FastMCP Forge on GitHub, or get the free Genesis Starter Kit and the Enterprise Pro Suite ($19).
How to Automate Product Management for AI Agents: A User Story & PRD Engine with MCP in Python
In 2026, autonomous software development agents (Claude Desktop, Cursor, Devin, Roo-Code) have become integral members of modern engineering teams. Developers routinely task agents with writing full microservices, refactoring legacy codebases, and implementing distributed algorithms.
However, giving high-level prompts directly to autonomous coding agents quickly triggers three fundamental product engineering failure modes:
- The Vague Requirements Trap: Agents receive instructions like "Make the checkout fast and intuitive". Without measurable acceptance criteria, the agent hallucinates arbitrary design decisions, builds unnecessary abstractions, or creates untestable implementations.
- Dependency Deadlocks & Sequence Inversion: When an agent attempts to implement components out of order—such as building a database consumer service before the underlying migration schema or producer API is finalized—subprocesses deadlock or fail on unresolvable import errors.
- Disconnection from Project Trackers: Agents execute code silently in local terminals, leaving sprint backlogs in Jira, Linear, or GitHub Issues out of sync. Engineering managers and tech leads are left manually transcribing agent progress.
To solve this, we engineered PMFlow: an open Model Context Protocol (MCP) server in Python that equips AI agents with the discipline of a Principal Technical Product Manager. It generates structured PRDs, decomposes epics into testable BDD User Stories, executes topological DAG scheduling with Kahn's algorithm, calculates the mathematical Critical Path (CPM), and exports synchronized payloads directly to GitHub Issues, Linear, and Jira.
🏗️ System Architecture
PMFlow operates as a deterministic Product Management sidecar communicating over stdio via JSON-RPC 2.0:
+-------------------------------------------------------------------------+
| AI Agent / LLM (Claude, Cursor, Devin) |
+-------------------------------------------------------------------------+
|
(MCP JSON-RPC Tools)
v
+-------------------------------------------------------------------------+
| PMFlow MCP Server |
+-------------------------------------------------------------------------+
| | |
v v v
+-----------------+ +-----------------+ +-----------------+
| PRD & Story | | Story DAG & | | Capacity & PERT |
| Decomposer | | Critical Path | | Forecaster |
| (BDD/Gherkin) | | (Kahn / CPM) | | (Monte Carlo) |
+-----------------+ +-----------------+ +-----------------+
| | |
+-----------------------+-----------------------+
|
v
+-----------------------+
| SQLite WAL Datastore |
| (Zero-loss persistence|
+-----------------------+
|
v
+------------------------------------------------+
| Issue Tracker Exporters (GitHub, Linear, Jira) |
+------------------------------------------------+
1. Automated PRD Generation & BDD Acceptance Validation
When an AI agent is tasked with building a feature, the first step is converting the user's intent into a structured Product Requirements Document (PRD) with MoSCoW prioritization, architectural constraints, and measurable success metrics.
Furthermore, human-written requirements frequently contain ambiguous words ("fast", "seamless", "easy", "robust") that cause AI agents to deviate. PMFlow's BDD Acceptance Validator scores criteria on a 0-100 testability scale and requires concrete quantitative boundaries:
import re
VAGUE_TERMS = {
"fast": "Specify response time in milliseconds (e.g., '< 200ms').",
"easy": "Specify concrete steps or usability metric (e.g., '< 3 clicks').",
"intuitive": "Define accessibility guidelines or UX checklist.",
"robust": "Specify failure recovery, retry policy, or SLA uptime percentage."
}
def validate_scenario(criteria: list[str]) -> dict:
has_given = any(re.match(r"^given\b", line.lower()) for line in criteria)
has_when = any(re.match(r"^when\b", line.lower()) for line in criteria)
has_then = any(re.match(r"^then\b", line.lower()) for line in criteria)
score = 100
if not (has_given and has_when and has_then):
score -= 50
vague_findings = []
for line in criteria:
for term, tip in VAGUE_TERMS.items():
if re.search(r"\b" + re.escape(term) + r"\b", line.lower()):
vague_findings.append({"term": term, "recommendation": tip})
score -= 10
return {
"is_valid": has_given and has_when and has_then and score >= 60,
"testability_score": max(0, score),
"vague_findings": vague_findings
}
Now, when an agent decomposes a feature, each story must meet strict Given/When/Then standards:
Given a user with an active session token
When user issues a POST to /api/v1/checkout with valid cart items
Then server responds with HTTP 201 within 250ms and decrements inventory
2. Dependency DAG & Critical Path Engine (CPM)
In multi-agent environments, tasks cannot execute arbitrarily. PMFlow models the backlog as a Directed Acyclic Graph (DAG) persisted in SQLite WAL.
Cycle Detection via Kahn's Algorithm
Before scheduling work, PMFlow verifies that no cyclic dependencies exist:
def topological_sort(stories, adjacency, predecessors):
in_degree = {sid: len(predecessors[sid]) for sid in stories}
queue = [sid for sid, deg in in_degree.items() if deg == 0]
sorted_order = []
while queue:
node = queue.pop(0)
sorted_order.append(node)
for succ in adjacency[node]:
in_degree[succ] -= 1
if in_degree[succ] == 0:
queue.append(succ)
if len(sorted_order) != len(stories):
cycle_nodes = [sid for sid, deg in in_degree.items() if deg > 0]
raise ValueError(f"Cyclic dependency detected: {cycle_nodes}")
return sorted_order
Critical Path & Float Calculation
Using forward and backward passes, PMFlow calculates:
- Earliest Start (ES) & Earliest Finish (EF)
- Latest Start (LS) & Latest Finish (LF)
- Total Float (Slack): $Float = LS - ES$. Tasks with $Float = 0$ constitute the Critical Path.
+---------------------+
| US-001: Schema | (4.0h, Critical)
+---------------------+
|
v
+---------------------+
| US-002: Tokenizer | (8.0h, Critical)
+---------------------+
/ \
v v
+---------------+ +-------------------+
| US-003: UI | | US-004: RateLimit | (6.0h, Critical)
| (2.0h, Slack) | +-------------------+
+---------------+ |
\ /
v v
+------------------------+
| US-005: Deploy Swarm | (2.0h, Critical)
+------------------------+
Total Project Duration: 20.0 hours. Any delay in US-001, US-002, US-004, or US-005 directly delays the release date, whereas US-003 has float slack and can run in the background.
3. Monte Carlo Capacity Forecaster
Will the current backlog fit into the sprint?
Instead of relying on single-point estimates, PMFlow uses triangular PERT estimation (Optimistic, Most Likely, Pessimistic) and executes a 1,000-trial Monte Carlo simulation:
import random
def simulate_sprint(stories, num_agents=2, hours_per_agent=40.0, trials=1000):
available_capacity = num_agents * hours_per_agent # e.g., 80 hours
simulated_totals = []
for _ in range(trials):
total = 0.0
for s in stories:
base = s["estimated_hours"]
# Triangular distribution: [0.7*base, base, 1.6*base]
total += random.triangular(0.7 * base, 1.6 * base, base)
simulated_totals.append(total)
simulated_totals.sort()
p50 = simulated_totals[int(0.50 * trials)]
p80 = simulated_totals[int(0.80 * trials)]
p95 = simulated_totals[int(0.95 * trials)]
return {
"p50_hours": p50,
"p80_hours": p80,
"p95_hours": p95,
"is_within_capacity": p80 <= available_capacity
}
If the P80 confidence forecast exceeds available capacity, PMFlow flags bottleneck tasks and advises the agent swarm on scope pruning before code is written.
4. Multi-Platform Issue Tracker Synchronization
Once the PRD and User Stories are validated, PMFlow exports verified payloads directly to the engineering team's tracker of choice:
-
GitHub Issues: Formats stories with Markdown acceptance criteria checklists (
- [ ] Given...), story point labels, and milestone assignment. - Linear: Generates GraphQL mutations with team IDs, priority rankings, and parent/sub-issue relations.
- Jira Cloud: Generates Atlassian REST API v3 payloads with issue types, custom fields for story points, and bidirectional block links.
⚡ Integrating with Claude Desktop & Cursor
Connect PMFlow to your local agent configuration:
{
"mcpServers": {
"pmflow": {
"command": "python3",
"args": ["-m", "pmflow.server"]
}
}
}
Now, simply prompt your agent:
"Generate a PRD for an idempotent payment webhook listener, break it down into testable BDD stories, calculate the critical path, and export the issues to GitHub."
Your agent acts with complete product rigor, eliminating hallucinations and delivering code in optimal topological order.
🚀 Get Started: Open-Source & Enterprise
The open-source PMFlow Lite is available immediately on GitHub under the MIT license:
👉 GitHub Repository: https://johannschiffer.github.io
For enterprise engineering teams and agent swarms requiring the persistent SQLite WAL DAG engine, Critical Path calculation (CPM), parallel multi-agent wave scheduling, Monte Carlo capacity forecasting, and Jira/Linear exporters:
👉 Explore PMFlow Pro on Gumroad ($14.9Free MIT)
How do you structure requirements and task dependencies when working with autonomous AI agents? Let's discuss in the comments below!
☕ Support & Community
- 100% Free & Open Source (MIT): All tools and full production architectures are unrestricted and publicly available on GitHub.
- Support Development on Ko-fi: ko-fi.com/johannschiffer
- GitHub Organization: github.com/johannschiffer
- Web Portal & Rule Configurator: johannschiffer.github.io
Top comments (0)