-
Notifications
You must be signed in to change notification settings - Fork 2
OAuth
Value Proposition Secure your database ecosystem with fine-grained access controls. Our OAuth integration supports a zero-trust architecture, leveraging scope-based permissions to establish clear security boundaries for autonomous AI agents. Read the full value proposition
Important
OAuth validation requires the HTTP transport to process bearer tokens. The default stdio transport does not support OAuth.
Streamline your secure deployments and enforce strict access boundaries. Enable enterprise OAuth via standard CLI arguments:
npx -y @neverinfamous/mysql-mcp --mysql mysql://user:password@localhost:3306/database \
--transport http \
--port 3000 \
--server-host 0.0.0.0 \
--allowed-io-roots "/data,C:/temp" \
--oauth-enabled \
--oauth-issuer http://localhost:8081/realms/mysql-mcp \
--oauth-audience mysql-mcp-clientOr with environment variables:
# OAuth
export OAUTH_ENABLED=true
export OAUTH_ISSUER=http://localhost:8081/realms/mysql-mcp
export OAUTH_AUDIENCE=mysql-mcp-client
# Database
export MYSQL_HOST=localhost
export MYSQL_PORT=3306
export MYSQL_USER=user
export MYSQL_PASSWORD=password
export MYSQL_DATABASE=database
npx -y @neverinfamous/mysql-mcp --transport http --server-host 0.0.0.0 --port 3000 --allowed-io-roots "/data,C:/temp"Note: The
--mysql <uri>argument is supported in addition to environment variables.
Note
Global install users can substitute npx -y @neverinfamous/mysql-mcp with mysql-mcp.
| Option | Environment | Description |
|---|---|---|
--oauth-enabled / -o
|
OAUTH_ENABLED |
Enable OAuth authentication |
--oauth-issuer |
OAUTH_ISSUER |
Authorization server URL (issuer) |
--oauth-audience |
OAUTH_AUDIENCE |
Expected token audience |
--oauth-jwks-uri |
OAUTH_JWKS_URI |
JWKS URI (auto-discovered if not set) |
--oauth-clock-tolerance |
OAUTH_CLOCK_TOLERANCE |
Clock tolerance in seconds (default: 60) |
| Scope | Operations | Allowed Tool Groups |
|---|---|---|
full |
All operations | All tool groups |
read |
Read-only operations | core (read), schema, json, stats, dba-monitor, router |
write |
Data modification | core (write), transactions, docstore |
admin |
Administrative operations | admin, backup, roles, codemode, shell |
Note: The scope mapping table above is illustrative and omits major meta-groups (e.g., vector, spatial, proxysql, etc.). To maintain a strict security boundary, highly privileged operations like Code Mode (mysql_execute_code) and the shell group explicitly require the admin scope.
Fine-grained access with pattern scopes:
| Pattern | Example | Description |
|---|---|---|
db:* |
db:mydb |
Access to specific database |
table:*:* |
table:mydb:users |
Access to specific table |
Download Keycloak from keycloak.org and extract it.
Note
Windows users should use .bat scripts (e.g., kc.bat, kcadm.bat) instead of .sh and set or $env: instead of export for environment variable configuration.
cd keycloak-<version>/bin
./kc.sh start-dev --http-port 8081Wait for: Keycloak started in X.XXs. Listening on: http://0.0.0.0:8081
- Open http://localhost:8081
- Create an admin user on first access
Open a new terminal and navigate to the keycloak-<version>/bin directory.
# Login to admin CLI
./kcadm.sh config credentials --server http://localhost:8081 --realm master --user admin --password YOUR_PASSWORD
# Create mysql-mcp realm
./kcadm.sh create realms -s realm=mysql-mcp -s enabled=true
# Create client with client_credentials grant
./kcadm.sh create clients -r mysql-mcp -s clientId=mysql-mcp-client -s enabled=true -s clientAuthenticatorType=client-secret -s secret=test-secret -s serviceAccountsEnabled=true
# Create scopes
./kcadm.sh create client-scopes -r mysql-mcp -s name=read -s protocol=openid-connect
./kcadm.sh create client-scopes -r mysql-mcp -s name=write -s protocol=openid-connect
./kcadm.sh create client-scopes -r mysql-mcp -s name=admin -s protocol=openid-connect
./kcadm.sh create client-scopes -r mysql-mcp -s name=full -s protocol=openid-connectcurl -X POST http://localhost:8081/realms/mysql-mcp/protocol/openid-connect/token \
-d "client_id=mysql-mcp-client" \
-d "client_secret=test-secret" \
-d "grant_type=client_credentials"Your issuer URL is: http://localhost:8081/realms/mysql-mcp
mysql-mcp implements:
- RFC 8414 - OAuth 2.0 Authorization Server Metadata Discovery
- RFC 7591 - OAuth 2.0 Dynamic Client Registration
- Tools - Complete tool list
- Tool Filtering - Custom tool filtering
- Configuration - General configuration
Value Proposition Enforce strict execution boundaries and maximize LLM context efficiency for secure, autonomous database interactions. Read the full value proposition
- Installation
- Configuration
- Architecture
- HTTP Transport
- Tool Filtering
- Code Mode
- Tools
- Prompts
- Resources
- Observability & Telemetry