How to link Claude to your local SQL database (safely)

Most businesses have years of useful information sitting in a SQL database: jobs, invoices, stock, customers, bookings. Getting answers out of it usually means waiting for someone who can write a query or build a report. What if you could just ask, in plain English, “Which customers haven’t ordered in six months?” or “What were our top ten products last quarter?”

You can, by linking Anthropic’s Claude to your database. The data stays on your own server, Claude asks the database questions on your behalf, and you approve what it does. Here’s how it works, what you need and how to set it up safely.

Claude Desktop app MCP server on your computer SQL database read-only login The database never leaves your network. Only query results are sent to Claude.

How it works: MCP in one paragraph

Claude connects to outside systems using the Model Context Protocol (MCP), an open standard for plugging AI into tools and data. An MCP server is a small program that runs on your computer and offers Claude a set of tools, such as “list tables”, “describe table” and “run query”. The Claude Desktop app starts the MCP server, and when you ask a question, Claude decides which tool to use, the MCP server runs the SQL against your database, and the results come back to Claude to explain. By default, Claude asks your permission before using a tool.

Because the MCP server runs locally, your database doesn’t need to be exposed to the internet. It only has to be reachable from the computer running Claude Desktop, in the same way as any other database client.

What you need

  • The Claude Desktop app for Windows or Mac, signed in to a paid Claude plan (a business plan is recommended).
  • A SQL database the computer can reach: Microsoft SQL Server (including Express and LocalDB), Azure SQL, MySQL, MariaDB, PostgreSQL or SQLite all have MCP servers available.
  • An MCP server for your database. For SQL Server there’s Microsoft’s own MSSQL MCP Server, several open-source options, and commercial options such as CData. Most need Python or Node.js installed.
  • A dedicated, read-only database login for Claude. More on this below, because it’s the most important step.

Step 1: Create a read-only login for Claude

Never connect Claude using sa, a domain admin or the application’s own login. Create a separate login that can only read the data you want it to see. On SQL Server, run this in SQL Server Management Studio (change the names and use a strong password):

-- Run on the SQL Server, in SSMS
CREATE LOGIN claude_reader WITH PASSWORD = 'Use-A-Long-Random-Password-Here!';
GO
USE YourDatabase;
GO
CREATE USER claude_reader FOR LOGIN claude_reader;
ALTER ROLE db_datareader ADD MEMBER claude_reader;
-- Optional: hide sensitive tables
DENY SELECT ON dbo.Payroll TO claude_reader;
GO

Even if Claude (or a person typing a prompt) asks for an UPDATE or DELETE, the database will refuse it. For extra safety, point Claude at a reporting copy or a restored backup rather than the live production database.

Step 2: Install an MCP server

There are two ways to add a local MCP server to Claude Desktop:

  • Desktop extensions (easiest). In Claude Desktop, open Settings and go to Extensions. If there’s an extension for your database, click install and fill in the connection details. Claude Desktop stores fields marked as sensitive, like passwords, in Windows Credential Manager or the macOS Keychain.
  • Manual configuration. For MCP servers that aren’t packaged as extensions, you install the server (usually with pip or npm) and add it to Claude Desktop’s configuration file.

As an example, the open-source mssql_mcp_server for SQL Server installs with Python:

pip install microsoft_sql_server_mcp

Step 3: Add it to Claude Desktop’s config file

In Claude Desktop go to Settings > Developer > Edit Config. This opens claude_desktop_config.json, which lives at %APPDATA%\Claude\claude_desktop_config.json on Windows and ~/Library/Application Support/Claude/claude_desktop_config.json on a Mac. Add an entry under mcpServers:

{
  "mcpServers": {
    "mssql": {
      "command": "python",
      "args": ["-m", "mssql_mcp_server"],
      "env": {
        "MSSQL_SERVER": "SQLSERVER01\\SQLEXPRESS",
        "MSSQL_DATABASE": "YourDatabase",
        "MSSQL_USER": "claude_reader",
        "MSSQL_PASSWORD": "Use-A-Long-Random-Password-Here!"
      }
    }
  }
}

Each MCP server uses slightly different setting names, so check its README for the exact ones (including options for Windows authentication, encryption and custom ports). Note the double backslash in a named instance, which JSON requires.

The password sits in this file in plain text, so keep it on a secure, encrypted computer and only use the read-only login. A desktop extension, where available, is the safer choice.

Step 4: Restart and test

  1. Fully quit Claude Desktop (right-click the tray icon and choose Quit, not just close the window) and open it again.
  2. Click the + button in the chat box and choose Connectors. Your SQL server should appear with its tools listed.
  3. Start simple: “List the tables in my database and tell me what each one seems to hold.”
  4. Then ask real questions: “Show monthly sales totals for the last 12 months”, “Which jobs are still open after 30 days?”, or “Find customers with duplicate email addresses.”

Claude will show you the SQL it wants to run and ask for approval. Read it the first few times: it’s a good way to check Claude has understood your tables correctly.

If the server doesn’t appear, check the JSON for a missing comma or bracket, make sure Python or Node.js is on the system PATH, and look at the MCP logs under Settings > Developer.

Tips for good results

  • Explain your database once. Table names like tblCust2 mean nothing to anyone. Put a short description of the important tables and columns in a Claude project or skill, so every chat starts with that knowledge. (See our post on Claude skills and projects.)
  • Create views for common questions. A view such as vw_SalesByMonth is faster, safer and easier for Claude to use than joining ten tables each time.
  • Ask for the output you want. Claude can turn the results into a table, a chart, a spreadsheet or a short written summary for a meeting.
  • Check the numbers. Treat Claude’s answers like a new staff member’s report: usually right, but verify anything important before acting on it.

Security and privacy checklist

Linking AI to business data is powerful, so set it up carefully:

  • Use a read-only login limited to the tables Claude needs, and deny access to payroll, health or other sensitive data.
  • Remember that query results are sent to Claude to be read and summarised. Use a business plan and check its data retention and training settings before connecting customer or personal information.
  • Only install MCP servers from trusted sources (the vendor, well-known open-source projects or the Claude extensions directory). An MCP server runs with your user’s permissions on your computer.
  • Keep the computer running Claude Desktop patched, encrypted and protected with endpoint security and multi-factor sign-in.
  • Keep the default approval prompts on, especially while you’re getting started.

Want help connecting Claude to your data?

King Computer helps Sydney businesses connect AI to their own systems safely: SQL Server, Microsoft 365, accounting and job management systems. We can set up read-only access, build reporting views, install and configure the MCP server, and show your team how to get useful answers out of it. See our AI Services for Business page, or call us on 1300 54 64 74 or email [email protected].

Sources

Practical IT tips, straight to your inbox

Microsoft 365 updates, security alerts and plain-English tech advice for small businesses, emailed when we publish a new article.

We don’t spam! Read our privacy policy for more info.

Leave a Reply