# Bulk deletes have a guard

**A delete tool that takes many targets must not treat an empty, missing or match-all selector as "everything" unless the caller opts in explicitly, and should offer a dry run and cap the batch size (MWS-TGT-2).**

Check `surface-bulk-delete` · Write-surface design · default severity: attention · rubric 2.1.0. Last verified against MCP Write-Safety Requirements 0.9 on 2026-11-18.

## What fails

The delete tool takes an array or filter of targets and has no dry-run or confirm argument, so one wrong selector removes many objects.

## The rule

> A tool that deletes or bulk-updates MUST NOT treat an empty, missing or match-all selector, or the path of a container, as selecting every object in the container or collection unless the caller sets an explicit argument that opts in.

Source: [MCP Write-Safety Requirements 0.9](https://isokron.ai/mws#mws-tgt-2)

## How to fix it

Add a dry-run argument, refuse an empty or match-all selector unless an explicit opt-in is set, and cap the number of items per call.

1. Refuse an empty, missing or wildcard selector unless an explicit all argument is true.
2. Add dry_run (default true) and return what would be deleted.
3. Cap the number of items per call, for example 100.

### TypeScript SDK

```ts
import { McpServer } from '@modelcontextprotocol/server';
import * as z from 'zod';

const server = new McpServer({ name: 'issues', version: '1.0.0' });

server.registerTool(
  'delete_issues',
  {
    title: 'Delete issues',
    description: 'Delete up to 100 issues by ID. With dry_run true (the default) returns what would be deleted. An empty list deletes nothing. Use only when the user asks to delete specific issues.',
    inputSchema: z.strictObject({
      issue_ids: z.array(z.string()).min(1).max(100).describe('Issue IDs to delete, 1 to 100'),
      dry_run: z.boolean().default(true).describe('true: preview only; false: delete'),
    }),
    annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: false },
  },
  async ({ issue_ids, dry_run }) => ({ content: [{ type: 'text', text: 'Done' }] }),
);
```

### Python SDK

```python
from typing import Annotated

from pydantic import Field
from mcp.server.mcpserver import MCPServer
from mcp.types import ToolAnnotations

server = MCPServer("issues")

@server.tool(
    title="Delete issues",
    annotations=ToolAnnotations(readOnlyHint=False, destructiveHint=True, openWorldHint=False),
)
def delete_issues(
    issue_ids: Annotated[list[str], Field(description="Issue IDs to delete, 1 to 100", min_length=1, max_length=100)],
    dry_run: Annotated[bool, Field(description="true: preview only; false: delete")] = True,
) -> str:
    """Delete up to 100 issues by ID. With dry_run true (the default) returns what would be deleted. An empty list deletes nothing. Use only when the user asks to delete specific issues."""
    return "Done"
```

## Questions

### How does a bulk delete go wrong with an agent?

A filter built from a misread request, an empty list that the backend reads as "no filter", or a path that names the container instead of an item: each can select everything.

### Is a confirm argument enough?

It helps, but a dry run shows the count and the items before anything is removed, which a yes/no confirm does not.

## Related checks

- [Delete tools take a confirm or dry-run argument](https://isokron.ai/mcp-check/checks/surface-delete-guard)
- [Deleting tools are not marked non-destructive](https://isokron.ai/mcp-check/checks/annot-delete-marked-safe)
- [Update and delete tools take a version or precondition](https://isokron.ai/mcp-check/checks/surface-version-guard)
- [Write-surface design for MCP tools](https://isokron.ai/mcp-check/checks/write-safety)

## Further reading

- [MWS-TGT-2: no implicit match-all](https://isokron.ai/mws#mws-tgt-2)
- [MCP write safety](https://isokron.ai/write-safety)

Counts toward: Write-surface design.

Rubric: https://isokron.ai/mcp-check/rubric

Check your tool list: https://isokron.ai/mcp-check
