Skip to content

[Enh]: Add DML tool: delete_record #2830

@JerryNixon

Description

@JerryNixon

What?

delete_record

A tool to allow an agent to delete a single record.

Behavior

  1. Behaves most like the GraphQL flow

  2. Entity permissions are enforced

    • Never bypass permissions.
    • On violation, return a standard DAB response payload with an error message (e.g. "You do not have permission to delete this record").
    • Do not signal errors via HTTP status codes.
  3. Key handling

    • Keys use the entity’s mapped aliases.
    • Keys are required in the request.
    • Keys uniquely identify the record to delete.
    • If no record matches the supplied keys, return a DAB error payload (e.g. "No record found with the given key").
  4. Returns the delete result

    • Follow the current GraphQL delete behavior.
    • Standard response is { "status": "okay" } on success.
  5. Field handling

    • Fields are not valid for this request.

How

  • Add delete_record MCP tool through GraphQL flow
  • Add config property (runtime.mcp.dml-tools.delete-record.enabled=true)
  • Update JSON Schema with runtime.mcp.dml-tools.delete-record.enabled
  • Obey configuration (runtime.mcp.dml-tools.delete-record.enabled=true)
  • Add CLI dab configure --runtime.mcp.dml-tools.delete-record.enabled true
  • Update dab validate (warn when delete-record.enabled and not mcp.enabled)

Tool method

/// <summary>
/// Deletes a single record from the specified entity. 
/// Keys must uniquely identify the record. 
/// Returns success or error. 
/// </summary>
Task<DabResponse> DeleteRecordAsync(
    [Description("The entity name of the record to delete. "
               + "Must match an entity returned by list_entities with delete=true. Required.")]
    string entity,

    [Description("A dictionary of key/value pairs that uniquely identify the record to delete. "
               + "Keys must match those defined in entity metadata. Required.")]
    IDictionary<string, object?> keys);

Parameters

  • entity (string, required)
if (string.IsNullOrWhiteSpace(entity))
    throw new ArgumentException("Entity is required", nameof(entity));
if (!entityMetadata.Delete)
    throw new UnauthorizedAccessException($"Entity {entity} cannot be deleted.");
  • keys (IDictionary<string, object?>, required)
if (keys == null || keys.Count == 0)
    throw new ArgumentException("Keys are required to delete a record", nameof(keys));

foreach (var key in keys.Keys)
{
    if (!entityMetadata.Keys.Contains(key))
        throw new ArgumentException($"Invalid key: {key}", nameof(keys));
}

Example call

await DeleteRecordAsync(
    entity: "User",
    keys: new Dictionary<string, object?> {
        { "Id", 123 }
    });

Output payload

This is a standard Data API builder (DAB) payload which includes errors.

Why?

This allows agents to delete existing records.

Configuration

Image

Command line

Add dab configure --runtime.mcp.dml-tools.delete-record.enabled true

Metadata

Metadata

Assignees

Labels

mcp-servermssqlan issue thats specific to mssql

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions