Skip to main content
Glama

delete_table

Remove a specific table from a Microsoft Word document by specifying the filename and table index, ensuring precise document editing and management.

Instructions

Delete a table from a document.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filenameYes
table_indexYes

Implementation Reference

  • The core handler function that executes the delete_table tool: validates inputs, loads the Word document using python-docx, removes the specified table by index from the document body, saves the modified document, and returns a status message.
    async def delete_table(filename: str, table_index: int) -> str:
        """Delete a table from a document.
        
        Args:
            filename: Path to the Word document
            table_index: Index of the table to delete (0-based)
        """
        filename = ensure_docx_extension(filename)
        
        if not os.path.exists(filename):
            return f"Document {filename} does not exist"
        
        # Check if file is writeable
        is_writeable, error_message = check_file_writeable(filename)
        if not is_writeable:
            return f"Cannot modify document: {error_message}. Consider creating a copy first."
        
        try:
            doc = Document(filename)
            
            # Validate table index
            if table_index < 0 or table_index >= len(doc.tables):
                return f"Invalid table index. Document has {len(doc.tables)} tables (0-{len(doc.tables)-1})."
            
            # Delete the table by removing its element from the document
            table = doc.tables[table_index]
            table._tbl.getparent().remove(table._tbl)
            
            doc.save(filename)
            return f"Table at index {table_index} deleted successfully."
        except Exception as e:
            return f"Failed to delete table: {str(e)}"
  • The registration of the 'delete_table' tool using FastMCP's @mcp.tool() decorator in the main server file. This wrapper function defines the tool interface and delegates execution to the implementation in content_tools.delete_table.
    @mcp.tool()
    async def delete_table(filename: str, table_index: int):
        """Delete a table from a document."""
        return await content_tools.delete_table(filename, table_index)
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 is 'Delete,' implying a destructive mutation, but does not clarify permissions needed, whether deletion is permanent or reversible, error handling (e.g., if the table doesn't exist), or side effects. This is inadequate for a destructive tool with zero annotation coverage.

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 zero wasted words. It is front-loaded with the core action and resource, making it highly efficient. Every word earns its place, though it could benefit from additional context.

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 complexity (destructive operation with 2 parameters), lack of annotations, and no output schema, the description is incomplete. It does not address behavioral aspects like safety, parameter usage, or expected outcomes, leaving significant gaps for an AI agent to invoke it correctly.

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?

Schema description coverage is 0%, so the description must compensate by explaining parameters. It does not mention 'filename' or 'table_index' at all, leaving both parameters undocumented. The description adds no meaning beyond the schema, failing to clarify what a 'table_index' represents or how to specify the filename.

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 ('Delete') and resource ('a table from a document'), making the purpose immediately understandable. It distinguishes from siblings like 'delete_paragraph' by specifying the target resource as a table, but does not explicitly contrast with other deletion tools or explain why to choose this over alternatives like 'format_table' for modification.

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. It does not mention prerequisites (e.g., needing an existing table), exclusions (e.g., not for deleting other elements), or sibling tools like 'delete_paragraph' for different operations. Usage is implied by the action but lacks explicit context.

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

Related 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/franlealp1/mcp-word'

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