Quick Start
Provision Local Auth And Secrets
The TypeScript declarations identify where Fentaris reads API-key hashes and upstream credentials. Provision the values after the project is built:x-fentaris-api-key header.
For CI, provide third-party tokens through the process environment first, then run fentaris secrets setup --non-interactive --yes --json. An incomplete plan exits before changing files and returns SECRETS_SETUP_INCOMPLETE with concrete next actions.
For local development, let the CLI generate FENTARIS_AUTH_KEY in the ignored project .env on the first encrypted write. For deployments, provide it through your secret manager. Keep the same value for later reads and updates, and never commit or include it in an agent response.
credentialJson("users.alice.apiKeys.0") points at the first CLI-managed API-key hash for alice. fentaris auth api-key add alice --generate writes that value; application code must not generate or encrypt it directly.
Team-Governed Proxy
Use this shape when one team proxy serves multiple users and different groups need different upstream permissions:.fentaris/secrets.manifest.json.
App-Level Composition
Use app-level governance declarations when the proxy is assembled across modules or when upstream MCP servers are registered after construction.app.policy(name) is a named policy registry. Repeating the same name returns the same policy instance, and app.group(id).policy(name) resolves that name before Fentaris serves requests.
Fluent groups must include at least one user and a policy before startup. A named policy reference must be declared through
app.policy(name) or Fentaris reports a configuration diagnostic.group({ ... }) form when a group owns credential sources or group-scoped server declarations. The fluent group handle currently configures users, policy, middleware, operations, and events only.
Local auth files
The generated local credential store uses one encrypted file by default:credentials.enc.json is encrypted and stores user API keys plus user, group, and default credential values. New writes use a versioned AES-256-GCM envelope with PBKDF2 key derivation metadata, while legacy SHA-256-derived files are still readable and migrate on the next successful write. On Unix, the file is written with owner-only permissions (0600). Keep it private and rotate the encryption key using your deployment secret process.
On the first encrypted write, the CLI creates a random FENTARIS_AUTH_KEY in the project .env when no key is already configured. Generated dev and start scripts load that file automatically. Projects that do not use encrypted credentials do not need a key.
For deployments or externally managed keys, prefer environment and stdin inputs so secrets do not appear in process arguments:
--key and --value remain available for compatibility, but Fentaris warns because those values can be visible through process inspection.
For agent-created projects, leave secret values for the user to provide after code generation. The CLI can generate the local encryption key during the first credential write; the handoff must list the exact CLI commands and scopes without inventing or printing secret values.
secrets.manifest.json lists required credential references only. Commit this file so teammates know which secrets a project needs without sharing encrypted values.
Server bindings live next to the MCP server declaration in TypeScript:
API-key identity
When users declareapiKeys, Fentaris uses API-key identity by default and requires the configured header. The default header is x-fentaris-api-key.
API keys resolve to declared user ids from encrypted local auth storage. Raw API keys are not exposed to middleware, hooks, logs, or policy callbacks.
Trusted user id headers remain available through headerIdentityStrategy, but they should only be used behind a trusted internal gateway that already authenticated the caller. Do not expose a direct x-user-id identity mode to untrusted clients.
Credential precedence
For an upstream binding such asgithub -> bearer github.token, Fentaris resolves the credential in this order:
- User credential for the authenticated subject.
- Group credential from the subject’s matching groups.
- Default credential.
ctx.credentials.sources, such as { reference: "github.token", source: "group", groupId: "support" }, never the decrypted credential value.
Credential Source Placement
Match the TypeScript source declaration to the scope used byfentaris secrets set:
A global server can resolve user-, group-, or default-scoped credentials for the authenticated subject. A server declared in
group({ servers: [...] }) can resolve user credentials from that group, that group’s credentials, or defaults.
A credential reference validates only when at least one source is visible in the server’s scope or an auth-backed store is configured. Runtime resolution can still fail for a specific subject that has no matching user, group, or default value.
Policy And Runtime Behavior
Keep durable authorization in groups and policies. Use server-scoped tool routes for runtime behavior after policy allows a call. Fentaris fails closed: a tool call or governed capability is denied unless a global policy, matching group policy, or explicit developmentPolicy.allowAll() / allowAll() policy allows it. Deny decisions are terminal and run before call hooks, middleware, routes, or upstream dispatch. If a subject belongs to multiple groups, any explicit deny from one matching group wins over allows from another group.
ctx.subject for resolved subject data and ctx.policy for the effective authorization decision:
ctx.policy.can(server, tool) evaluates allow/deny permissions only. It does not consume rate limits, invoke manual approval callbacks, or expose raw API keys, bearer tokens, decrypted credentials, or environment secret values.
listTools is filtered both before and after list hooks. Synthetic tools added by onListTools or tools:list:after must use the normal <server>__<tool> proxy name and match policy, or they are hidden from the final response.
Local Namespace Policy
Local capabilities declared withapp.local(name) are authorized through the same .mcp(name) policy namespace as upstream MCP servers.
tools/list, resources/list, resources/templates/list, and prompts/list. Denied execution returns before the local handler runs.
Capability Permissions
Tool permissions are still supported, but Fentaris also accepts operation-based capability permissions for proxied resources, prompts, and completion.resource:*, prompt:*, and completion:* events with start, success, error, and after phases. Audit logs include operation, subject, server, target, policy outcome, and credential source metadata.
Migration From Tool Policies
Existing tool policy declarations continue to work:tool:call capability permissions. Existing ToolPermission, SimplePolicy, Policy.evaluate(...), group policy, middleware, and ctx.policy.can(server, tool) behavior remain compatible for tool calls. Add allowCapability(...) or denyCapability(...) only when you need to govern resources, resource templates, prompts, or completion.
CLI Helpers
Preferred workflow for local encrypted credentials:fentaris secrets list shows credential reference names and scopes only. Secret values are never printed.
.fentaris/secrets.manifest.json is the committed schema: reference names, scopes, source kinds, and API-key requirements with no values. Regenerate it after changing credential declarations in your entrypoint:
fentaris secrets manifest --check in CI to fail when the manifest is out of date.
Low-Level API
The class constructors remain available for compatibility and advanced embedding. Preferfentaris(...), mcp(...), streamableHttp(...), group(...), user(...), and policy(...) for new applications.