Add MCP health check and profile lookup helpers - #19
anhtahaylove wants to merge 2 commits into
Conversation
…roxyShard#19) Snapshot download previously read the whole blob (up to 512 MiB) into a Vec<u8> before returning, with no concurrency cap — a burst of lock holders pulling at once could exhaust server memory/bandwidth. Server (server/src/routes/locks.rs, blob.rs, state.rs, main.rs): - Stream the blob straight from disk via tokio_util ReaderStream + axum Body::from_stream instead of buffering it. - New download_slots semaphore (8) mirrors upload_slots: acquire a permit AFTER the ACL + lock-token + row-existence checks (so an unauthorized/non-holder request can't consume a slot), then move it into a GuardedReader that owns it for the whole streamed transfer — released when the stream drains or the client disconnects. 429 + Retry-After when saturated. - Defense-in-depth: verify the on-disk blob length matches the recorded snap.size before streaming, so corruption/tampering fails loudly rather than serving a body that contradicts Content-Length. - Advertise Content-Length from snap.size. Launcher (src-tauri/src/sync.rs): - download() retries a 429 up to 5 attempts, honoring a clamped (1..=10s) Retry-After, before surfacing an error — so a transient download-slot saturation degrades to a short wait instead of aborting the launch. The LeaseGuard keeps renewing across the wait. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
9849a05 to
332720c
Compare
332720c to
4401ba4
Compare
|
Tidied my open PRs here against current Closed as superseded (each with the specific reason on the PR):
Still open, rebased onto current
Verification on my side: No rush from my side — flagging only because all three are small and independent, so they can be taken in any order or declined individually. One unrelated note: |
Summary
health_checkfor ShardX Launcher API reachability/auth checksfind_profile_by_nameto locate profiles by id/name without returning full fingerprint configensure_profile_startedto idempotently resolve/start a profile and return its CDP endpointsafe_open_urlto resolve/start a profile, open anhttp(s)URL, and return title/url for MCP smoke checksSHARDX_API/SHARDX_TOKENfrom Windows user environment when stdio clients strip custom env varsWhy
These helpers make MCP clients safer to bootstrap and automate against ShardX Launcher:
SHARDX_TOKENis valid before mutating callsThis PR intentionally does not change browser engine behavior, fingerprint behavior, profile isolation, or the launcher API contract.
Test
node --check mcp/index.jshealth_checkauthenticated with token from Windows user env fallbackfind_profile_by_namefoundVN Automation 001 - No Proxyensure_profile_startedreturned an existing CDP endpointsafe_open_urlopenedhttps://example.com/and returnedExample Domainsafe_open_urlrejectedfile://...withsafe_open_url only supports http(s) URLs