The servers in this repository are reference implementations intended for educational purposes. They demonstrate MCP features and SDK usage but are not production-ready solutions. Evaluate your security requirements and implement appropriate safeguards based on your threat model.
This guide covers security best practices for deploying MCP servers safely and securely.
For enhanced security, use runtime connection tools instead of startup credentials:
# Start server without credentialsdocker run -i --rm mochoa/mcp-oracle# Connect at runtime using toolorcl-connect host.docker.internal:1521/freepdb1 readonly_user secure_password
-- Create read-only userCREATE USER mcp_readonly IDENTIFIED BY secure_password;-- Grant minimal permissionsGRANT CONNECT TO mcp_readonly;GRANT SELECT ON schema_name.* TO mcp_readonly;-- Optional: For explain plansGRANT SELECT_CATALOG_ROLE TO mcp_readonly;-- Optional: For AWR reportsGRANT SELECT_CATALOG_ROLE TO mcp_readonly;GRANT EXECUTE ON DBMS_WORKLOAD_REPOSITORY TO mcp_readonly;
-- Create read-only userCREATE USER 'mcp_readonly'@'%' IDENTIFIED BY 'secure_password';-- Grant SELECT onlyGRANT SELECT ON mydb.* TO 'mcp_readonly'@'%';-- Optional: For performance schema access (AWR reports)GRANT SELECT ON performance_schema.* TO 'mcp_readonly'@'%';-- Apply changesFLUSH PRIVILEGES;
Create a dedicated user with read-only API access:
# Create read-only user/user add name=mcp_readonly password=secure_password group=read# Configure API access/ip service set api address=192.168.88.0/24/ip service set api-ssl address=192.168.88.0/24
Never use administrative or root accounts for MCP server connections. Always create dedicated accounts with minimal necessary privileges.
# Run with read-only root filesystemdocker run -i --rm --read-only mochoa/mcp-mysql# Drop unnecessary capabilitiesdocker run -i --rm --cap-drop=ALL mochoa/mcp-mysql# Use non-root user (if image supports)docker run -i --rm --user 1000:1000 mochoa/mcp-mysql
-- Enable unified auditingAUDIT SELECT ON schema_name.sensitive_table BY mcp_readonly;-- Review audit logsSELECT * FROM UNIFIED_AUDIT_TRAIL WHERE DBUSERNAME = 'MCP_READONLY';
MySQL Auditing
-- Enable general query log (development only)SET GLOBAL general_log = 'ON';SET GLOBAL log_output = 'TABLE';-- Review query logSELECT * FROM mysql.general_logWHERE user_host LIKE '%mcp_readonly%';
MikroTik Logging
# Enable API logging/system logging add topics=api action=memory# View logs/log print where topics~"api"