Skip to content

Configuration ​

The server reads settings from a config.yaml file or from environment variables. Environment variables always override the file, which makes secrets easy to inject at runtime.

config.yaml ​

Start from config.yaml.example:

yaml
database:
  host: "localhost"
  port: 1433
  user: "readonly_user"
  password: ""              # prefer SQLSERVER_PASSWORD
  database: "MyDatabase"
  encrypt: "true"           # true, false, or disable
  trust_server_certificate: false
  connection_timeout: 30

# Always Encrypted: client-side column decryption with a local PFX.
encryption:
  enabled: false
  key_path: ""              # absolute path to the .pfx file
  key_password: ""          # prefer SQLSERVER_ALWAYS_ENCRYPTED_KEY_PASSWORD

query:
  max_length: 5000          # max characters per query
  max_rows: 1000            # max rows returned
  timeout: 30s              # per-query timeout

pool:
  max_open_conns: 10
  max_idle_conns: 5
  conn_max_lifetime: 1h

logging:
  level: "info"             # debug, info, warn, error
  format: "json"            # json, text

mcp:
  transport: "stdio"        # stdio or http
  port: 9090

Environment variables ​

VariableDescription
SQLSERVER_HOSTDatabase host
SQLSERVER_PORTDatabase port (default 1433)
SQLSERVER_USERDatabase user
SQLSERVER_PASSWORDDatabase password
SQLSERVER_DATABASEDatabase name
SQLSERVER_ENCRYPTEncryption mode (default true)
SQLSERVER_TRUST_SERVER_CERTIFICATETrust self-signed certificates
SQLSERVER_CONNECTION_TIMEOUTConnection timeout in seconds
SQLSERVER_ALWAYS_ENCRYPTED_KEY_PATHPath to the PFX certificate
SQLSERVER_ALWAYS_ENCRYPTED_KEY_PASSWORDPFX certificate password
QUERY_MAX_LENGTHMaximum query length
QUERY_MAX_ROWSMaximum result rows
QUERY_TIMEOUT_SECONDSPer-query timeout
LOG_LEVELLog level
LOG_FORMATLog format
CONFIG_PATHPath to config.yaml

MCP client integration ​

Claude Desktop ​

Add the server to claude_desktop_config.json:

json
{
  "mcpServers": {
    "mssql": {
      "command": "mssql-mcp-go",
      "env": {
        "SQLSERVER_HOST": "localhost",
        "SQLSERVER_PORT": "1433",
        "SQLSERVER_USER": "readonly_user",
        "SQLSERVER_PASSWORD": "secret",
        "SQLSERVER_DATABASE": "MyDatabase",
        "SQLSERVER_ENCRYPT": "disable"
      }
    }
  }
}

If you installed with Homebrew, the binary is already on your PATH. Otherwise, use its full path.

Claude Desktop with Docker ​

json
{
  "mcpServers": {
    "mssql": {
      "command": "docker",
      "args": [
        "run", "--rm", "-i",
        "-e", "SQLSERVER_HOST=host.docker.internal",
        "-e", "SQLSERVER_PORT=1433",
        "-e", "SQLSERVER_USER=readonly_user",
        "-e", "SQLSERVER_PASSWORD=secret",
        "-e", "SQLSERVER_DATABASE=MyDatabase",
        "ghcr.io/nirantarasi/mssql-mcp-go:latest"
      ]
    }
  }
}

Cline (VS Code) ​

Add the server to your Cline MCP settings:

json
{
  "mssql": {
    "command": "mssql-mcp-go",
    "env": {
      "SQLSERVER_HOST": "localhost",
      "SQLSERVER_PORT": "1433",
      "SQLSERVER_USER": "readonly_user",
      "SQLSERVER_PASSWORD": "secret",
      "SQLSERVER_DATABASE": "MyDatabase"
    }
  }
}

Security notes ​

  • Use a login that only has read permissions on the databases the assistant should see.
  • Prefer environment variables over committing credentials to config.yaml.
  • TLS is on by default (encrypt: true). Set trust_server_certificate: false unless you are connecting to a server with a self-signed certificate.
  • Always Encrypted columns are decrypted client-side with the PFX you provide; the key never leaves the machine running the server.