Documentation Index
Fetch the complete documentation index at: https://mintlify.com/nicobailon/pi-mcp-adapter/llms.txt
Use this file to discover all available pages before exploring further.
Authentication Types
Pi MCP Adapter supports two authentication methods for HTTP-based MCP servers:- Bearer Token - Static token passed in the
Authorizationheader - OAuth - OAuth 2.0 flow with token storage and manual refresh
Bearer Token Authentication
Direct Token
Provide the bearer token directly in the configuration:Set to
"bearer" to enable bearer token authenticationThe actual bearer token value
Environment Variable
Reference an environment variable containing the token:Name of the environment variable containing the bearer token
How Bearer Tokens Work
The adapter adds the token to every HTTP request:OAuth Authentication
Configuration
Set to
"oauth" to enable OAuth authenticationOAuth Flow
Obtain Tokens Externally
Pi MCP Adapter does not provide a browser-based OAuth flow. You must obtain tokens through the provider’s OAuth process externally (e.g., via their web interface, CLI tool, or authorization endpoint).
Token Storage Format
Tokens are stored in:The OAuth access token
Token type (usually
"bearer")OAuth refresh token (optional, not currently used for automatic refresh)
Token lifetime in seconds (optional)
Absolute expiration timestamp in milliseconds (optional). If set, the adapter checks expiration before using the token.
Token Expiration
The adapter checks token expiration ifexpiresAt is present in the token file:
Automatic token refresh is not currently implemented. When tokens expire, you must manually refresh them and update the
tokens.json file.Manual Token Refresh
When your OAuth tokens expire:Update Token File
Replace the contents of
~/.pi/agent/mcp-oauth/<server-name>/tokens.json with the new tokensCustom Headers
For servers that require additional authentication headers beyond OAuth or bearer tokens:Custom HTTP headers included in every request
Header values support
${VAR} environment variable interpolation, just like the env field.Complete Examples
Security Best Practices
Recommendations
-
Use environment variables for all tokens and keys:
-
Protect token storage directory:
- Rotate tokens regularly even if they haven’t expired
- Use least-privilege tokens with only the permissions needed for the MCP server
- Monitor token expiration and set up reminders to refresh before expiry
Troubleshooting
Server Shows “needs-auth” Status
OAuth servers:- Check if
~/.pi/agent/mcp-oauth/<server>/tokens.jsonexists - Verify the token file has valid JSON format
- Check if
expiresAttimestamp has passed - Refresh tokens and update the file
- Verify the environment variable is set:
echo $API_TOKEN - Check that the token value is correct
- Ensure
bearerTokenEnvmatches the actual variable name
Token Validation Errors
The adapter requiresaccess_token to be present and non-empty:
Automatic Refresh Not Working
This is expected behavior. Automatic token refresh is not currently implemented. You must manually refresh tokens when they expire.
Limitations
- No browser-based OAuth flow - Tokens must be obtained externally
- No automatic token refresh - Manual refresh required when tokens expire
- Refresh tokens are stored but not used - Future feature
- No cross-session token sharing - Each Pi session manages its own tokens
Next Steps
Server Setup
Configure MCP servers with different transports
Global Settings
Set defaults for toolPrefix, idleTimeout, and directTools