Authentication Methods
| Method | Use Case | How It Works |
|---|---|---|
| OAuth | Interactive login, user-scoped access | Prompted automatically when server requires it |
| Bearer Token | Static tokens, API keys | Enter when prompted |
| Public | No authentication needed | No configuration required |
OAuth Authentication
For servers that support OAuth, Craft Agents detects this automatically and initiates the flow:- Craft Agents detects the server needs authentication
- A browser window opens for you to authorize access
- After approval, you’re redirected back to the terminal
- The OAuth token is stored securely for future use
Token Refresh
OAuth tokens are automatically refreshed when they expire. If a refresh fails, you’ll be prompted to re-authenticate.Bearer Token Authentication
For servers that use static API keys or bearer tokens, you have two options:Prompted Entry (Recommended)
Just specify the server URL - Craft Agents prompts you for credentials when needed:~/.craft-agent/credentials.enc, not in your Craft document.
Include in Configuration
Alternatively, add the token directly in the headers:Public Servers
Some MCP servers don’t require authentication:Credential Management
Viewing Stored Credentials
You can’t view the actual credential values, but you can see what’s stored:Removing Credentials
To clear credentials for a specific agent, remove and re-add the agent, or use/logout to clear all credentials.
Credential Scoping
Credentials are scoped hierarchically:- Different workspaces have separate credentials
- Different agents can have different access to the same service
- Removing an agent removes its credentials
Example: Multi-Auth Agent
An agent connecting to multiple servers with different auth methods:Troubleshooting Authentication
OAuth window doesn't open
OAuth window doesn't open
- Check your default browser is working
- Try running
craftfrom a terminal with GUI access - Firewall may be blocking the local callback server (port 8914)
Token rejected by server
Token rejected by server
- Verify the token has required permissions/scopes
- Check if the token has expired
- Confirm the server URL is correct
Re-authenticate after it was working
Re-authenticate after it was working
- Token may have been revoked
- Credentials file may have been corrupted
- Try
/logoutand set up again
Wrong account authenticated
Wrong account authenticated
- Clear credentials with
/logout - Re-authenticate with the correct account
- Check you’re logged into the right account in your browser
Security Best Practices
Prefer OAuth over static tokens
Prefer OAuth over static tokens
OAuth tokens can be scoped, revoked, and rotated. Static tokens are harder to manage securely.
Use prompted tokens instead of inline
Use prompted tokens instead of inline
Omit the
headers with tokens and let Craft Agents prompt you - this avoids storing secrets in Craft documents.Limit token scopes
Limit token scopes
When creating API keys or authorizing OAuth, grant only the permissions the agent needs.
Rotate credentials periodically
Rotate credentials periodically
For sensitive services, periodically clear and re-enter credentials to ensure they’re current.