Skip to main content
Glama
ZatesloFL

Google Workspace MCP Server

by ZatesloFL

debug_table_structure

Analyze and troubleshoot table structure in Google Docs to resolve data placement errors, verify dimensions, and plan data formatting. Identifies cell positions, content, and insertion points for precise debugging.

Instructions

ESSENTIAL DEBUGGING TOOL - Use this whenever tables don't work as expected.

USE THIS IMMEDIATELY WHEN:

  • Table population put data in wrong cells

  • You get "table not found" errors

  • Data appears concatenated in first cell

  • Need to understand existing table structure

  • Planning to use populate_existing_table

WHAT THIS SHOWS YOU:

  • Exact table dimensions (rows × columns)

  • Each cell's position coordinates (row,col)

  • Current content in each cell

  • Insertion indices for each cell

  • Table boundaries and ranges

HOW TO READ THE OUTPUT:

  • "dimensions": "2x3" = 2 rows, 3 columns

  • "position": "(0,0)" = first row, first column

  • "current_content": What's actually in each cell right now

  • "insertion_index": Where new text would be inserted in that cell

WORKFLOW INTEGRATION:

  1. After creating table → Use this to verify structure

  2. Before populating → Use this to plan your data format

  3. After population fails → Use this to see what went wrong

  4. When debugging → Compare your data array to actual table structure

Args: user_google_email: User's Google email address document_id: ID of the document to inspect table_index: Which table to debug (0 = first table, 1 = second table, etc.)

Returns: str: Detailed JSON structure showing table layout, cell positions, and current content

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
document_idYes
table_indexNo
user_google_emailYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The core handler function for the 'debug_table_structure' tool. Decorated with @server.tool() for MCP registration. Fetches document via Google Docs API, uses find_tables helper to locate tables, then extracts detailed cell information including positions, content, and ranges, returning a JSON-formatted debug output.
    @server.tool()
    @handle_http_errors("debug_table_structure", is_read_only=True, service_type="docs")
    @require_google_service("docs", "docs_read")
    async def debug_table_structure(
        service,
        user_google_email: str,
        document_id: str,
        table_index: int = 0,
    ) -> str:
        """
        ESSENTIAL DEBUGGING TOOL - Use this whenever tables don't work as expected.
    
        USE THIS IMMEDIATELY WHEN:
        - Table population put data in wrong cells
        - You get "table not found" errors
        - Data appears concatenated in first cell
        - Need to understand existing table structure
        - Planning to use populate_existing_table
    
        WHAT THIS SHOWS YOU:
        - Exact table dimensions (rows × columns)
        - Each cell's position coordinates (row,col)
        - Current content in each cell
        - Insertion indices for each cell
        - Table boundaries and ranges
    
        HOW TO READ THE OUTPUT:
        - "dimensions": "2x3" = 2 rows, 3 columns
        - "position": "(0,0)" = first row, first column
        - "current_content": What's actually in each cell right now
        - "insertion_index": Where new text would be inserted in that cell
    
        WORKFLOW INTEGRATION:
        1. After creating table → Use this to verify structure
        2. Before populating → Use this to plan your data format
        3. After population fails → Use this to see what went wrong
        4. When debugging → Compare your data array to actual table structure
    
        Args:
            user_google_email: User's Google email address
            document_id: ID of the document to inspect
            table_index: Which table to debug (0 = first table, 1 = second table, etc.)
    
        Returns:
            str: Detailed JSON structure showing table layout, cell positions, and current content
        """
        logger.debug(f"[debug_table_structure] Doc={document_id}, table_index={table_index}")
    
        # Get the document
        doc = await asyncio.to_thread(
            service.documents().get(documentId=document_id).execute
        )
    
        # Find tables
        tables = find_tables(doc)
        if table_index >= len(tables):
            return f"Error: Table index {table_index} not found. Document has {len(tables)} table(s)."
    
        table_info = tables[table_index]
    
        import json
    
        # Extract detailed cell information
        debug_info = {
            'table_index': table_index,
            'dimensions': f"{table_info['rows']}x{table_info['columns']}",
            'table_range': f"[{table_info['start_index']}-{table_info['end_index']}]",
            'cells': []
        }
    
        for row_idx, row in enumerate(table_info['cells']):
            row_info = []
            for col_idx, cell in enumerate(row):
                cell_debug = {
                    'position': f"({row_idx},{col_idx})",
                    'range': f"[{cell['start_index']}-{cell['end_index']}]",
                    'insertion_index': cell.get('insertion_index', 'N/A'),
                    'current_content': repr(cell.get('content', '')),
                    'content_elements_count': len(cell.get('content_elements', []))
                }
                row_info.append(cell_debug)
            debug_info['cells'].append(row_info)
    
        link = f"https://docs.google.com/document/d/{document_id}/edit"
        return f"Table structure debug for table {table_index}:\n\n{json.dumps(debug_info, indent=2)}\n\nLink: {link}"
  • Helper function used by the tool to parse document structure and extract all tables with their dimensions, positions, and cell details from the raw Google Docs API response.
    def find_tables(doc_data: dict[str, Any]) -> list[dict[str, Any]]:
        """
        Find all tables in the document with their positions and dimensions.
        
        Args:
            doc_data: Raw document data from Google Docs API
        
        Returns:
            List of table information dictionaries
        """
        tables = []
        structure = parse_document_structure(doc_data)
        
        for idx, table_info in enumerate(structure['tables']):
            tables.append({
                'index': idx,
                'start_index': table_info['start_index'],
                'end_index': table_info['end_index'],
                'rows': table_info['rows'],
                'columns': table_info['columns'],
                'cells': table_info['cells']
            })
        
        return tables
