Docs: https://mcp-z.github.io/oauth Multi-account OAuth orchestration and token storage for MCP servers.
npm install @mcp-z/oauth
Optional storage backends:
npm install keyv-duckdb
npm install keyv-file
npx @mcp-z/oauth init
This creates a .tokens/ directory and a default config file for token storage.
Use AccountServer to add account tools to your MCP server.
When using loopback OAuth, these tools are added:
account-meaccount-switchaccount-removeaccount-listWhen using stateless auth (DCR/bearer tokens), only this tool is available:
account-meimport { AccountServer } from '@mcp-z/oauth';
const { tools, prompts } = AccountServer.createLoopback({
service: 'gmail',
store: tokenStore,
logger,
auth: authProvider
});
Use sanitizeForLoggingFormatter to avoid leaking secrets in logs.