sylphx
The Sylphx SDK for Rust: one API (https://api.sylphx.com), one key, one
namespace per service.
[]
= "0.1"
= { = "1", = ["macros", "rt-multi-thread"] }
async
- Every service is a namespace (
sx.data(),sx.hosting(), …) and every collection a type on it (sx.data().databases()), with the standard methodsget,list,create,update,deleteand each custom method. - Mutations of reconciled Resources return an
Operation;.wait().awaitreturns the settled Resource. - Errors are
sylphx::Error::Api { code, status, retryable, effect, detail, request_id, .. }from the one RFC 9457 problem body. - The client retries retryable answers with full-jitter backoff, honours
Retry-After, and sends oneIdempotency-Keyper logical mutation.Client::with_deadline(instant)returns a copy whose calls share that one absolute budget: requests and retries alike must finish by it, a retry that would start past it returns the last answer instead (so its server message reaches the caller), and it never widens a shorter per-calltimeout— whichever deadline ends first bounds the call. The default HTTP client has a 5 s connect timeout and a 120 s whole-call budget. Local socket deadlines include response bodies and retries on every origin, including Data; protocol calls still omit Resource API headers. A supplied HTTP client should set its own connect timeout; the transport still enforces the configured or default whole-call budget. Client::invoke("data.databases.get", json!({"name": "…"}))calls any method by id with wire JSON.- Sylphx Data's objects, key-value entries (strings, counters, hashes, lists,
sorted sets, scan, expiry), and search documents (
sx.data().objects(),sx.data().kv(),sx.data().documents(),sx.data().search()) are served athttps://api.data.sylphx.comwith the same key; each call carries oneSylphx-Effect-Id, reused on its retries. SYLPHX_URLandSYLPHX_SECRET_URL(per-project<project>.api.sylphx.comhosts, retired on 2026-09-03) are not read; a base URL on such a host is ignored with a warning.
Typed flags with offline defaults
let mut context = default;
context.user_id = "alice".into;
let mut flags = sx.flags;
let enabled = flags.bool.await;
let layout = flags.string.await;
let limit = flags.number.await;
let settings = flags.json.await;
Each call evaluates through the existing Config API. Keep the handle for that environment and subject: when the API is unreachable it serves its last successful evaluations held in memory, or the call-site default without a cache. Missing flags and scalar type mismatches also return the default. A new handle has no cache; use separate handles for separate environments and subjects.
Protecting an MCP server with Sylphx Auth
With the default resource feature,
sylphx::auth::resource::ProtectedResource makes your server an OAuth
protected resource of a Sylphx Auth instance (MCP authorization spec, RFC 9728,
RFC 6750, RFC 7662, RFC 8707): it serves the protected-resource metadata
(metadata_response() at metadata_path()), validates Authorization: Bearer
tokens by introspection with your own confidential OAuth client (tokens are
accepted only when active, for your resource, from your issuer, Bearer type
and unexpired; positive answers are cached for at most 60 s), and builds the
401/400/403/503 challenges (Challenge::reply()). It is framework-agnostic: it
returns a status, headers and body, so mounting it in axum, hyper or actix
takes a few lines (see the module documentation).
Set-up: register your server's own confidential client in the Auth instance
with resource_uri set to the server's canonical URI (exactly the
SYLPHX_RESOURCE_URI you configure here) and scopes set to the scopes it
serves; SYLPHX_AUTH_ISSUER is the instance's Account Portal origin
(https://{slug}.auth.sylphx.net or its verified custom origin). MCP clients
then sign users in there with PKCE, and their tokens are bound to your URI.
let rs = from_env?; // SYLPHX_RESOURCE_URI, SYLPHX_AUTH_ISSUER, ...
match rs.authorize.await
This crate is generated from the Sylphx schema registry by sylphx-gen; do
not edit it by hand. Source: clients/rust in the Sylphx monorepo, published
from its MIT mirror.
Identifier-first Auth
With the default http feature, sylphx::auth::client::AuthClient exposes
r#continue(ContinueRequest) and continue_verify(ContinueVerifyRequest).
Construct it with AuthClient::new(publishable_key, original_user_agent);
never pass a secret key. Both calls forward the browser's original User-Agent,
which binds the flow. Use the same client/header for both calls.
ContinueRequest::default() uses SessionMode::Server. Continue returns
ContinueResponse::Password or EmailOtp { flow, expires_in }. Use
method: Some(ContinueMethod::EmailOtp) for an explicit email fallback.
Verification returns ContinueVerifyResponse::Ticket { ticket, expires_in } in
server mode; redeem the ticket on your backend with the secret key, forwarding
the same User-Agent, and store the resulting bearer in an HttpOnly cookie.
Only explicit SessionMode::Browser returns ContinueVerifyResponse::Session.
ContinueVerifyRequest carries flow, code, and optional factor_proofs.
AuthClientError::MfaRequired preserves the 401 error; retry the same flow with
TOTP or recovery-code proofs. AuthClientError::RateLimited preserves 429 and
AuthApiError::retry_after_seconds from Retry-After (or JSON retry_after).
The client does not replay these single-use mutations automatically.