Skip to content

Commit ea6cdfa

Browse files
[4] Public catalog MCP surface for agent assembly (#32)
* [4] Public catalog MCP surface for agent assembly Add a thin Streamable HTTP MCP server on pegma-dev-api at /api/mcp that reads the published composition catalog. Tools list/get components and recipes plus rule-based plan_composition; skill page and llms.txt carry the config snippet. Catalog remains the system of record. * [4] Harden plan_composition for deps, green fixtures, logging Close recommended packages over required component dependencies and recipe package owners. Gate production plans on green fixtures. Fix static_host heavy-tag filtering and log MCP error messages. * [4] Prefer primary recipe and host-filtered adapter packages plan_composition no longer unions every partial recipe match into one install set; packages come from the top recipe (or tag match) with requires-closure. Adapter packages are filtered by host. Enrich storage-blobs so it is reachable via the storage capability tag. * [4] Keep tag matches and host-filter recipe pins Include tag-matched components alongside the primary recipe so combined capabilities (e.g. accounts+health) stay in the plan. Skip recipe package pins that are adapters for a different host than requested. * [4] Distinguish storage_blobs capability from record storage Add storage_blobs to the catalog capability tag set and tag storage-blobs with it so plan_composition no longer selects blob packages on generic storage / host-only queries. * [4] Tighten plan selection and package pins; stale catalog fallback Require meaningful core-tag coverage so incidental single-tag hits do not select heavy recipes. Prefer primary-recipe package pins over dumping every package on multi-package components. Serve stale catalog on revalidation failure when a warm isolate cache exists. * [4] Fix exclusive-tag coverage, host adapters, catalog backoff Allow singular accounts/passkeys requests while still rejecting incidental storage-only selection of the accounts recipe. Emit host adapter packages beside recipe core pins. On revalidation failure, serve stale catalog and reset TTL to back off.
1 parent 6b92d48 commit ea6cdfa

20 files changed

Lines changed: 4016 additions & 147 deletions

‎docs/AGENT_ASSEMBLY_PLAN.md‎

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22

33
## Status
44

5-
**Stage:** Phase 3 complete (hosted assembly skill). No MCP surface yet.
5+
**Stage:** Phase 4 complete (public catalog MCP). Phase 5 (scaffold + eval)
6+
remains open.
7+
68
This document is the working plan for closing the gap between what AI coding
79
agents tend to do (regenerate common backend functions as bespoke code) and
810
what the Pegma stack already packages (typed, tested, pin-able components).
911

10-
**Phase 0–3 artifacts:**
12+
**Phase 0–4 artifacts:**
1113

1214
| Artifact | Path |
1315
| --- | --- |
@@ -22,6 +24,8 @@ what the Pegma stack already packages (typed, tested, pin-able components).
2224
| P2 fixture (Yard Loan outbox) | `recipes/storage-audit-mail-outbox/` |
2325
| Hosted assembly skill (raw) | `https://pegma.dev/skill.md` (`public/skill.md`) |
2426
| Skill install notes | `https://pegma.dev/skill` (`src/pages/skill.astro`) |
27+
| Catalog tool logic | `src/data/mcp-tools.ts` |
28+
| MCP Worker surface | `worker/src/mcp-server.ts` → `https://pegma.dev/api/mcp` |
2529

2630
**Goal:** An agent given a short product description chooses the right
2731
`@pegma/*` packages, respects their refusals, and wires them at an explicit
@@ -313,16 +317,32 @@ The skill teaches judgment only; versions and package sets stay in
313317
**Exit:** a human can add the Pegma skill to a major coding agent in one
314318
sitting; the skill does not hardcode package versions.
315319

316-
### Phase 4 — MCP surface (optional but planned)
320+
### Phase 4 — MCP surface ✓
321+
322+
Implement a thin MCP server over the published catalog. Hosted on the
323+
existing `pegma-dev-api` Worker at `/api/mcp` (stateless Streamable HTTP via
324+
`createMcpHandler`). Tools: list/get components, list/get recipes,
325+
`plan_composition`. Same progressive-disclosure limits as above. Catalog is
326+
fetched from the static `catalog.json` URL — MCP is never the system of
327+
record.
317328

318-
Implement a thin MCP server over the published catalog (likely on the
319-
existing Workers API or a sibling Worker). Tools: list/get components,
320-
list/get recipes, plan_composition. Same progressive-disclosure limits as
321-
above.
329+
Shipped:
330+
331+
| Surface | Path / URL |
332+
| --- | --- |
333+
| Tool logic (pure) | `src/data/mcp-tools.ts` |
334+
| Catalog fetch + cache | `worker/src/mcp-catalog-fetch.ts` |
335+
| MCP server factory | `worker/src/mcp-server.ts` |
336+
| Endpoint | `https://pegma.dev/api/mcp` |
337+
| Config snippet | `public/skill.md`, `/skill` |
322338

323339
**Exit:** MCP config snippet on pegma.dev; tools return catalog facts only;
324340
no private data plane.
325341

342+
**Done:** public MCP tools over catalog.json; install/config on skill page
343+
and `llms.txt`; `plan_composition` is rule-based over structured
344+
`capabilityTags`.
345+
326346
### Phase 5 — Scaffold and eval harness
327347

328348
Public synthetic starter template with pinned known-good versions and an
@@ -398,8 +418,9 @@ Phase 0 recommendations (not irreversible) are recorded in
398418
**structured `capabilityTags`** (see schema).
399419
- **Skill packaging:** single canonical markdown vs. thin per-tool wrappers
400420
that only differ in install paths. (Phase 3)
401-
- **MCP hosting:** extend `pegma-dev-api` vs. separate Worker to keep the
402-
account API’s privilege surface small. (Phase 4)
421+
- **MCP hosting:** ~~extend `pegma-dev-api` vs. separate Worker~~ →
422+
**extend `pegma-dev-api` at `/api/mcp`** (stateless, public catalog only;
423+
no new secrets or private data plane).
403424

404425
## Implementation note
405426

‎docs/catalog/SCHEMA.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,9 @@ CompositionCatalog
115115
Structured flags (not free text) so `plan_composition` can stay rule-based:
116116

117117
`accounts`, `passkeys`, `email_codes`, `sessions`, `authorization`, `storage`,
118-
`audit`, `mail_transactional`, `rate_limit_durable`, `rate_limit_memory`,
119-
`webhooks_inbound`, `support_queue`, `health`, `logging`, `events_in_process`,
120-
`cloudflare`, `azure`, `static_host`.
118+
`storage_blobs`, `audit`, `mail_transactional`, `rate_limit_durable`,
119+
`rate_limit_memory`, `webhooks_inbound`, `support_queue`, `health`, `logging`,
120+
`events_in_process`, `cloudflare`, `azure`, `static_host`.
121121

122122
## TypeScript source
123123

0 commit comments

Comments
 (0)