Skip to main content
Glama

analyze_sheet_structure_tool

Analyze Google Sheets structure to identify tables, charts, slicers, drawings, and metadata for quick overview and organization.

Instructions

Analyze a specific sheet's structure - quick overview.

This tool provides a simple overview of what's in the sheet:
- Sheet basic info (name, size, hidden status)
- Tables (count, names, ranges, sizes)
- Charts (count, IDs, positions)
- Slicers (count, IDs, positions)
- Drawings (count, IDs, positions)
- Developer metadata (count, keys, values)
- Summary (total elements, sheet type, frozen panes)

Args:
    spreadsheet_name: The name of the Google Spreadsheet
    sheet_name: Name of the specific sheet to analyze

Returns:
    JSON string with simplified structure overview

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
spreadsheet_nameYesThe name of the Google Spreadsheet
sheet_nameYesName of the specific sheet to analyze

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Core handler function that orchestrates the sheet structure analysis: resolves spreadsheet ID, performs analysis, formats response as JSON.
    def analyze_sheet_structure_handler(
        drive_service,
        sheets_service,
        spreadsheet_name: str,
        sheet_name: str
    ) -> str:
        """
        Handler for analyzing sheet structure - simplified overview with separated data detection.
        """
        try:
            # Get spreadsheet ID
            spreadsheet_id = get_spreadsheet_id_by_name(drive_service, spreadsheet_name)
            
            # Perform simple analysis
            analysis = analyze_sheet_structure_simple(
                sheets_service=sheets_service,
                spreadsheet_id=spreadsheet_id,
                sheet_name=sheet_name
            )
            
            result = {
                "success": True,
                "spreadsheet_name": spreadsheet_name,
                "sheet_name": sheet_name,
                "analysis": analysis,
                "message": f"Successfully analyzed sheet structure '{sheet_name}' in '{spreadsheet_name}'"
            }
            
            return compact_json_response(result)
            
        except Exception as e:
            error_result = {
                "success": False,
                "spreadsheet_name": spreadsheet_name,
                "sheet_name": sheet_name,
                "message": f"Error analyzing sheet structure: {str(e)}"
            }
            return compact_json_response(error_result)
  • MCP tool registration with @mcp.tool(), input schema via pydantic Field, documentation, and wrapper that initializes services and delegates to core handler.
    @mcp.tool()
    def analyze_sheet_structure_tool(
        spreadsheet_name: str = Field(..., description="The name of the Google Spreadsheet"),
        sheet_name: str = Field(..., description="Name of the specific sheet to analyze")
    ) -> str:
        """
        Analyze a specific sheet's structure - quick overview.
        
        This tool provides a simple overview of what's in the sheet:
        - Sheet basic info (name, size, hidden status)
        - Tables (count, names, ranges, sizes)
        - Charts (count, IDs, positions)
        - Slicers (count, IDs, positions)
        - Drawings (count, IDs, positions)
        - Developer metadata (count, keys, values)
        - Summary (total elements, sheet type, frozen panes)
        
        Args:
            spreadsheet_name: The name of the Google Spreadsheet
            sheet_name: Name of the specific sheet to analyze
        
        Returns:
            JSON string with simplified structure overview
        """
        sheets_service, drive_service = _get_google_services()
        return analyze_sheet_structure_handler(drive_service, sheets_service, spreadsheet_name, sheet_name)
  • Key helper function that makes the Google Sheets API call to retrieve sheet structure data (properties, tables, charts, etc.) and finds the target sheet.
    def analyze_sheet_structure_simple(
        sheets_service,
        spreadsheet_id: str,
        sheet_name: str
    ) -> Dict[str, Any]:
        """
        Simple analysis of a sheet structure - quick overview of elements and data.
        
        Args:
            sheets_service: Google Sheets API service
            spreadsheet_id: ID of the spreadsheet
            sheet_name: Name of the sheet to analyze
        
        Returns:
            Dictionary with simple sheet structure and data overview
        """
        try:
            # Get comprehensive spreadsheet data including values
            result = sheets_service.spreadsheets().get(
                spreadsheetId=spreadsheet_id,
                fields="sheets.properties,sheets.charts,sheets.tables,sheets.slicers,sheets.developerMetadata,sheets.drawings,sheets.data"
            ).execute()
            
            sheets = result.get('sheets', [])
            
            # Find the specific sheet
            target_sheet = None
            for sheet in sheets:
                props = sheet.get('properties', {})
                if props.get('title') == sheet_name:
                    target_sheet = sheet
                    break
            
            if not target_sheet:
                raise RuntimeError(f"Sheet '{sheet_name}' not found in spreadsheet")
            
            return process_simple_sheet_analysis(target_sheet, sheets_service, spreadsheet_id, sheet_name)
            
        except HttpError as error:
            error_details = error.error_details[0] if hasattr(error, 'error_details') and error.error_details else {}
            error_message = error_details.get('message', str(error))
            raise RuntimeError(f"Google Sheets API error: {error_message}")
        except Exception as error:
            raise RuntimeError(f"Unexpected error analyzing sheet structure: {str(error)}")
  • Pydantic input schema definition for the tool parameters.
    spreadsheet_name: str = Field(..., description="The name of the Google Spreadsheet"),
    sheet_name: str = Field(..., description="Name of the specific sheet to analyze")
Behavior3/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 effectively describes what the tool does (provides a simple overview with specific elements listed) and hints at its read-only nature by focusing on analysis. However, it lacks details on potential limitations (e.g., performance with large sheets, authentication needs, or error handling), which would enhance transparency for a tool with no annotations.

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 appropriately sized and front-loaded, starting with a clear purpose statement followed by a bulleted list of what's included. The 'Args' and 'Returns' sections are structured for quick reference. However, the bulleted list is somewhat lengthy and could be condensed without losing essential information, slightly reducing efficiency.

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 (simple analysis with 2 parameters), 100% schema coverage, and the presence of an output schema (implied by 'Returns: JSON string'), the description is complete enough. It clearly outlines what the tool analyzes, the required inputs, and the output format, providing sufficient context for an agent to invoke it correctly without needing to explain return values in detail.

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

Parameters4/5

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

The schema description coverage is 100%, so the input schema already documents both parameters ('spreadsheet_name' and 'sheet_name') with clear descriptions. The description adds minimal value by restating the parameter purposes in the 'Args' section, but it does not provide additional context (e.g., format examples or constraints). Since there are only 2 parameters and schema coverage is complete, a baseline of 3 is appropriate, but the explicit listing in 'Args' slightly enhances clarity, warranting a 4.

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 clearly states the tool's purpose with specific verbs ('analyze', 'provides') and resources ('sheet's structure', 'quick overview'). It distinguishes itself from siblings by focusing on structural analysis rather than data retrieval, table manipulation, or spreadsheet management, as evidenced by the list of sibling tools like 'get_table_data_tool' or 'update_table_cells_by_range_tool'.

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

Usage Guidelines3/5

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

The description implies usage by specifying it's for a 'quick overview' of sheet structure, suggesting it's for initial assessment rather than detailed analysis. However, it does not explicitly state when to use this tool versus alternatives (e.g., 'get_table_metadata_tool' or 'get_sheet_cells_by_range_tool'), nor does it provide exclusions or prerequisites, leaving some ambiguity for the agent.

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/henilcalagiya/google-sheets-mcp'

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