Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Important
SQL Model Context Protocol (MCP) Server is available in Data API builder version 1.7 and later.
Note
The SQL MCP Server 2.0 functionality described in this section is currently in preview and might change before general availability. For more information, see What's new in version 2.0.
SQL MCP Server exposes tables and views through generic data manipulation language (DML) tools. For stored procedures, you can go further: set custom-tool: true on the entity so the procedure appears in the MCP tool list as a named, purpose-built tool. AI agents discover it by name, see its description, and call it directly—no SQL required.
Important
Custom tool names are derived from the entity name but converted to snake_case. For example, an entity named GetProductById becomes get_product_by_id in the MCP tool list. Use the snake_case name when calling the tool. The PascalCase entity name is not accepted as a tool name.
The rest of this article shows how to add, configure, and test a custom MCP tool backed by a stored procedure.
Prerequisites
- Data API builder version 2.0 or later
- SQL Server database with at least one stored procedure
- An existing
dab-config.jsonwith MCP enabled - DAB CLI installed
Enable MCP in your configuration
If you haven't already, enable MCP in the runtime section.
dab configure --runtime.mcp.enabled true
This adds the following to your dab-config.json:
{
"runtime": {
"mcp": {
"enabled": true
}
}
}
Add the stored procedure as a custom tool
Use dab add with --source.type stored-procedure and --mcp.custom-tool true.
dab add GetProductById \
--source dbo.get_product_by_id \
--source.type "stored-procedure" \
--permissions "anonymous:execute" \
--mcp.custom-tool true
This produces the following entity in dab-config.json:
{
"entities": {
"GetProductById": {
"source": {
"object": "dbo.get_product_by_id",
"type": "stored-procedure"
},
"graphql": {
"enabled": true,
"operation": "mutation",
"type": {
"singular": "GetProductById",
"plural": "GetProductByIds"
}
},
"rest": {
"enabled": true,
"methods": [
"post"
]
},
"permissions": [
{
"role": "anonymous",
"actions": [
{
"action": "execute"
}
]
}
],
"mcp": {
"custom-tool": true
}
}
}
}
Important
The custom-tool property is only valid on stored-procedure entities. Setting it on a table or view entity results in a configuration error at startup.
Add a description to improve agent accuracy
Without a description, agents see only the technical name GetProductById. With a description, they understand what it does and when to use it.
dab update GetProductById \
--description "Returns full product details including pricing and inventory for a given product ID"
{
"entities": {
"GetProductById": {
"description": "Returns full product details including pricing and inventory for a given product ID",
"source": {
"object": "dbo.get_product_by_id",
"type": "stored-procedure"
},
"fields": [],
"graphql": {
"enabled": true,
"operation": "mutation",
"type": {
"singular": "GetProductById",
"plural": "GetProductByIds"
}
},
"rest": {
"enabled": true,
"methods": [
"post"
]
},
"permissions": [
{
"role": "anonymous",
"actions": [
{
"action": "execute"
}
]
}
],
"mcp": {
"custom-tool": true
}
}
}
}
Verify the tool appears in the tool list
Start DAB and call the tools/list MCP endpoint to confirm the tool is registered.
dab start
When an MCP client calls tools/list, the response includes your custom tool alongside the DML tools:
{
"tools": [
{
"name": "get_product_by_id",
"description": "Returns full product details including pricing and inventory for a given product ID",
"inputSchema": {
"type": "object",
"properties": {}
}
}
]
}
Note
The tool name uses snake_case (for example, get_product_by_id for the GetProductById entity). The inputSchema currently returns empty properties. Agents rely on the tool description and describe_entities to determine the correct parameters.
Configure multiple custom tools
You can register multiple stored procedures as custom tools in the same configuration.
dab add SearchProducts \
--source dbo.search_products \
--source.type "stored-procedure" \
--permissions "anonymous:execute" \
--mcp.custom-tool true \
--description "Full-text search across product names and descriptions"
dab add GetOrderSummary \
--source dbo.get_order_summary \
--source.type "stored-procedure" \
--permissions "authenticated:execute" \
--mcp.custom-tool true \
--description "Returns order totals and line item counts for a given customer"
Control which roles can call the tool
Custom tools respect the same role-based access control (RBAC) as all other DAB entities. Set the permissions on the entity to restrict which roles can execute the procedure.
{
"entities": {
"GetOrderSummary": {
"source": {
"object": "dbo.get_order_summary",
"type": "stored-procedure"
},
"graphql": {
"enabled": true,
"operation": "mutation",
"type": {
"singular": "GetOrderSummary",
"plural": "GetOrderSummarys"
}
},
"rest": {
"enabled": true,
"methods": [
"post"
]
},
"permissions": [
{
"role": "authenticated",
"actions": [
{
"action": "execute"
}
]
}
],
"mcp": {
"custom-tool": true
}
}
}
}
When an agent calls with the anonymous role, get_order_summary doesn't appear in tools/list and any direct tools/call returns a permission error.
Disable a custom tool without removing it
Set custom-tool to false to hide the tool from agents without deleting the entity.
dab update GetProductById \
--mcp.custom-tool false
The entity remains in the configuration and you can re-enable it later by setting --mcp.custom-tool true.