This document outlines the security practices implemented in the LogScale MCP Server.
We use a .env file approach to keep credentials secure:
# 1. Create the .env file
touch .env
# 2. Edit with your credentials
nano .env
# 3. The .env file is automatically gitignoredβ Credentials Never in Code
- API tokens are stored in
.env, not in shell scripts - Main codebase contains no sensitive information
- Safe to commit and share publicly
β Version Control Protection
.envfile is in.gitignore- Prevents accidental commits of credentials
- Use documentation examples for the required format without exposing secrets
β Runtime Validation
- Script validates credentials before starting server
- Clear error messages if configuration is missing
- Fails fast with helpful guidance
β Least Privilege Access
- Only the startup script needs to read credentials
- MCP server receives credentials via environment variables
- No credential persistence in memory beyond startup
For corporate environments with SSL inspection:
# Add to your .env file:
SSL_CERT_FILE=/path/to/your/corporate/certificate.pemCommon locations:
- Netskope:
/Library/Application Support/Netskope/STAgent/data/nscacert.pem - Check with IT for your organization's certificate
The MCP server needs access to:
- Your LogScale instance (typically HTTPS/443)
- Inbound connections are not required for the default stdio transport (Cursor runs the process locally)
- If you enable Streamable HTTP (
MCP_TRANSPORT=http), the process listens onMCP_HTTP_HOST/MCP_HTTP_PORT(default127.0.0.1:3333); restrict to localhost and/or setMCP_HTTP_TOKENbefore exposing beyond your machine
The startup script performs these checks:
- File Existence: Ensures
.envfile exists - Token Validation: Rejects default/empty tokens
- URL Validation: Ensures instance URL is configured
- Repository Check: Validates repository name is set
All user-supplied parameters are validated before use:
| Parameter | Validation | Function |
|---|---|---|
| Repository names | Whitelist regex [a-zA-Z0-9_.\-] |
validateRepoName() |
| Job IDs | Whitelist regex [a-zA-Z0-9_\-] |
validateJobId() |
| File paths | Directory traversal prevention | safePath() |
| Time inputs | Format + type + range validation | parseTimeInput() |
| Numeric limits | Min/max bounds enforcement | normalizeMaxEvents(), normalizeMaxChars() |
API error responses are sanitized before returning to clients:
- Truncated to 500 characters (configurable) to prevent information leakage
- Newlines collapsed to prevent log injection
- Applied to all REST API, GraphQL, and file operation error paths
# Example error messages:
ERROR: .env file not found!
ERROR: LOGSCALE_API_TOKEN not configured!
ERROR: LOGSCALE_BASE_URL not configured!-
Protect Your
.envFile# Set restrictive permissions chmod 600 .env -
Regular Token Rotation
- Rotate LogScale API tokens periodically
- Update
.envfile with new tokens - Revoke old tokens in LogScale UI
-
Environment Isolation
- Use separate tokens for dev/staging/production
- Don't share
.envfiles between environments - Use different LogScale repositories for testing
-
Never Commit Credentials
- Double-check
.gitignoreincludes.env - Use
git statusbefore commits - Consider using git hooks for additional protection
- Double-check
-
Documentation Security
- Use placeholders in documentation examples
- Never include real tokens in examples
- Sanitize logs and error messages
-
Code Review
- Review changes to credential handling carefully
- Ensure no hardcoded secrets
- Validate error messages don't leak sensitive info
Instead of .env, you can use system environment variables:
# Set in your shell profile (.bashrc, .zshrc, etc.)
export LOGSCALE_API_TOKEN="your-token"
export LOGSCALE_BASE_URL="https://your-instance.com"
export LOGSCALE_REPOSITORY="your-repo"For enterprise deployments, consider:
- HashiCorp Vault: Store and rotate credentials
- AWS Secrets Manager: Cloud-based secret storage
- Azure Key Vault: Microsoft Azure secret management
- System Keychain: macOS/Linux keychain integration
When using Docker:
# Use secrets mounting instead of environment variables
# Mount secrets as files, not env vars
COPY --from=secrets /run/secrets/logscale-token /etc/secrets/Monitor your LogScale instance for:
- API token usage patterns
- Unusual query patterns
- Failed authentication attempts
- Access from unexpected IP addresses
The MCP server logs:
- β Startup and configuration validation
- β General connection status
- β Never logs API tokens or sensitive data
- β Credentials are not written to any logs
If you suspect credential compromise:
-
Immediate Actions
# 1. Revoke the token in LogScale UI # 2. Generate a new token # 3. Update .env file # 4. Restart MCP server
-
Investigation
- Check LogScale access logs
- Review recent query history
- Monitor for suspicious activity
- Update any shared configurations
For security vulnerabilities in this MCP server:
- Create a private issue or contact maintainers directly
- Do not publicly disclose security issues
- Include reproduction steps and impact assessment
Before deploying:
-
.envfile created and configured -
.envfile has restrictive permissions (600) -
.gitignoreincludes.envandnode_modules/ - No credentials in code or documentation
- SSL certificate configured (if needed)
- LogScale API token has minimal required permissions
- Network firewall allows HTTPS to LogScale instance
- Monitoring setup for unusual API usage
- All utility tests passing (
npm test)
Run the test suite to verify input validation and security controls:
npm testTests cover:
- Repository name injection prevention (SQL injection, path traversal, special characters)
- Job ID format validation (path traversal, URL injection, command injection)
- Path traversal prevention for file operations
- Error text sanitization (truncation, newline collapsing)
- Numeric bounds enforcement
- Time input format validation
This security-first approach ensures your LogScale credentials and data remain protected while providing a smooth user experience.