Domain 1 β€” Module 10 of 10 100%
10 of 28 overall
Domain 1: Design and Develop Database Solutions Free ⏱ ~11 min read

MCP: Connecting AI to Your Database

Use Model Context Protocol to connect AI agents and tools directly to SQL Server and Fabric databases β€” giving them schema awareness and the ability to query data safely.

Giving AI tools direct access to your database

Simple explanation

Imagine giving a new colleague a tour of the office.

Without a tour, they wander around guessing where things are. With a tour, they know: β€œCustomer data is in this cabinet, financial reports are over there, and you need a key for the vault.” That is what MCP does for AI tools β€” it gives them a guided tour of your database so they know what tables exist, what columns they contain, and how to query them properly.

MCP (Model Context Protocol) is an open standard that connects AI tools (like GitHub Copilot or custom agents) to data sources. For SQL, it means Copilot can see your actual schema and write queries that work with your real tables β€” not generic guesses.

What is MCP?

MCP follows a client-server architecture:

ComponentRoleExamples
MCP ClientThe AI tool that consumes dataGitHub Copilot, VS Code, Copilot Studio, Foundry agents
MCP ServerExposes data and tools via the MCP protocolSQL MCP Server (via Data API Builder), Fabric MCP Server
TransportHow client and server communicateHTTP/SSE (remote), stdio (local)

The MCP server tells the client: β€œHere are the tables I have, here are the columns, and here are the queries you can run.” The client uses this information to generate accurate, schema-aware SQL.

SQL MCP Server (via Data API Builder)

Microsoft provides an MCP server for SQL databases built on Data API Builder (DAB). It exposes your database schema and query capabilities to any MCP-compatible client.

How it works

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     MCP Protocol      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  GitHub Copilot  β”‚ ◄──────────────────► β”‚  SQL MCP Server  β”‚
β”‚  (MCP Client)    β”‚                       β”‚  (Data API       β”‚
β”‚                  β”‚                       β”‚   Builder)       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                       β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                                   β”‚
                                          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                                          β”‚  SQL Server /    β”‚
                                          β”‚  Azure SQL /     β”‚
                                          β”‚  Fabric SQL DB   β”‚
                                          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Connecting to SQL MCP Server endpoints

  1. Install the SQL MCP Server (part of Data API Builder tooling)
  2. Configure the connection β€” specify your SQL Server endpoint and authentication
  3. Register in your MCP client β€” add the server endpoint to Copilot or VS Code settings

In VS Code settings (.vscode/mcp.json or user settings):

{
  "mcpServers": {
    "sql-server": {
      "type": "http",
      "url": "http://localhost:5000/mcp",
      "headers": {
        "Authorization": "Bearer ${env:SQL_MCP_TOKEN}"
      }
    }
  }
}

What the SQL MCP Server exposes

MCP CapabilityWhat It Provides
ResourcesDatabase schema β€” tables, views, columns, data types, relationships
ToolsCRUD operations β€” query, create, update, delete according to configured entity permissions
PromptsPre-built prompt templates for common SQL tasks

Connecting to Fabric lakehouse

For Fabric SQL databases and lakehouses, MCP connectivity allows AI tools to understand and query your Fabric data:

  1. Fabric workspace must have Copilot enabled
  2. SQL analytics endpoint provides the connection for MCP
  3. Authentication uses Microsoft Entra ID (Azure AD)

The Fabric MCP endpoint gives AI tools access to:

  • Lakehouse tables and views
  • SQL database objects
  • Data warehouse schemas

Configuring MCP tool options in Copilot

When using MCP with GitHub Copilot Chat, you can:

Select tools

In the chat panel, use @ to reference available MCP tools:

  • @sql-server β€” query your connected SQL database
  • @fabric β€” query your Fabric lakehouse

Configure model options

Switch between available AI models in the chat session:

  • Different models have different strengths (speed vs reasoning)
  • Some models handle SQL better than others
  • Model selection affects token limits and response quality
MCP transforms Copilot from guessing to knowing your database
FeatureWithout MCPWith MCP
Schema awarenessCopilot guesses table/column namesCopilot knows your exact schema
Query accuracyGeneric suggestions, often wrong table namesSchema-accurate queries using real tables
Data type awarenessMay suggest wrong data typesKnows column types, suggests appropriate functions
Relationship awarenessCannot know foreign key relationshipsUnderstands JOINs between your tables
SecurityNo access control on what Copilot seesMCP server controls which objects are exposed
Scenario: Leo's MCP setup at SearchWave

Leo Torres at SearchWave connects the SQL MCP Server to his VS Code instance. Now when he asks Copilot: β€œWrite a query to find the top 10 products by search frequency this month,” Copilot generates a query using SearchWave’s actual table names (search_events, products, search_metrics) with correct column names and JOINs.

Without MCP, Copilot would have guessed generic names like Products and Searches β€” requiring Leo to fix every table and column reference manually.

Leo also connects to the Fabric lakehouse MCP endpoint for analytics queries against the company’s data warehouse, giving Copilot visibility into both the OLTP database and the analytics layer.

Exam tip: MCP security boundaries

The MCP server controls what the AI client can see and do. Key security principles:

  • Least privilege β€” configure DAB entities to expose only the tables, views, and operations the AI needs
  • Read-only when appropriate β€” restrict entities to read operations unless write access is explicitly needed
  • Authentication β€” MCP connections should use managed identity or token-based auth, not embedded credentials
  • Audit β€” log all queries executed through MCP for compliance

The exam may ask about securing MCP endpoints β€” the answer usually involves restricting which objects are exposed and using proper authentication.

Question

What is Model Context Protocol (MCP)?

Click or press Enter to reveal answer

Answer

An open protocol that connects AI tools (clients) to external data sources (servers) through a standardised interface. For SQL, an MCP server exposes database schema, query tools, and data access β€” giving AI tools like GitHub Copilot schema-aware intelligence instead of generic guessing.

Click to flip back

Question

What does the SQL MCP Server expose to AI clients?

Click or press Enter to reveal answer

Answer

Three things: (1) Resources β€” database schema including tables, views, columns, and relationships. (2) Tools β€” ability to execute queries against the database. (3) Prompts β€” pre-built templates for common SQL tasks. This is built on Data API Builder.

Click to flip back

Question

How does connecting MCP improve Copilot's SQL suggestions?

Click or press Enter to reveal answer

Answer

Without MCP, Copilot guesses table and column names. With MCP, Copilot knows your exact schema β€” real table names, column types, foreign key relationships. This dramatically improves query accuracy and reduces manual corrections.

Click to flip back

Knowledge Check

Dev at PixelForge Studios wants GitHub Copilot to generate accurate queries against the company's SQL database. Currently, Copilot suggests generic table names that do not match the actual schema. What should Dev configure?

Next up: Encryption: Always Encrypted and Column-Level β€” protect sensitive data at rest and in transit with SQL Server’s encryption features.