Multi-account orchestration and secure token storage for OAuth-based MCP servers
npm install @mcp-z/oauthDocs: https://mcp-z.github.io/oauth
Multi-account OAuth orchestration and token storage for MCP servers.
- Add consistent account tools to MCP servers
- Store OAuth tokens with a shared config and storage backend
- Reuse the same account lifecycle across Google and Microsoft providers
``bash`
npm install @mcp-z/oauth
Optional storage backends:
`bash`
npm install keyv-duckdb
npm install keyv-file
`bash`
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-switch
- account-remove
- account-list
-
When using stateless auth (DCR/bearer tokens), only this tool is available:
- account-me
`ts
import { 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.
- Node.js >= 22