Skip to main content
Glama
KazKozDev
by KazKozDev

Delete Block

delete_element

Remove specific blocks from Markdown documents using hierarchical paths to delete elements like sections, paragraphs, or lists without manual text editing.

Instructions

Removes a block from the document.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYes
pathYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
successNo

Implementation Reference

  • Top-level asynchronous handler function for the 'delete_element' MCP tool. Delegates to the singleton EditTool instance's delete method to perform the actual operation.
    async def delete_element(file_path: str, path: str):
        return await _instance.delete(file_path, path)
  • Core implementation of element deletion within the EditTool class. Loads the document, calls Document.delete(path), performs atomic file write with locking, handles errors with rollback, and updates cache.
    async def delete(self, file_path: str, path: str) -> Dict[str, Any]:
        abs_path = resolve_path(file_path)
        with FileLock(abs_path):
            doc = self.get_doc(file_path)
            result = doc.delete(path)
            if "success" in result:
                try:
                    self._atomic_write(file_path, doc.get_content())
                    self._update_cache_mtime(abs_path)
                    doc.confirm_journal()
                except Exception as e:
                    doc.rollback_last_entry()
                    self.invalidate_cache(file_path)
                    return {"error": f"Failed to write file: {e}"}
        return result
  • JSON Schema definition for the 'delete_element' tool, specifying input parameters (file_path: string, path: string) and output (success: boolean). Part of the tools list returned by list_tools().
        name="delete_element",
        title="Delete Block",
        description="Removes a block from the document.",
        inputSchema={
            "type": "object",
            "properties": {
                "file_path": {"type": "string", "examples": ["./document.md"]},
                "path": {
                    "type": "string",
                    "examples": [
                        "Introduction > paragraph 3",
                        "Old Section",
                        "Deprecated > list 1",
                    ],
                },
            },
            "required": ["file_path", "path"],
            "additionalProperties": False,
        },
        outputSchema={
            "type": "object",
            "properties": {"success": {"type": "boolean"}},
        },
    ),
  • Registration and dispatch handler in the @app.call_tool() method. Matches tool name 'delete_element', extracts arguments, calls the handler function, and returns MCP CallToolResult.
    elif name == "delete_element":
        res = await delete_element(file_path, arguments["path"])
        return CallToolResult(
            content=[TextContent(type="text", text="Element deleted")],
            structuredContent=res,
            isError="error" in res,
        )
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the action ('Removes') but lacks details on permissions needed, whether the deletion is permanent or reversible, error handling, or effects on the document structure. This is insufficient for a destructive operation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, clear sentence with no wasted words, making it highly concise and front-loaded. It efficiently conveys the core action without unnecessary elaboration.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's destructive nature, no annotations, and an output schema (which might cover return values), the description is incomplete. It doesn't address safety, permissions, or error scenarios, leaving significant gaps for an AI agent to understand proper usage.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 0%, so the description must compensate but fails to do so. It doesn't explain what 'file_path' and 'path' parameters mean, their formats, or how they interact. This leaves key input semantics undocumented.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Removes') and the resource ('a block from the document'), making the purpose understandable. However, it doesn't explicitly differentiate from sibling tools like 'delete_item' or 'move_element', which might also remove content, so it doesn't reach the highest score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives such as 'delete_item' or 'move_element', nor does it mention prerequisites like file existence or permissions. It's a basic statement without contextual usage information.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/KazKozDev/markdown-editor-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server