PCQ

PCQ

Python library for agent-operable experiment evidence and control. Bring any training code

Category
访问服务器

README

pcq

pcq is the contract for agent-run ML experiments. This repository hosts the contract specification under spec/ and the reference Python implementation under src/pcq/. Install the reference impl: uv add pcq (Apache-2.0).

The contract turns a project with cq.yaml into a reproducible experiment unit. The reference Python implementation loads config, resolves output paths, captures metrics, writes standard artifacts, finalizes run evidence, and exposes JSON/JSONL/MCP surfaces that coding agents, CI jobs, notebooks, and services can consume. See spec/IMPLEMENTATIONS.md for the registered implementation list (Python reference + CQ Go production worker today) and the procedure for adding yours.

pcq is not a training framework, model zoo, adapter matrix, or CQ-only client. Use PyTorch, Hugging Face Trainer, Lightning, sklearn, TabPFN, PyCaret, XGBoost, shell scripts, remote jobs, or project-local research code. The contract is the integration layer.

pcq does not operate the model.
pcq operates the experiment boundary.

SITE | INTRODUCTION | V4_DIRECTION | VISION | AGENT_OPERABILITY | RUN_RECORD | AGENT_OPERATING_GUIDE | CHANGELOG

Contract specification (single source of truth): spec/INDEX.md | SPEC | CQ_YAML_RUNTIME_CONTRACT | JSON_CONTRACTS | STRICTNESS | CQ_MCP_SPEC | VERSIONING | CONFORMANCE | schemas/ (auto-exported via scripts/export_schemas.py)

Case studies (external evidence): mnist-dogfood | tabular-dogfood | mcp-dogfood | cq-worker-dogfood

Agent-readable site files: llms.txt, llms-full.txt, agent-manifest.json.

Identity

pcq = open-source experiment evidence/control library
cq  = managed execution + orchestration + dashboard + agent loop

CQ service is one managed consumer of the contract. pcq remains useful without CQ: locally, in CI, in notebooks, and inside third-party orchestrators.

Why pcq

  • Framework-neutral — keep the training stack that fits the problem.
  • Agent-readable — use JSON/JSONL instead of terminal scraping.
  • Agent-verifiable — validate source, config, environment, metrics, artifacts, and run records.
  • Agent-operable — run, observe, validate, describe, compare, lineage, and iterate through stable commands.
  • Service-ready — CQ can consume the same contract for managed execution and automatic experiment loops.

Installation

uv add pcq
# Optional — to expose pcq as MCP tools to agent runtimes:
uv add 'pcq[mcp]'

pyproject.toml:

[project]
dependencies = ["pcq"]              # core only
# or:
dependencies = ["pcq[mcp]"]         # core + Model Context Protocol server

Docker (MCP server only)

A minimal container image is also published; it packages pcq[mcp] from PyPI and runs pcq mcp serve on stdio.

docker build -t pcq .
docker run -i --rm pcq          # MCP client attaches to stdin/stdout

The image is intentionally scoped to the MCP server surface — for pcq run, pcq describe-run, pcq agent install and other CLI subcommands, install pcq directly with uv add pcq instead.

For a tag, branch, or private fork:

[tool.uv.sources]
pcq = { git = "https://github.com/playidea-lab/pcq.git", tag = "v4.1.0" }

The PyPI distribution, import name, CLI command, GitHub repository, runtime workspace, and JSON contract namespace are all pcq. Runtime contract names from CQ remain stable: cq.yaml, CQ_CONFIG_JSON, and cq://.

Minimal Contract

cq.yaml declares the run:

name: sklearn-baseline
cmd: uv run python train.py
configs:
  output_dir: output
  seed: 42
  strictness: 3
  monitor: eval_acc
  mode: max
metrics:
  - epoch
  - eval_acc
artifacts:
  - output/
inputs: {}

train.py can use any framework:

import pickle

import pcq
from sklearn.datasets import load_iris
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import train_test_split

cfg = pcq.config()
out = pcq.output_dir()
pcq.seed_everything(cfg.get("seed", 42))

x, y = load_iris(return_X_y=True)
x_train, x_eval, y_train, y_eval = train_test_split(
    x,
    y,
    test_size=0.25,
    random_state=int(cfg.get("seed", 42)),
    stratify=y,
)

model = RandomForestClassifier(random_state=int(cfg.get("seed", 42)))
model.fit(x_train, y_train)
eval_acc = float(model.score(x_eval, y_eval))

with (out / "model.pkl").open("wb") as f:
    pickle.dump(model, f)

history = [{"epoch": 0, "eval_acc": eval_acc}]
pcq.log(**history[-1])
pcq.save_all(history=history, artifacts={"model": "model.pkl"})

No sklearn adapter is required. The same pattern works for HF Trainer, Lightning, XGBoost, TabPFN, PyCaret, shell commands, or custom code.

Agent Command Surface

Read and validate the project:

pcq resolve --json
pcq inspect . --json
pcq validate . --strictness 2 --json

Run the project:

pcq run --path . --json
pcq run --path . --jsonl
pcq run --path . --events output/events.jsonl --json

Validate and summarize outputs:

pcq validate-run output --strictness 3 --json
pcq describe-run output --json
pcq compare-runs old_output new_output --json
pcq lineage output --json

Iterate:

pcq apply-plan experiment.plan.json --json

Agent rule: prefer JSON/JSONL surfaces over scraping human output. pcq reports facts; the agent or service chooses policy.

Standard Artifacts

A completed run should produce:

  • config.json
  • metrics.json
  • manifest.json
  • run_summary.json
  • run_record.json
  • validation_report.json

run_record.json is the canonical completion object. It combines execution, source, environment, input identity, metric schema, artifact manifest, agent provenance, validation, and summary evidence.

Agent Runtime Assets

pcq can install its canonical agent instructions and skill into a project. Package installation itself never mutates project agent files.

pcq agent install --target codex --path .
pcq agent install --target claude --path .
pcq agent install --target both --path . --dry-run --json
pcq agent status --target both --path . --json

To also wire the project for MCP-aware agents (Claude Code, Codex), install pcq[mcp] and pass --mcp:

uv add 'pcq[mcp]'
pcq agent install --target claude --path . --mcp     # writes .mcp.json
pcq mcp serve                                         # stdio (default)

This exposes 14 mcp__pcq__* tools (resolve_project, validate_run, describe_run, compare_runs, ...) so agents call pcq directly without subprocess parsing. See MCP Integration.

Reusable assets:

v4 Direction

v4 clarifies the product boundary:

  • contract-first workflow, not a 3-tier training API
  • project-local training code, not built-in production catalogs
  • contract scripts, not framework adapters
  • run evidence validation, not recipe ownership
  • JSON/JSONL facts, not prose parsing

See pcq v4 Direction.

Development

uv run ruff check src/ tests/ scripts/
uv run python -m compileall src/pcq
uv run pytest tests/ -q
bash scripts/release-smoke.sh

License

Apache-2.0.

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选