This guide explains how to set up authentication for Substack MCP Plus. Our enhanced authentication system provides a foolproof setup that handles everything automatically, including CAPTCHA challenges and token management.
The easiest way to set up authentication is using our interactive setup wizard:
python setup_auth.pyThis wizard will:
- ✅ Ask how you want to sign in (magic link or password)
- ✅ Request your Substack email
- ✅ If using password, ask for your password
- ✅ Open a browser window for secure login
- ✅ Handle CAPTCHA challenges if they appear
- ✅ Extract and securely store your session token
- ✅ Test the connection automatically
- ✅ Configure everything for you
That's it! No manual token extraction, no dealing with browser developer tools, no configuration files to edit.
- Substack sends a 6-digit code to your email
- Enter the code in the browser when prompted
- No password needed - more secure!
- Traditional email + password login
- The wizard automatically clicks "Sign in with password"
- Faster if you have your password ready
Our authentication system uses a three-tier approach for maximum reliability:
-
Secure Token Storage (Primary)
- Tokens are encrypted and stored in your system keyring
- Automatically used when available
- Checked for expiration and refreshed as needed
-
Environment Variables (Fallback)
- Supports traditional environment variable configuration
- Useful for CI/CD environments
-
Automatic Fallback (Seamless)
- If stored token fails, tries environment variables
- Provides clear guidance if re-authentication is needed
After running setup_auth.py, you only need to provide the publication URL in your Claude Desktop config:
{
"mcpServers": {
"substack-mcp-plus": {
"command": "python",
"args": ["-m", "src.server"],
"env": {
"SUBSTACK_PUBLICATION_URL": "https://yourpublication.substack.com"
}
}
}
}No passwords or tokens in the config! Authentication is handled automatically.
- Secure Storage: Tokens are encrypted using your system's keyring
- Expiration Tracking: Monitors token age and prompts for refresh
- Cache Management: Reuses authenticated sessions for performance
- Clear Error Messages: Helpful guidance when authentication fails
If needed, simply run the setup wizard again:
python setup_auth.pyIt will detect existing authentication and ask if you want to replace it.
If you prefer traditional environment variables (e.g., for CI/CD):
Create a .env file:
SUBSTACK_EMAIL=your-email@example.com
SUBSTACK_PASSWORD=your-password
SUBSTACK_PUBLICATION_URL=https://yourpublication.substack.comOr set them in your shell:
export SUBSTACK_EMAIL="your-email@example.com"
export SUBSTACK_PASSWORD="your-password"
export SUBSTACK_PUBLICATION_URL="https://yourpublication.substack.com"If you already have a session token:
SUBSTACK_SESSION_TOKEN=s%3AYourLongSessionTokenHere...
SUBSTACK_PUBLICATION_URL=https://yourpublication.substack.comSolution: Run python setup_auth.py
The setup wizard handles CAPTCHA automatically. If you still have issues:
- Clear your browser cookies for substack.com
- Try using magic link authentication instead of password
- Log in manually once in your browser
- Wait 5 minutes
- Run
python setup_auth.pyagain
Solution: Run python setup_auth.py to refresh
- Verify your email is correct
- If using password auth, verify your password is correct
- Try using magic link authentication instead
- Check that your publication URL includes
https:// - Ensure you have access to the publication
- Never commit credentials to version control
- Use the setup wizard for the most secure configuration
- Tokens are encrypted in your system keyring
- Enable 2FA on your Substack account
- Rotate passwords periodically
Tokens are stored using:
- Keyring: OS-level secure credential storage
- Encryption: Additional layer using Fernet symmetric encryption
- Metadata: Expiration tracking and email association
The system tries authentication in this order:
- Stored token (from setup wizard)
- Environment session token
- Email/password from environment
- Clear error with setup instructions
- Tokens are set to expire after 30 days
- System checks for expiration before each use
- Automatic refresh reminders at 7 days before expiry
- Future updates will support automatic refresh
For 99% of users, just run:
python setup_auth.pyFollow the prompts, and you're done! The system handles everything else automatically.