@mgcrea/mcp-cloudkit
A read-only-by-default MCP server for the CloudKit management API — browse containers, record types, and schemas, and preview a Development → Production deploy diff (mutations only when writes are enabled).
cloudkit_auth_status— check whether the management token works, whether writes are on, and exactly what config is missing.cloudkit_list_containers— list containers this team can manage, to find the container id other tools take.cloudkit_list_record_types— record types and fields forDEVELOPMENTorPRODUCTION; confirms a newCD_-prefixed field actually reached CloudKit.cloudkit_export_schema— dump an environment's full schema as.ckdbtext, or write it tooutputPath.cloudkit_diff_schema— pending Development → Production changes, one row per record type/field (ADD,CHANGE_INDEXES,RETYPE,MISSING_IN_DEVELOPMENT,OTHER); the read-only preview of a deploy.cloudkit_validate_schema— validate a local.ckdbagainst an environment without importing it.cloudkit_request— GET-only escape hatch for arbitrary routes (the Developmentresetroute is refused by path).With
CLOUDKIT_ALLOW_WRITES=1(andconfirm: true):cloudkit_deploy_schema— promote Development to Production, always computing the diff first and supportingdryRun; andcloudkit_import_schema— upload a.ckdbwholesale.Handles the two separate environment databases (Debug vs TestFlight/App Store) and stays entirely separate from App Store Connect credentials.
Provides tools for managing CloudKit schemas in an iCloud container, including listing containers and record types, exporting and validating schemas, diffing Development against Production, and deploying schema changes when writes are enabled.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@@mgcrea/mcp-cloudkit show me the schema diff between Development and Production"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
@mgcrea/mcp-cloudkit
A Model Context Protocol server for the CloudKit
management API — the schema surface behind the CloudKit Console and xcrun cktool. Read a
container's schema, diff Development against Production, and deploy the way the Console's
Deploy Schema Changes button does, from an MCP client.
This is a separate service from App Store Connect, with its own host and its own credential — an App Store Connect API key gives no access to CloudKit, and this token gives no access to App Store Connect. See @mgcrea/mcp-appstore-connect for versions, builds, TestFlight, and the rest of a release.
The server is read-only by default. Mutating tools are not merely refused when writes are off — they are never registered, so an agent cannot call them at all.
Why this exists
NSPersistentCloudKitContainer (Core Data or SwiftData) creates new record types and fields in
the Development environment only. It cannot alter Production, and it does not report that it
did nothing — so a build that ships a new attribute before the schema is deployed saves it
locally, syncs everything else, and drops that one field on the floor. Nothing surfaces to the
user; the record just arrives on the other device with the field absent.
The fix is one Console click, but it is a click nobody can script safely without seeing the diff
first: the schema becomes additive-only the moment it is first pushed to Production, and stays
that way forever — a field can be added, never removed, renamed or retyped. This server exists
to make that click scriptable without losing the safety property that matters: cloudkit_deploy_schema
always fetches and returns the diff before promoting anything, exactly what the Console shows
you before you press the button.
Related MCP server: CloudKit MCP
The API is undocumented
Apple ships no public docs or OpenAPI spec for the CloudKit management API. The routes here were
read out of the cktool binary Xcode installs (strings $(xcrun -f cktool)), and the way it calls
them — headers, methods, bodies — out of a live cktool session under a debugger, because
strings alone gets that wrong:
A management token goes in
X-ACP-API-TOKEN.X-Apple-CloudKit-User-Token, the only header namestringsfinds, is for user tokens; a management token sent there gets401 Failed to validate user token.Containers are listed at
/teams/{teamId}/containers, the one route outside/v1/database.A
.ckdbgoes up as a multipart body with one part namedfile, nevertext/plain(415). Validate is aPOST; import is aPUT.The binary also names
…/recordTypes,…/containers/{id}and…/schema/diff. They exist, but refuse a management token (401 authentication-failed): they belong to the Console's signed-in session. So record types are read fromGET …/environments/{env}/schema, and the diff is computed here from the two environments' schemas — the same data, reachable with the token.
cktool's own CLI exposes export-schema, import-schema and validate-schema — but not a
diff or a deploy, which is why this server exists rather than just wrapping cktool.
Three consequences follow from that:
Every response shaper falls back to the raw payload when it does not recognise the envelope, rather than reporting an empty result. A wrong guess here must never read as "the field is not deployed yet" when the truth is "the shaper does not understand this response".
cloudkit_requestis a GET-by-default escape hatch, so one endpoint answering differently than expected cannot make the rest of the server useless.cloudkit_deploy_schemahas not yet been seen to work with a management token. Its…/schema/{uuid}/promoteroute comes from the binary like the rest, butcktoolnever calls it, and its Console-only neighbours refuse the token. If it is refused, the tool says so and returns the diff; deploy from the Console instead.
Features
cloudkit_diff_schemashows what a deploy would change, one row per record type or field:ADD,CHANGE_INDEXES,RETYPE,MISSING_IN_DEVELOPMENT(Production keeps it; a deploy cannot remove it), orOTHERwhen the schemas differ outside any field, such as permissions.cloudkit_deploy_schemaalways computes that diff first; it refuses when there is nothing to deploy, when a field is retyped, or when either schema cannot be read, and takesdryRunto stop before committing.cloudkit_list_record_typesanswers "did my new field actually reach CloudKit" in one call — Core Data and SwiftData prefix every record type and field withCD_, so a SwiftisHiddenonTrackshows up asCD_isHiddenonCD_Track.The container
resetroute (wipes all Development data) is not exposed as a tool, andcloudkit_requestrefuses to reach it by path, in any case and percent-encoded or not — omitting it as a tool would mean little if the escape hatch could still call it.
Security
Read-only by default.
CLOUDKIT_ALLOW_WRITES=1addscloudkit_deploy_schemaandcloudkit_import_schema; both then additionally require an explicitconfirm: trueon every call, andcloudkit_requestrequires it for any method other than GET.A management token can rewrite a container's schema, which is broader than reading one. Scope it to the team that needs it, keep it out of tracked files, and revoke it in the Console when you are done — there is no expiry on it otherwise.
No runtime dependencies beyond the MCP SDK and Zod — native
fetchthroughout.Your credentials stay in your environment or config file; nothing is sent anywhere but
api.icloud.apple.com.
Configure
Create a token at icloud.developer.apple.com/dashboard/account/tokens under CloudKit Management Tokens.
Variable | Required | Notes |
| yes | Apple's own variable name — |
| yes | Your 10-character Apple Developer team id. |
| no | Default container, e.g. |
| no |
|
| no | Retry budget for 429/5xx. Defaults to 3. |
| no |
|
cp .env.example .envConfig file
If you'd rather not put the token in your shell profile or every MCP client config:
// ~/.config/cloudkit/config.json (chmod 600)
{
"managementToken": "...",
"teamId": "75QE9PRT3V",
"containerId": "iCloud.io.mgcrea.Balise",
"allowWrites": false,
}The environment wins over the file, field by field — a one-off CLOUDKIT_ALLOW_WRITES=0 still
overrides a file that says true. Unknown keys are an error, not silently ignored. Location:
$CLOUDKIT_CONFIG, else $XDG_CONFIG_HOME/cloudkit/config.json, else ~/.config/cloudkit/config.json.
Quick start
pnpm install
pnpm buildThen copy .mcp.json.example to .mcp.json and fill it in.
Inspect the tools
printf '%s\n' \
'{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"cli","version":"0"}}}' \
'{"jsonrpc":"2.0","method":"notifications/initialized"}' \
'{"jsonrpc":"2.0","id":2,"method":"tools/list"}' \
| node dist/cli.js 2>/dev/null | jq -r '.result.tools[]?.name'Tools
Tool | What it does | Writes |
| Credential state and what to configure | no |
| Containers this team can manage | no |
| Record types and fields for an environment | no |
| An environment's full schema as | no |
| Pending Development → Production changes | no |
| Validate a local | no |
| Escape hatch for any other route | no (GET only) |
| Promote Development to Production | yes† |
| Upload a | yes† |
Italic tools need CLOUDKIT_ALLOW_WRITES=1. † additionally requires confirm: true.
Develop
pnpm dev # tsdown --watch
pnpm test # vitest
pnpm typecheck
pnpm lint
pnpm formatPublish
pnpm dlx release-it # bump, commit, tag
git push --follow-tags # CI publishes to npm + GHCR from the tagLicense
MIT
Available Tools
7 toolscloudkit_auth_statusCloudKit: Auth StatusARead-only
Report whether this server has a working CloudKit management token, whether writes are enabled, and — when something is missing — exactly what to set. Call this first when a tool you expected is not listed: an absent tool here means missing configuration rather than a bug.
Inputs: no named parameters.
cloudkit_diff_schemaCloudKit: Diff SchemaARead-only
Show what deploying would change: the pending differences between the container's DEVELOPMENT and PRODUCTION schemas, one row per change: ADD, CHANGE_INDEXES, RETYPE, MISSING_IN_DEVELOPMENT (Production keeps it; a deploy cannot remove it) or OTHER (the schemas differ outside any field, e.g. permissions). Read this before cloudkit_deploy_schema. Production is additive-only and irreversible — a field can be added forever, but never removed, renamed or retyped — so a RETYPE is a reason to stop.
Inputs: containerId.
cloudkit_export_schemaCloudKit: Export SchemaARead-only
Export an environment's full schema as a .ckdb document. Returns the text, or writes it to outputPath and reports where it went. Exporting both environments and diffing them locally is one way to review a pending change; cloudkit_diff_schema is the direct one.
Inputs: environment (required), outputPath, containerId.
cloudkit_list_containersCloudKit: List ContainersARead-only
List the CloudKit containers this team can manage, with their ids. Use this to find the container id the other cloudkit_* tools take.
Inputs: no named parameters.
cloudkit_list_record_typesCloudKit: List Record TypesARead-only
List a container environment's record types and their fields. This is how you confirm a newly added field actually reached CloudKit: Core Data and SwiftData prefix everything with CD_, so a Swift property isHidden on Track appears here as CD_isHidden on CD_Track. A field missing from DEVELOPMENT has not been written by any client yet — there is nothing to deploy until one has.
Inputs: environment (required), recordType, containerId.
cloudkit_requestCloudKit: Raw RequestARead-only
Escape hatch: issue an arbitrary CloudKit management API request. The other cloudkit_* tools cover the documented-by-observation routes; this exists because the API is undocumented, so one endpoint being shaped differently than expected should not make the rest unreachable. Prefer a specific tool when one fits. Only GET is available while writes are disabled.
Inputs: path (required), body, method, confirm.
cloudkit_validate_schemaCloudKit: Validate SchemaARead-only
Validate a local .ckdb file against a container environment without importing it. Read-only: it reports whether the schema would be accepted, and changes nothing.
Inputs: filePath (required), environment (required), containerId.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 7 tools
Each specific tool targets a distinct schema operation (list containers, diff, export, validate, list record types), and the descriptions explicitly steer agents away from overlaps (diff vs export, validate vs import). The only real ambiguity is cloudkit_request, a catch-all escape hatch that technically subsumes every other tool, though its description mitigates this by telling agents to prefer specific tools.
All seven tools use the same cloudkit_ prefix followed by a clear snake_case noun/verb label (list_containers, diff_schema, export_schema, validate_schema, auth_status). The pattern is predictable and readable throughout, with no mixed conventions.
Seven tools is well-scoped for a CloudKit schema-management server, with each tool covering a distinct step (auth, discover containers, inspect record types, diff, export, validate, raw request). Nothing feels padded or missing in terms of quantity.
The surface covers inspection, diffing, exporting and validating, but there is no deploy/apply tool — and the descriptions explicitly reference cloudkit_deploy_schema, which is absent here, creating a dead end for the primary write workflow (presumably config-gated by the auth token). Union/import of a .ckdb is also absent, so an agent cannot complete the add-field lifecycle end to end.
Maintenance
Related MCP Connectors
Hosted MCP server for AI-driven data ops. Create apps, manage schemas, and CRUD structured data.
Governed MCP gateway: one endpoint for your tools, with credential custody and audit log.
An MCP server that provides access to Agility CMS. See https://mcp.agilitycms.com for more details.
One MCP URL for all your connectors — scoped writes, enforced constraints, and a full audit trail.
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceEnables AI assistants and automation to inspect, compare, and manage FileMaker schema artifacts via MCP, including exploring objects, tracing references, generating diffs between versions, and automating schema tasks through jobs.1Apache 2.0
- AlicenseNot gradedqualityBmaintenanceEnables secure, read-only inspection and debugging of account-relative CloudKit databases, records, zones, sharing, subscriptions, and change state through policy-scoped MCP tools.45 npmMIT
- AlicenseNot gradedqualityCmaintenanceEnables database querying and modification through an MCP server where each action is gated by human-granted scopes, per-call confirmations for destructive operations, and revocable access.MIT
- AlicenseNot gradedqualityBmaintenanceEnables MCP clients to connect through a single Streamable HTTP endpoint, discover allowed backend servers and tools, inspect schemas, and invoke allowlisted catalog operations with authentication and scope checks.621 npmMIT