Athena — roomy-mobile/archive/changes/2026-01-05-add-roomy-firestore-mcp/tasks/006-register-crud-tools.md


status: done

Task: Register CRUD + schema MCP tools

End Goal

MCP server registers all 10 CRUD and schema tools with correct input/output shapes.

Currently

Firestore env works, datamodel registry works, serialization works, CRUD helpers work.

Should

Register exactly these 10 tools:

  • list_collections
  • get_schema
  • get_doc
  • list_docs
  • create_doc
  • update_doc
  • delete_doc
  • create_docs
  • update_docs
  • delete_docs

Constraints

  • [ ] Use Zod enum for type built from entityKey values
  • [ ] Enforce pathParams required for subcollection entities
  • [ ] Tool output always uses toJsonSafe and JSON.stringify(..., null, 2)
  • [ ] Batch tools: if transaction=false, enforce max 500 operations

Acceptance Criteria

  • [ ] Tool names, input shapes, and output shapes match the spec
  • [ ] list_collections reflects datamodel YAMLs
  • [ ] Complete CRUD flow works: create → get → update → delete

Implementation Checklist

  • [x] 6.1 Create src/tools/crudTools.ts with registerCrudTools({ server, envService, repoRoot })
  • [x] 6.2 Load entities via loadEntityRegistry(repoRoot)
  • [x] 6.3 Build Zod enum from entity keys for type parameter
  • [x] 6.4 Register list_collections tool
  • [x] 6.5 Register get_schema tool with timestampFormat and fields
  • [x] 6.6 Register get_doc tool
  • [x] 6.7 Register list_docs tool
  • [x] 6.8 Register create_doc tool with buildCreateOrUpsertDataSchema validation
  • [x] 6.9 Register update_doc tool with buildUpdateDataSchema validation
  • [x] 6.10 Register delete_doc tool
  • [x] 6.11 Register create_docs batch tool
  • [x] 6.12 Register update_docs batch tool with upsert support
  • [x] 6.13 Register delete_docs batch tool
  • [x] 6.14 Implement transaction vs batch modes
  • [x] 6.15 Update src/index.ts to call registerCrudTools(...) after env init
  • [x] 6.16 Return { entityCount, toolCount: 10 } from registration

Notes

  • Schema tools return normalized field types: string|number|boolean|timestamp|map|array|unknown
  • Batch transaction mode: use runTransaction() with tx.create/update/delete
  • Batch non-transaction mode: use WriteBatch with max 500 ops

Reacties

Nog geen reacties