Security & Authentication
By default, the S3 Documentation MCP server runs in open access mode for easy local development. For shared or remote deployments, enable API key authentication.
Authentication Overview
Section titled “Authentication Overview”Open Access (Default)
Section titled “Open Access (Default)”ENABLE_AUTH=false- ✅ No authentication required
- ✅ Perfect for local development
- ⚠️ Not recommended for shared networks or remote access
API Key Authentication
Section titled “API Key Authentication”ENABLE_AUTH=trueMCP_API_KEY=your-secret-key-here- ✅ All endpoints require valid API key (except
/health) - ✅ Supports multiple authentication methods
- ✅ Secure for shared/remote deployments
Enabling Authentication
Section titled “Enabling Authentication”1. Generate a Strong API Key
Section titled “1. Generate a Strong API Key”Use a cryptographically secure random key:
# macOS/Linuxopenssl rand -hex 32
# Output example:# 3f7a8b2c9d4e1f6g8h5i7j9k0l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6a7b8c9d0Or use a password manager to generate a strong random string.
2. Configure Environment
Section titled “2. Configure Environment”Edit your .env file:
# Enable authenticationENABLE_AUTH=true
# Set your API keyMCP_API_KEY=3f7a8b2c9d4e1f6g8h5i7j9k0l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6a7b8c9d03. Restart the Server
Section titled “3. Restart the Server”# Docker Composedocker-compose restart
# From sourcenpm startUsing Authentication
Section titled “Using Authentication”Method 1: Authorization Header (Recommended)
Section titled “Method 1: Authorization Header (Recommended)”Send the API key in the Authorization header as a Bearer token:
curl -H "Authorization: Bearer your-secret-key" \ http://localhost:3000/mcpWhy recommended?
- ✅ More secure (not logged in URLs)
- ✅ Standard HTTP authentication pattern
- ✅ Not visible in browser history or server logs
Method 2: Query Parameter
Section titled “Method 2: Query Parameter”Send the API key as a URL parameter:
curl "http://localhost:3000/mcp?api_key=your-secret-key"Use when:
- Browser-based testing
- Tools that don’t support custom headers
- Quick debugging
⚠️ Note: Query parameters appear in logs and browser history.
MCP Client Configuration
Section titled “MCP Client Configuration”Cursor
Section titled “Cursor”Edit ~/.cursor/mcp.json:
{ "mcpServers": { "doc": { "type": "streamable-http", "url": "http://127.0.0.1:3000/mcp", "headers": { "Authorization": "Bearer your-secret-key" }, "note": "S3 Documentation RAG Server with authentication" } }}Claude Desktop
Section titled “Claude Desktop”Edit your Claude Desktop configuration file:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%/Claude/claude_desktop_config.json
{ "mcpServers": { "doc": { "type": "streamable-http", "url": "http://127.0.0.1:3000/mcp", "headers": { "Authorization": "Bearer your-secret-key" }, "note": "S3 Documentation RAG Server with authentication" } }}Protected Endpoints
Section titled “Protected Endpoints”When authentication is enabled:
Protected
Section titled “Protected”POST /mcp- MCP protocol endpoint- All MCP tools (
search_documentation,refresh_index,get_full_document) - All MCP resources (
resources/list,resources/read)
Public (No Auth Required)
Section titled “Public (No Auth Required)”GET /health- Health check endpoint
Error Responses
Section titled “Error Responses”Missing API Key
Section titled “Missing API Key”{ "error": "Unauthorized", "message": "Missing API key"}HTTP Status: 401 Unauthorized
Invalid API Key
Section titled “Invalid API Key”{ "error": "Unauthorized", "message": "Invalid API key"}HTTP Status: 401 Unauthorized
Best Practices
Section titled “Best Practices”API Key Management
Section titled “API Key Management”- ✅ Use strong, randomly generated keys (32+ characters)
- ✅ Store keys securely (e.g., in environment variables, not in code)
- ✅ Rotate keys periodically
- ✅ Use different keys for different environments (dev, staging, prod)
- ❌ Never commit keys to version control
- ❌ Never share keys in plain text (email, chat, etc.)
Deployment Strategies
Section titled “Deployment Strategies”Local Development:
ENABLE_AUTH=falseNo need for authentication on localhost.
Shared Network (Office, VPN):
ENABLE_AUTH=trueMCP_API_KEY=<strong-random-key>Protect against unauthorized access from the network.
Remote/Public Deployment:
ENABLE_AUTH=trueMCP_API_KEY=<strong-random-key>Always enable authentication for internet-facing deployments.
Additional Security Layers
Section titled “Additional Security Layers”While API key authentication provides basic security, consider these additional measures for production:
- HTTPS/TLS: Use a reverse proxy (nginx, Caddy) with SSL certificates
- Rate Limiting: Implement rate limiting at the proxy level
- IP Whitelisting: Restrict access to known IP addresses
- Network Isolation: Run in a private VPC or behind a firewall
- Monitoring: Log authentication attempts and alert on failures
Example Configurations
Section titled “Example Configurations”Development
Section titled “Development”ENABLE_AUTH=falseStaging
Section titled “Staging”ENABLE_AUTH=trueMCP_API_KEY=staging-3f7a8b2c9d4e1f6g8h5i7j9k0l2m3n4oProduction
Section titled “Production”ENABLE_AUTH=trueMCP_API_KEY=prod-5p6q7r8s9t0u1v2w3x4y5z6a7b8c9d0e1f2g3h4i5j6k7Troubleshooting
Section titled “Troubleshooting””Missing API key” Error
Section titled “”Missing API key” Error”Cause: Authentication is enabled but no API key was provided.
Solution:
- Add
Authorization: Bearer <key>header - Or append
?api_key=<key>to the URL - Check MCP client configuration
”Invalid API key” Error
Section titled “”Invalid API key” Error”Cause: The provided API key doesn’t match the configured key.
Solution:
- Verify the key in
.envmatches the one in your request - Check for typos or extra spaces
- Ensure the key wasn’t truncated
- Restart the server after changing
.env
Authentication Works in curl but Not in MCP Client
Section titled “Authentication Works in curl but Not in MCP Client”Cause: MCP client configuration might be incorrect.
Solution:
- Verify the
headerssection in your MCP config - Ensure the key is correctly formatted
- Restart the MCP client after config changes
Health Check (No Auth)
Section titled “Health Check (No Auth)”The /health endpoint is always accessible without authentication, useful for monitoring:
# Works even with ENABLE_AUTH=truecurl http://localhost:3000/healthResponse:
{ "status": "healthy", "timestamp": "2025-10-25T10:30:00.000Z", "version": "0.0.0"}