Repository navigation
Description
Goal
Design a shared Mecatl-wide secret-management capability for both explicitly supplied credentials (such as API keys and static MCP bearer tokens) and system-managed read/write credentials (such as OAuth refresh credentials). This is forward-looking design work, not a requirement to expand the current static-secret resolver in PR #2583.
Current state
Secret handling is split across subsystems:
internal/cliconfig/secret.go: a narrow startup-time static-secret resolver.CredentialSourcecaptures environment values and resolves MCP bearer references with environment precedence over the selectedauth.yaml. It is not a general secret store or OAuth lifecycle manager.internal/adapter/credentialstore: shared namespace-bound opaque records, read-onlyReader, conditional-writeStore, and environment/encrypted-file/plaintext-file implementations.internal/adapter/clientauth: client-auth storage selection and OS-keyring-backed encryption-key custody, with a plaintext-file fallback.internal/adapter/mcpcredential: separate MCP OAuth storage and encryption-key custody.internal/adapter/toolhivellm: delegates LLM credential storage and refresh to ToolHive's scoped system secret provider; Mecatl retains references rather than token values in ToolHive configuration.
These provide useful building blocks, but they are not one consistently wired, cross-subsystem capability. There is no current general Vault/cloud secret-manager/Kubernetes Secret API backend.
Proposed direction
Establish a shared port/adapter capability, building on existing abstractions rather than adding another competing store interface. Separate:
- Storage: opaque secret reads and, where supported, conditional create/update/delete; namespaces and explicit backend capabilities.
- Resolution and policy: logical references, explicitly supplied credentials, environment precedence, backend selection, availability/failure behavior, and read-only versus read/write sources.
- Credential lifecycle: subsystem-owned OAuth login, refresh, expiry, scopes, and rotation. Sharing storage must not centralize or flatten these lifecycle contracts.
Cover both operator-provided API keys/static credentials and machine-managed structured credential records, not only bearer-token strings. Keep values out of settings, diagnostics, errors, and public projections; retain reference-based configuration.
Design questions and constraints
- Evaluate OS keyring, encrypted local storage, and future external secret-manager adapters behind the shared capability. Preserve ToolHive's ownership and scopes; do not copy externally owned secrets merely to unify APIs.
- Include an explicit private-file fallback. Evaluate whether a read/write
auth.yamlcan safely hold broader credential records, or whether operator-edited static secrets and frequently rewritten machine-managed records should use separate files behind the same capability. Do not assume a single YAML file is the goal. - Define file ownership/permissions, atomic writes, cross-process concurrency/CAS, manual-edit behavior, schema/version migration, deletion, and secret rotation. Reuse existing record-store guarantees where appropriate.
- Distinguish an intentionally selected/allowed file fallback from backend failure. A configured keyring or remote manager failure must not silently downgrade to plaintext or anonymous access.
- Preserve current credential-source precedence, selected-file provenance, missing-versus-empty semantics, startup snapshots where promised, and headless/remote ownership boundaries. Avoid unrelated secret acquisition.
- Assess migration from current client-auth, MCP OAuth, static provider/MCP, and ToolHive paths, including existing encrypted data and key custody. Cross-subsystem sharing must not weaken isolation.
Expected outcome
A reviewed design and incremental migration plan describing the shared boundary, backend capabilities and policy, fallback/storage representation, credential ownership, compatibility, and offline verification. Include tests for precedence, read-only backends, concurrent rotation, failure/no-downgrade behavior, and redaction before migrating consumers.
Related: #2577 / #2583 (static MCP credentials in auth.yaml), #1685 (CLI-managed MCP setup).
Activity
docs(cliconfig): clarify static secret resolver scope