| title | Quickstart - Visual Studio Code local |
|---|---|
| description | Learn how to start a SQL MCP Server locally using Data API builder without Aspire. Connect Visual Studio Code to your database and execute queries in minutes. |
| author | jnixon |
| ms.author | jnixon |
| ms.topic | quickstart |
| ms.date | 12/22/2025 |
[!INCLUDESection - Quickstart selector]
[!INCLUDENote - Preview]
This quickstart uses the Data API builder CLI to run a SQL MCP Server locally without Aspire. You create a database, configure a config file, start SQL MCP Server, and connect to it from Visual Studio Code (VS Code) using a custom tool. This path is the easiest way to explore SQL MCP Server without containers or hosting frameworks.
Install these tools before you start.
You may already have this tool installed. Run dotnet --version and confirm it reports version 9.0 or later. If .NET is already present, reinstalling is safe and only refreshes your runtime.
You need access to a SQL Server database. Any of the following work:
- SQL Server (Developer or Express)
- LocalDB (file-based SQL Server)
- SQL Server in Docker
dotnet new tool-manifest
dotnet tool install microsoft.dataapibuilder --prerelease
dotnet tool restoreNote
SQL MCP Server is currently in prerelease. Using the --prerelease flag ensures you get the latest version of Data API builder with all the features used in this quickstart.
In this step, you create a database named ProductsDb and seed it with a single table named Products.
Connect to your SQL instance using SQLCMD, SQL Server Management Studio, or any preferred tool, then run:
CREATE DATABASE ProductsDb;
GO
USE ProductsDb;
GO
CREATE TABLE dbo.Products (
Id INT PRIMARY KEY,
Name NVARCHAR(100) NOT NULL,
Inventory INT NOT NULL,
Price DECIMAL(10,2) NOT NULL,
Cost DECIMAL(10,2) NOT NULL
);
INSERT INTO dbo.Products (Id, Name, Inventory, Price, Cost)
VALUES
(1, 'Action Figure', 40, 14.99, 5.00),
(2, 'Building Blocks', 25, 29.99, 10.00),
(3, 'Puzzle 500 pcs', 30, 12.49, 4.00),
(4, 'Toy Car', 50, 7.99, 2.50),
(5, 'Board Game', 20, 34.99, 12.50),
(6, 'Doll House', 10, 79.99, 30.00),
(7, 'Stuffed Bear', 45, 15.99, 6.00),
(8, 'Water Blaster', 35, 19.99, 7.00),
(9, 'Art Kit', 28, 24.99, 8.00),
(10,'RC Helicopter', 12, 59.99, 22.00);Your sample database is ready.
Run all commands in the folder where you want to create your dab-config.json file.
Create a file named .env in your working directory and add the following line (customize with your SQL Server information):
MSSQL_CONNECTION_STRING=Server=localhost;Database=ProductsDb;Trusted_Connection=True;TrustServerCertificate=True
Note
Integrated authentication (Trusted_Connection=True) works on Windows. For SQL authentication (common with Docker or cross-platform), use Server=localhost,1433;Database=ProductsDb;User Id=sa;Password=<YourPassword>;TrustServerCertificate=True instead (assuming your container maps port 1433 to localhost).
Data API builder can read variables from a local .env file when present in the working directory. If your environment doesn't support .env files, set MSSQL_CONNECTION_STRING as an environment variable in your terminal session before running the following commands.
Run the following commands:
dab init --database-type mssql --connection-string "@env('MSSQL_CONNECTION_STRING')" --host-mode Development --config dab-config.json
dab add Products --source dbo.Products --permissions "anonymous:read" --description "Toy store products with inventory, price, and cost."dab update Products --fields.name Id --fields.primary-key true --fields.description "Product Id"
dab update Products --fields.name Name --fields.description "Product name"
dab update Products --fields.name Inventory --fields.description "Units in stock"
dab update Products --fields.name Price --fields.description "Retail price"
dab update Products --fields.name Cost --fields.description "Store cost"Your SQL MCP Server is fully configured.
Before connecting from VS Code, start the SQL MCP Server in a separate terminal.
dab start --config dab-config.jsonThis command starts the SQL MCP Server. After startup, the terminal output shows the listening URLs. This quickstart assumes the MCP endpoint is http://localhost:5000/mcp. Keep this terminal running - Visual Studio Code connects to this HTTP endpoint.
Note
You can customize the port by configuring the runtime settings in your dab-config.json or by setting environment variables such as ASPNETCORE_URLS.
Important
A workspace is the root folder that VS Code treats as your project. Settings and MCP server definitions only apply inside that folder. If you open a single file, you aren't in a workspace. You must open a folder.
- Select File > Open Folder.
- Open the folder that contains your
dab-config.jsonfile.
Create a file named .vscode/mcp.json and add the following content:
{
"servers": {
"sql-mcp-server": {
"type": "http",
"url": "http://localhost:5000/mcp"
}
}
}Save the file. VS Code detects the MCP server configuration automatically. You may need to reload the window (Developer: Reload Window from the Command Palette).
- Open the Command Palette (Ctrl+Shift+P or Cmd+Shift+P on macOS).
- Run MCP: List Servers to view available servers.
- Select sql-mcp-server and choose Start to connect.
Once connected, the Products entity appears as MCP tools such as describe_entities and read_records. Tool names may vary based on your configuration.
Note
VS Code MCP support is evolving. The configuration schema may change in future releases. For the latest guidance, see the VS Code documentation for MCP integration.
Open the VS Code Copilot Chat and try this prompt:
Which products have an inventory under 30?