Petamind MCP

Petamind MCP

Enables agentic coding workflows in Claude Code through a multi-candidate patch evaluation loop that generates code variants, validates builds, scores results with mandatory vision testing, and automatically selects the best implementation.

Category
访问服务器

README

Petamind MCP

A Claude Code MCP server for a multi-candidate agentic coding loop: reasoner plan → generate patches → deterministic gates → mandatory vision scoring → pick the best winner.

Poetiq-style refinement loop (descriptive, not affiliated): This project uses “Poetiq-style” descriptively to refer to iterative refinement loops (generate → critique → refine → verify). It is not affiliated with Poetiq.

Setup guide: docs/MCP_PETAMIND_MCP.md. Vertex setup: docs/VERTEX_SETUP.md. Troubleshooting: docs/TROUBLESHOOTING.md.

MCP Quick Start (Claude Code)

Option A (recommended): install from PyPI via pipx

pipx install petamind-mcp
petamind-setup

Then add the MCP server to Claude Code (user scope):

claude mcp add-json --scope user petamind-mcp '{"command":"petamind-mcp","args":[]}'

Notes:

  • petamind-setup installs Playwright Chromium (required for the mandatory vision loop).
  • You do not need Google Cloud credentials to use petamind_eval_patch with vision_provider=client (default).

Option B: install from a git clone (contributors / hacking)

From this repo root:

./scripts/setup.sh

Then follow docs/MCP_PETAMIND_MCP.md to add the server to Claude Code via .mcp.json or claude mcp add-json.

Minimal Claude Code config (user scope)

claude mcp add-json --scope user petamind-mcp '{
  "command": "'"$(pwd)"'/.venv/bin/python",
  "args": ["-m", "petamind_mcp.mcp_server"]
}'

Included: Synthetic UI Dataset Factory

This repo also includes a production-grade synthetic dataset generator for UI/UX design tasks (landing pages, directories, dashboards) using Next.js App Router + TypeScript + Tailwind.

Features

  • Multi-model pipeline: Uses Vertex AI (DeepSeek, Kimi, MiniMax) and OpenRouter (Devstral, vision models)
  • Quality gating: Only winners pass through to training data (build success + vision score threshold)
  • Resumable: SQLite caching for model responses, task state persistence
  • Two output tracks: public/ (publishable models only) and private/ (all models)
  • No contamination: Chain-of-thought/thinking never stored; only structured specs + code

Claude Code MCP (agentic coding)

This repo also ships an MCP server (petamind-mcp) that exposes a multi-candidate patch/test/vision loop to Claude Code. Setup guide: docs/MCP_PETAMIND_MCP.md.

Quick Start

1. Environment Setup

# Create virtual environment
python3 -m venv .venv
source .venv/bin/activate

# Install dependencies
pip install -e .

# Or with uv (faster)
uv pip install -e .

# Install Playwright browsers
playwright install chromium

2. Configure Environment Variables

cp .env.example .env
# Edit .env with your credentials

Required:

  • GOOGLE_CLOUD_PROJECT: Your GCP project ID
  • GOOGLE_CLOUD_REGION: Region for Vertex AI (e.g., us-central1)
  • OPENROUTER_API_KEY: Your OpenRouter API key

Optional:

  • GCS_BUCKET: For cloud backup of outputs

3. Authenticate with Google Cloud

gcloud auth application-default login

4. Run

# Smoke test (3 tasks end-to-end)
make smoke

# Full run (public models only)
make run_public

# Full run (all models including private)
make run_private

# Resume a previous run
titan-factory run --resume <run_id>

# Export training data
make export RUN_ID=<run_id>

Configuration

Edit config/config.yaml to customize:

models:
  planner:
    provider: vertex
    model: deepseek-ai/deepseek-v3.2-maas
    publishable: true

  ui_generators:
    - provider: vertex
      model: moonshotai/kimi-k2-thinking-maas
      publishable: true
      variants: 2
    - provider: vertex
      model: minimaxai/minimax-m2-maas
      publishable: true
      variants: 2

  patcher:
    provider: openrouter
    model: mistralai/devstral-2512:free
    publishable: true

  vision_judge:
    provider: openrouter
    model: null  # Falls back to heuristic scorer
    publishable: false

pipeline:
  vision_score_threshold: 8.0
  max_fix_rounds: 2
  polish_loop_enabled: true
  tasks_per_niche: 7

budget:
  concurrency_vertex: 5
  concurrency_openrouter: 10
  requests_per_min_vertex: 60
  requests_per_min_openrouter: 100
  max_total_tasks: null  # Run all
  stop_after_usd: null   # No limit

export:
  holdout_niches: 12
  validation_split: 0.08

Pipeline Stages

  1. Niche/Task Generation: Creates 100 niches × 7 tasks = 700+ tasks
  2. Planning: DeepSeek generates UI_SPEC JSON for each task
  3. UI Generation: Kimi + MiniMax generate code candidates (2 variants each)
  4. Validation: Next.js build with Devstral-powered fix loops
  5. Rendering: Playwright captures screenshots at 3 viewport sizes
  6. Scoring: Vision judge (or heuristic fallback) scores candidates
  7. Selection: Best candidate per task selected for training
  8. Export: Winners exported to train.jsonl / valid.jsonl

Output Structure

out/<run_id>/
├── cache.db                 # SQLite response cache
├── manifest.db              # Task state tracking
├── prompts/
│   ├── niches.json
│   └── tasks.jsonl
├── renders/
│   └── <task_id>/
│       └── <candidate_id>/
│           ├── 375x812.png
│           ├── 768x1024.png
│           └── 1440x900.png
├── rich_records.jsonl       # All candidates (for audit)
├── selected_records.jsonl   # Winners only
├── public/
│   ├── train.jsonl
│   └── valid.jsonl
└── private/
    ├── train.jsonl
    └── valid.jsonl

Training Data Format

Each line in train.jsonl:

{
  "messages": [
    {"role": "system", "content": "You are Titan 4 Design..."},
    {"role": "user", "content": "<task prompt>"},
    {"role": "assistant", "content": "{\"ui_spec\": ..., \"files\": [...]}"}
  ]
}

Page Types Covered

  • landing: Marketing landing pages
  • directory_home: Directory homepage with search
  • city_index: City-specific listing pages
  • category_index: Category-specific listing pages
  • listing_profile: Individual listing detail pages
  • admin_dashboard: Admin/analytics dashboards
  • edit: Refactor/edit tasks (20% of dataset)

Development

# Run tests
pytest tests/

# Type checking
mypy src/

# Format
ruff format src/ tests/
ruff check src/ tests/

Architecture Notes

  • Provider abstraction: Clean interface for Vertex AI and OpenRouter
  • Deterministic IDs: Tasks have stable IDs from hash(niche_id + page_type + seed)
  • JSON strictness: Safe extraction with fallback parsing
  • Async throughout: Uses asyncio for concurrent model calls
  • No thinking storage: Only structured UI_SPEC and final code stored

License

MIT

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选