Add write operations (create/update/delete) for Kontena schemas and entries#39
Merged
Merged
Conversation
…blish)
Adds the create/update/delete + publish workflow on top of the existing
read-only kontena CLI and MCP surfaces. Three milestones in one PR:
* CLI: `sawala kontena schema {create,update,delete}` and
`sawala kontena entry {create,update,delete,publish,unpublish}`.
Body is supplied via `--file <path>` (or `-` for stdin) or inline
`--data <json>`. Destructive verbs prompt on a TTY and refuse in
non-TTY mode without `--yes`. Both create/update support `--dry-run`
for round-trip-free validation.
* MCP: eight new tools mirroring the CLI verbs. Delete tools require
`confirm: true` in the input to guard against empty-payload accidents
and carry `destructiveHint`/`irreversibleHint` for host UIs. Entry
CRUD transparently fetches the schema first to route single vs
collection — schema type stays an implementation detail of the
worker, not the tool surface.
* Shared helpers: new `packages/sawala/src/lib/io.ts` with
`readJsonInput`, `confirmOrThrow`, and `resolveInputPayload` so the
CLI verbs share a single I/O convention.
The publish/unpublish verbs target collection schemas; for single-type
schemas, callers use `update --publish` with the locale in the patch.
sutisnamulyana
pushed a commit
that referenced
this pull request
May 22, 2026
PR #39 merged without a changeset, so the release workflow tried to republish the existing 0.1.2 of both `@sawala/cli` and `@sawala/mcp`. This bumps both to a `minor` (new feature surface).
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Extends the Kontena CLI and MCP tool surface from read-only inspection to full CRUD operations. Adds support for creating, updating, and deleting both schemas and entries, plus publish/unpublish workflows for collection entries.
Key Changes
CLI Commands (
packages/sawala/src/commands/kontena.ts)schema create,schema update <slugOrId>, andschema delete <slugOrId>commands--fileand--dataoptions for input payloads--dry-runflag to validate without writing--yes)entry create <schemaSlug>,entry update <schemaSlug> <slugOrId>, andentry delete <schemaSlug> <slugOrId>commandsfetchSchemaType()helper/content/{single,collection}/...endpoints based on schema type--publishflag to setstatus='published'on create/updateentry publish <schemaSlug> <slugOrId>andentry unpublish <schemaSlug> <slugOrId>convenience commandsInput/Output Utilities (
packages/sawala/src/lib/io.ts)readJsonInput(path): Reads JSON from file or stdin (-)confirmOrThrow(question): TTY-aware confirmation prompt for destructive operationsresolveInputPayload(opts): Unified handler for--dataand--fileoptionsMCP Tools (
packages/sawala-mcp/src/tools/)Added 8 new tool definitions:
kontenaCreateSchemaTool: POST schema to/schemaskontenaUpdateSchemaTool: PUT schema patch to/schemas/<slugOrId>kontenaDeleteSchemaTool: DELETE schema (requiresconfirm: true)kontenaCreateEntryTool: POST entry with transparent schema-type routingkontenaUpdateEntryTool: PUT entry patch with optionalpublishflagkontenaDeleteEntryTool: DELETE entry (requiresconfirm: true)kontenaPublishEntryTool: Publish collection entry (idempotent)kontenaUnpublishEntryTool: Unpublish collection entry (idempotent)All MCP tools include proper Zod validation, destructive/idempotent annotations, and error handling.
Tests
packages/sawala/test/kontena.test.tspackages/sawala-mcp/test/tools/Notable Implementation Details
/content/single/or/content/collection/routes, hiding wire-protocol asymmetry from usersdelete) refuse to run in non-TTY environments without--yes, preventing accidental data loss in scriptsreadOnlyHint,destructiveHint,idempotentHint, andirreversibleHintfor host-level safety warningshttps://claude.ai/code/session_01MuNb39Fg1kz7xDNfD8ehhe