Behavior4/5

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

With no annotations provided, the description carries the full burden and does so well by detailing what the tool returns (e.g., 'Exact table dimensions,' 'Current content in each cell'), how to interpret the output (e.g., 'dimensions: "2x3"'), and its read-only nature implied by debugging use. It lacks explicit rate limits or auth needs, but covers core behavior thoroughly.

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

Conciseness4/5

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

The description is well-structured with clear sections (e.g., 'USE THIS IMMEDIATELY WHEN,' 'HOW TO READ THE OUTPUT,' 'WORKFLOW INTEGRATION') and uses bullet points for readability. It is slightly verbose but every sentence adds value, such as explaining output interpretation and integration steps, making it efficient for an agent.

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

Completeness5/5

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

Given the tool's complexity (debugging table structure), no annotations, 0% schema coverage, and an output schema provided, the description is complete. It explains purpose, usage, parameters, output format (e.g., 'Detailed JSON structure'), and integration, leaving no gaps for the agent to understand and invoke the tool correctly.

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

Parameters5/5

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

Schema description coverage is 0%, but the description compensates fully by explaining all three parameters in the 'Args' section: 'user_google_email: User's Google email address,' 'document_id: ID of the document to inspect,' and 'table_index: Which table to debug (0 = first table, 1 = second table, etc.).' This adds crucial meaning beyond the bare schema.

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

Purpose5/5

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

The description explicitly states the tool's purpose as an 'ESSENTIAL DEBUGGING TOOL' for table structure issues, specifying it shows table dimensions, cell positions, content, and insertion indices. It clearly distinguishes from sibling tools like 'create_table_with_data' or 'populate_existing_table' by focusing on inspection rather than creation or modification.

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

Usage Guidelines5/5

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

The description provides explicit usage scenarios with bullet points (e.g., 'Table population put data in wrong cells,' 'Need to understand existing table structure') and a detailed workflow integration section (e.g., 'After creating table → Use this to verify structure'). It clearly differentiates when to use this tool versus alternatives like 'populate_existing_table' for planning.

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/ZatesloFL/google_workspace_mcp'

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