Repository navigation
Harden Zedcloud SDK: generator rewrite, multi-tenant auth, helpers, and guarded MCP server - #2
Merged
Merged
Conversation
Introduce a uv/hatchling workspace with: - zedcloud: typed httpx + Pydantic v2 client generated from committed OpenAPI swagger specs (11 services), with retries, ApiError types, Bearer + X-API-KEY auth, and pagination helpers - zedcloud-automation: pytest fixtures, markers, and read-only smoke tests - zedcloud-mcp: stdio MCP server exposing focused nodes/apps/networks/k8s/jobs tools - codegen script, Makefile, CI (ruff + mocked tests), MIT license, docs Co-authored-by: vignesh-zededa <vignesh-zededa@users.noreply.github.com>
Remove shared tests/__init__.py packages that collided across members and use --import-mode=importlib for the monorepo. Co-authored-by: vignesh-zededa <vignesh-zededa@users.noreply.github.com>
- Drop typing.Self (3.11+) so the package imports on the declared 3.10 floor. - Only replay 5xx responses for idempotent methods; POST/PUT/DELETE are retried only on 429 or connection failures where the server never saw the request, preventing duplicate creates or repeated reboots. - Percent-encode path parameters so values containing '/', '?' or '#' cannot escape their path segment and reach other endpoints. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Generator (scripts/generate.py, replaces datamodel-codegen pipeline): - Merge the 11 specs' definitions into one models module (191 shared definitions were emitted 11 times as distinct classes); conflicts fail. - Tolerant response models: all fields optional, unknown fields kept and round-tripped, open enums accept server-added values, lenient timestamps, spec patterns not enforced. Fixes ValidationErrors on real responses. - Hoist gRPC-gateway inline update bodies into typed *Body models (42 of 121 bodies were previously dict | Any). - Readable method names via override table; collisions fail generation. - Keyword-only optional args, pagination params renamed (page_size, ...), docstrings with parameter docs and read/write/destructive labels. - Typed iter_* methods for all paginated list operations. - Multipart upload support (formData params were silently dropped). - Sync and async classes per service; operations.json registry. - --check mode for CI; scripts/fetch_specs.py refreshes openapi/. Runtime: - Sync and async transports with idempotency-aware retries, jittered backoff, per-call X-Request-Id, debug logging without secrets. - Username/password login with automatic re-login on 401, optional enterprise selection; token auth; X-API-KEY for the Kubernetes service. - Multi-tenant profiles (TOML) with env/command/keyring secret sources. - Error hierarchy that surfaces Zedcloud error codes and details. - client.call(operation_id, ...) and zedcloud.operations search/registry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Generate lookup_* (name-or-ID) for all 45 resources exposing /id/{id}
and /name/{name} GETs; UUID-shaped values fall back to name on 404.
- wait_for_edge_node / wait_for_app_instance / wait_for_job (sync+async)
on generic zedcloud.waiters, with fail states and WaitFailedError.
- lookup_project alias for resource groups.
- zedcloud CLI: profiles, whoami, ops search/show, call (writes need --yes).
- Profiles file default now applies when no environment config is set.
- zedcloud-automation: --zedcloud-profile option, config fixture, and
integration tests skip unless the profile sets allow_writes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Tenants from the zedcloud profiles file: list_tenants / use_tenant / whoami, optional tenant on every tool, tenant echoed in every result. - Task tools: fleet_health, list/get edge nodes and app instances, list_projects, recent_events, get_job; compact, redacted outputs. - Full API reach: search_operations, describe_operation, describe_model, call_read_operation (read-only operations only). - Writes: plan_write_operation validates, fetches the target, merges partial updates onto the current object, diffs fields, flags destructive ops, and stores the exact request under a single-use, expiring token; execute_write_operation runs only that stored plan, asks the user via elicitation when supported, and audit-logs to JSONL. - Writes require allow_writes on the profile; --read-only and --require-human-approval flags; MCP SDK >= 2.2 (MCPServer API). - Docs: README, getting started, architecture, MCP safety model. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
Builds on the initial SDK from
cursor/zedcloud-python-sdk-5998(included in this PR, sincemainonly has the README) and makes it safe for real tenant automation and chat-driven use through MCP.1. Bug fixes (
4a93fde)import zedcloudfailed on Python 3.10 (typing.Self), although 3.10 is the declared minimum and is in CI.get_edge_node_by_name("x/../../v1/users")requested a different endpoint.2. Generator rewrite (
5dfb811)ValidationError.dict | Any), readable method names, keyword-only arguments, docstrings with a risk label, and multipart uploads (3 upload endpoints were unusable).operations.jsonregistry,--checkmode in CI, andscripts/fetch_specs.py.3. Runtime (
5dfb811)X-Request-Idon every call.4. Helpers (
d764e32)iter_*for 56 paginated lists andlookup_*(name or ID) for 45 resource types.wait_for_edge_node,wait_for_app_instanceandwait_for_job.zedcloudCLI:profiles,whoami,ops search/show, andcall(writes need--yes).--zedcloud-profile, and integration tests skip unless the profile setsallow_writes.5. MCP server (
21a3630)plan_write_operationpreviews the change (merged update and field diff) and returns a single-use, expiring token.execute_write_operationruns exactly that stored request, asks the user via elicitation when the client supports it, and writes to a JSONL audit log with secrets redacted.allow_writes.--read-onlyand--require-human-approvalflags are available.Test plan
scripts/generate.py --check.uv run pytest -m smoke --zedcloud-profile <profile>.Assumptions still to confirm against a live tenant
usernameAtRealm(orusername+realm).X-API-KEYdefaults to the session token.next.pageNumstarts at 1 andtotalPagesis reliable.🤖 Generated with Claude Code