This page captures the unified credential workflow. It summarizes how CLI, API, and MCP surfaces resolve secrets, the aliasing rules that keep behavior consistent, and concrete examples you can copy into your own smoke tests.
Key Conceptsο
Single entry point β Every surface funnels through
zyra.connectors.credentials.resolve_credentials, so literals, environment variables, and manager lookups all behave the same way.Safe logging β
ResolvedCredentials.maskedkeeps audit trails redacted, whileapply_http_credentialsand related helpers never emit plaintext in validation traces.Alias aware β Username/password slots honor
user,username,basic_user(andpassword/basic_password) throughresolve_basic_auth_credentials, so older flags like--usercontinue to work.Header injection β Any credential key prefixed with
header.,header:orheader_is converted into an HTTP header. Keys with neither prefix remain structured data for downstream tools.
Resolution Flowο
Literal values β
--credential api_key=abc123uses the value as-is.Environment variables β Prefix with
$:--credential token=$API_TOKEN.Credential manager entries β Prefix with
@:--credential password=@FTP_PASSWORD. When the manager is not preloaded, pass--credential-file secrets.envor configure the default manager namespace.Validation β Missing or empty secrets raise
CredentialResolutionErrorbefore any network calls run.
CLI Usage Patternsο
Acquire over HTTP(S)ο
# Bearer token supplied via environment variable and expanded into headers
export API_TOKEN="abc123"
zyra acquire http https://httpbin.org/headers \
--credential token=$API_TOKEN \
--credential header.Authorization="Bearer $API_TOKEN" \
--output headers.json
Acquire over FTPο
# Credentials can come from a dotenv file for repeatable jobs
zyra acquire ftp ftp://dataserver.example.com/public/report.txt \
--credential-file secrets.env \
--credential user=@FTP_USER \
--credential password=@FTP_PASS \
--output report.txt
Disseminate via HTTP POST (legacy decimate/post)ο
# Header aliases keep structured JSON clean while still sending auth headers
zyra disseminate post results.json https://api.example.com/upload \
--credential header.Authorization=@ANALYTICS_BEARER \
--credential header.Content-Type="application/json"
Disseminate over FTPο
zyra disseminate ftp -i artifact.bin ftp://dataserver.example.com/outbox/artifact.bin \
--credential-file secrets.env \
--credential user=@FTP_USER \
--credential password=@FTP_PASS
Discovery Search APIsο
# Query an authenticated search endpoint with the same credential semantics
zyra search api --url https://catalog.example/api \
--query "hrrr" \
--credential token=$CATALOG_TOKEN \
--auth bearer:$CATALOG_TOKEN
# Override credentials for a specific endpoint while keeping global defaults
zyra search api \
--url https://catalog.example/api \
--url https://staging.example/api \
--query "wind" \
--credential token=$GLOBAL_TOKEN \
--url-credential https://staging.example/api token=$STAGING_TOKEN
# Echo a header end-to-end (httpbin)
zyra acquire api \
--url https://httpbin.org/anything \
--method GET \
--auth bearer:demo-token \
--output - | head
# Authenticated discovery against GitHub
export GITHUB_USER="your-username"
export GITHUB_TOKEN="ghp_yourtoken"
zyra search api \
--url https://api.github.com \
--query placeholder \
--endpoint search/repositories \
--qp q \
--param q=language:python \
--result-key items \
--auth basic:$GITHUB_USER:$GITHUB_TOKEN \
--limit 3 \
--json
API & MCP Integrationο
Domain args normalization β REST clients can POST either
{"headers": {"X-Api-Key": "..."}}or the CLI-style list{"header": ["X-Api-Key: ..."]}. The API layer flattens both into the same list before invoking the worker, so credentials resolve exactly like the CLI.Credential echo suppression β OpenAPI validation, MCP capability manifests, and FastAPI responses operate on sanitized header maps, ensuring bearer tokens never appear in logs or schema dumps.
Example JSON payload
{
"stage": "acquire",
"tool": "http",
"args": {
"url": "https://httpbin.org/basic-auth/demo/secret",
"credentials": {
"basic_user": "demo",
"basic_password": "secret"
},
"headers": {
"X-Request-ID": "{{$uuid}}"
}
}
}
Testing Tipsο
Use
poetry run pytest -q tests/connectors/test_acquire_api_auth.pyto cover HTTP credential combinations.FTP flows are covered by
tests/connectors/test_ftp_backend.py; add cases there when introducing new aliases.Regenerate the wizard manifest (
poetry run python -m zyra.utils.generate_capabilities) after adding CLI flags that expose new credential slots.
Troubleshootingο
Missing env vars β The helper raises
CredentialResolutionErrorwith the variable name when$ENVlookup fails.Unexpected headers β Run
poetry run zyra acquire http ... --traceto see sanitized headers, or addZYRA_VERBOSITY=debugfor extra logging.Credential manager scope β Pass
--credential-fileexplicitly during smoke tests so@KEYreferences resolve without relying on host configuration.
This page should evolve alongside connector workβupdate it whenever you add a new credential alias or surface (e.g., discovery connectors) so downstream teams can rely on a single source of truth.