Basic Configuration
Environment variables
Section titled “Environment variables”The safest way to configure the server is through environment variables. Copy the example template:
cp .env.example .envEdit .env with your database credentials.
Load environment variables
Section titled “Load environment variables”Linux/macOS:
source .envWindows PowerShell:
Get-Content .env | ForEach-Object { $name, $value = $_ -split '=', 2 [Environment]::SetEnvironmentVariable($name, $value)}Required variables
Section titled “Required variables”| Variable | Description |
|---|---|
MSSQL_SERVER | SQL Server hostname or IP |
MSSQL_DATABASE | Database name |
MSSQL_USER | SQL Server username |
MSSQL_PASSWORD | SQL Server password |
Optional variables
Section titled “Optional variables”| Variable | Default | Description |
|---|---|---|
MSSQL_PORT | 1433 | SQL Server port |
DEVELOPER_MODE | false | true for development, false for production |
MSSQL_READ_ONLY | false | Read-only mode |
MSSQL_WHITELIST_TABLES | (empty) | Tables allowed for modification in read-only mode |
MSSQL_AUTH | sql | Authentication mode (sql, integrated, azure) |
MSSQL_CONNECTION_STRING | (empty) | Custom connection string (overrides other variables) |
Execution modes
Section titled “Execution modes”Development mode
Section titled “Development mode”DEVELOPER_MODE=true go run main.goIn development mode:
- Self-signed certificates are allowed
- Errors show technical details
- Encryption can be disabled for local SQL Server
Production mode
Section titled “Production mode”DEVELOPER_MODE=false ./mcp-go-mssqlIn production mode:
- Valid TLS certificates are required
- Errors are generic (no technical details)
- Encryption is mandatory
Verify the connection
Section titled “Verify the connection”cd testgo run test-connection.go