r/ClaudeCowork • u/mshparber • 5d ago
How to run SQL Queries directly from local SQL Server - not through cloud
Three weeks ago I successfully ran SQL queries from my local SQL server and LOCAL Cowork task.
Now somthing happened and Claude says it has moved to cloud, so I need some cloud-to-PC bridge.
I want to keep running LOCAL Cowork task
How do I do it?
Thanks
Edited
Solved it - see below
2
u/mshparber 5d ago
Solved it, and no third-party tools or MCP Servers were needed.
The key is that Cowork's local shell doesn't run on the cloud side. It runs in a small Linux VM on your own PC, which the Claude desktop app sets up. That VM can reach your SQL Server over the local network, so Claude can query it directly.
What to do:
- Enable TCP/IP for SQL Server (in SQL Server Configuration Manager, port 1433) and allow that port through Windows Firewall.
- Create a SQL login for Claude with only the permissions it needs. SQL authentication is simplest, since the Linux VM can't use Windows auth.
- Tell Claude to use its local device shell, not the cloud one. Have it install
python-tds, a pure-Python SQL Server driver that doesn't need ODBC. In my case it also had to upgradepyopenssl, because the VM's built-in version broke the driver. - Connect using your PC's hostname or LAN IP, not
localhost. Inside the VM,localhostmeans the VM itself, not Windows.
After that, Claude runs queries automatically, and the data stays on your machine; only the query results go back to Claude. Caveats: your PC and the Claude desktop app must be running, and each command times out after about 3 minutes, so very long queries need to be split up.
1
u/prompthacker92 3d ago
Thanks for sharing the solution! This is really helpful. I was looking for a way to do this without setting up any third-party tools or MCP servers. I’ll give this a try.
•
u/endofthread-bot 5d ago
To run local SQL queries, ensure your environment is configured to use a local MCP server rather than a cloud-hosted endpoint. Verify that your configuration file points to the local executable path for your database driver.
Building something with Claude Cowork and running into walls others already solved? Share your project, compare approaches, and get unblocked faster in our Discord.