Azure SQL MCP Server

Azure SQL MCP Server

Enables querying an Azure SQL Products table via MCP, allowing integration with Microsoft Foundry agents for data retrieval.

Category
访问服务器

README

SQL MCP Server — Foundry Demo — Resume Point

Project: Deploy Microsoft's SQL MCP Server (Data API builder) on Azure Container Apps, backed by an Azure SQL Products table, so it can be wired into a Microsoft Foundry agent (Claude, via Microsoft Agent Framework or the Foundry portal) as a Custom MCP Tool.

Working folder on this machine: ~/MCP-Azure (contains dab-config.json and Dockerfile). This is a separate folder from the agent.py / Cursor project that consumes this MCP server later — don't merge them.


Current status

Step Status
1. Azure SQL Database + Products table (10 sample rows) ✅ Done — verified via Azure Portal Query Editor (SELECT COUNT(*) FROM dbo.Products → 10)
2. dab-config.json (SQL MCP Server config) ✅ Done — entity Products fully configured, anonymous:read, field descriptions set
3. Dockerfile ✅ Created
3. Azure Container Registry (ACR) resource ✅ Created (acrsqlmcp15272)
3. Build image via az acr build (cloud build) ❌ Blocked — Free Trial subscriptions can't use ACR Tasks (TasksOperationsNotAllowed). Switched to local Docker build + push instead.
3. Build image locally with Docker, tag, push to ACR 🔄 In progress — resume here
3. Container Apps environment + deploy ⬜ Not started
3. Get /mcp URL, test /health ⬜ Not started
4. Wire into Foundry (portal or agent.py) ⬜ Not started (guide + agent.py already exist from earlier session)

Known values (already created — don't regenerate)

RESOURCE_GROUP="rg-mcp-demo"
LOCATION="westus3"
SQL_SERVER="sql-mcp-1000"              # NOT the FQDN — just the server name
SQL_DATABASE="ProductsDb"
SQL_ADMIN="sqladmin"
SQL_PASSWORD="<not stored here — re-enter each session>"

CONNECTION_STRING="Server=tcp:${SQL_SERVER}.database.windows.net,1433;Database=${SQL_DATABASE};User ID=${SQL_ADMIN};Password=${SQL_PASSWORD};Encrypt=true;TrustServerCertificate=false;Connection Timeout=30;"

ACR_NAME="acrsqlmcp15272"
ACR_LOGIN_SERVER="acrsqlmcp15272.azurecr.io"

CONTAINERAPP_ENV="sql-mcp-env"         # not yet created
CONTAINERAPP_NAME="sql-mcp-server"     # not yet created

Re-paste this whole block into a fresh terminal at the start of each session — none of these persist across terminal tabs/restarts.


Remaining steps (resume here)

1. Confirm Docker Desktop is running

docker --version

If not installed: brew install --cask docker, then open Docker Desktop from Applications and wait for the whale icon to go steady before continuing.

2. Build the image locally, targeting the right architecture

This Mac is Apple Silicon (arm64), but Azure Container Apps expects linux/amd64 by default — build explicitly for that platform:

cd ~/MCP-Azure
docker build --platform linux/amd64 -t sql-mcp-server:1 .

3. Tag and push to ACR

az acr login --name "$ACR_NAME"

docker tag sql-mcp-server:1 "$ACR_LOGIN_SERVER/sql-mcp-server:1"
docker push "$ACR_LOGIN_SERVER/sql-mcp-server:1"

Confirm it landed:

az acr repository list --name "$ACR_NAME" --output table

Expect to see sql-mcp-server listed.

4. Create the Container Apps environment and deploy

az containerapp env create --name "$CONTAINERAPP_ENV" --resource-group "$RESOURCE_GROUP" --location "$LOCATION"

ACR_USERNAME=$(az acr credential show --name "$ACR_NAME" --query username --output tsv)
ACR_PASSWORD=$(az acr credential show --name "$ACR_NAME" --query "passwords[0].value" --output tsv)

az containerapp create \
  --name "$CONTAINERAPP_NAME" --resource-group "$RESOURCE_GROUP" --environment "$CONTAINERAPP_ENV" \
  --image "$ACR_LOGIN_SERVER/sql-mcp-server:1" \
  --registry-server "$ACR_LOGIN_SERVER" --registry-username "$ACR_USERNAME" --registry-password "$ACR_PASSWORD" \
  --target-port 5000 --ingress external --min-replicas 1 --max-replicas 3 \
  --secrets "mssql-connection-string=$CONNECTION_STRING" \
  --env-vars "MSSQL_CONNECTION_STRING=secretref:mssql-connection-string" \
  --cpu 0.5 --memory 1.0Gi

5. Get the MCP URL and test it

MCP_URL=$(az containerapp show --name "$CONTAINERAPP_NAME" --resource-group "$RESOURCE_GROUP" \
  --query "properties.configuration.ingress.fqdn" --output tsv)

echo "MCP Server URL: https://$MCP_URL/mcp"
curl "https://$MCP_URL/health"

A healthy response here means the SQL MCP Server is fully live. That URL is what goes into PRODUCTS_MCP_URL in the separate agent.py / Cursor project, or into the "Remote MCP Server endpoint" field when wiring this into Microsoft Foundry's portal (Custom MCP Tool, Authentication: Unauthenticated, Require approval: never).


Gotchas already hit and fixed (so you don't re-debug these)

  1. SQL Server region capacity restriction (Free Trial subscriptions can't create SQL servers in some regions, e.g. East US) — fixed by using westus3.
  2. sqlcmd (Go/Homebrew version) panics on certain flag combinations (panic: runtime error: index out of range) — worked around by verifying data via the Azure Portal Query Editor instead of the CLI.
  3. dab init --connection-string "@env(...)" fails with Response file 'env(...)' does not exist — the DAB CLI's arg parser treats a leading @ as a "response file" reference. Fixed by using --connection-string=@env(...) (no space, = sign) instead of a space-separated value.
  4. .NET 8.0.0 not found running dab — DAB 2.0.9 targets .NET 8, but only .NET 9 SDK was installed. Fixed with export DOTNET_ROLL_FORWARD=LatestMajor (run once per terminal session, or prefix each dotnet tool run dab ... command with it).
  5. dab update Products --fields.description "Category: Electronics, Furniture, ..." truncates at the first comma — the CLI parser splits on commas. Fixed by hand-editing the Category field's description value directly in dab-config.json after generation.
  6. Microsoft.ContainerRegistry provider not registered — first-time use of ACR on this subscription. Fixed with:
    az provider register --namespace Microsoft.ContainerRegistry
    az provider register --namespace Microsoft.App
    az provider register --namespace Microsoft.OperationalInsights
    
  7. az acr build fails with TasksOperationsNotAllowed — ACR Tasks (cloud-based builds) are blocked entirely for Azure Free Trial subscriptions; only a Pay-As-You-Go upgrade lifts this. Workaround: build the image locally with Docker (docker build --platform linux/amd64) and push directly with docker tag / docker push instead of az acr build. This is where we are now (Step 3 above).

Related files from earlier work (not in this folder)

  • foundry-mcp-azure-sql-demo.md — full original step-by-step guide (Steps 1–6, including the no-code Foundry portal wiring and the Python SDK path).
  • agent.py, .env.example, requirements.txt — a Microsoft Agent Framework + Claude-in-Foundry agent (separate Cursor project) that consumes this same MCP server via PRODUCTS_MCP_URL.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选