Skip to content

Create packages/mcp server with run-data tools #85

Description

@williamthorsen

Parent

Part of #74 (MCP server for run data + v3 event-sourced format) — PR 2 of 4.

Dependencies

Scope

Create packages/mcp/ as a custom MCP server providing domain-specific tools for run data management. The orchestrator calls these instead of Read/Edit/Write on JSON files.

Deliverables

  1. Package scaffoldingpackage.json (@codeassembly/mcp), tsconfig.json, vitest.config.ts, CLI entry point
  2. 5 MCP tools:
    • init_run — generate run ID, create artifact directory, write v3 header, emit run_initialized
    • emit_event — validate event against Zod schema, append timestamped JSONL line
    • register_artifact — validate artifact entry, emit artifact_written event
    • complete_run — emit run_completed, stamp completedAt on header
    • get_run_state — read header + fold events → CanonicalRunStatus
  3. Server implementation@modelcontextprotocol/sdk with stdio transport
  4. MCP registration — add to .claude/settings.json
  5. Build-on-installprepare script to compile on pnpm install

Acceptance criteria

  • Server starts via node packages/mcp/dist/esm/cli.js without errors
  • Each tool handler tested with mock file system
  • JSONL append produces valid, parseable lines
  • Validation errors return descriptive messages (not silent failures)
  • get_run_state round-trips correctly: init → emit events → get_run_state matches expected state
  • Integration test: full lifecycle (init → events → artifacts → complete → get_state)
  • init_run failure is loud and immediate (fail-early design for MCP unavailability)

See #74 implementation plan, Step 2 for full details.

Metadata

Metadata

Labels

featureAdded or improved external functionalityscope:agents

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions