Skip to main content
Glama

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

Implementation Reference

  • The async handler function for the 'delete_element' tool that delegates execution to the EditTool instance's delete method.
    async def delete_element(file_path: str, path: str): return await _instance.delete(file_path, path)
  • Core logic in EditTool class for deleting an element by path, updating the document, and persisting changes to file.
    async def delete(self, file_path: str, path: str) -> Dict[str, Any]: doc = self.get_doc(file_path) result = doc.delete(path) if "success" in result: with open(file_path, 'w', encoding='utf-8') as f: f.write(doc.get_content()) return result
  • Registration of the 'delete_element' tool in the list_tools() handler, including metadata, input schema, and output schema.
    Tool( 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"} } } ),
  • Dispatch logic in call_tool() that invokes the delete_element handler when the tool is called.
    elif name == "delete_element": res = await delete_element(file_path, arguments["path"]) return {"content": [TextContent(type="text", text="Element deleted")], "structuredContent": res, "isError": "error" in res}

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