Skip to main content
Glama

inspect_data_around

Analyze data patterns and relationships around specific coordinates for validation, error investigation, and contextual understanding in CSV datasets.

Instructions

Inspect data around a specific coordinate for contextual analysis.

Examines the data surrounding a specific cell to understand context, patterns, and relationships. Useful for data validation, error investigation, and understanding local data patterns.

Returns: Contextual view of data around the specified coordinates

Inspection Features: 📍 Center Point: Specified cell as reference point 🔍 Radius View: Configurable area around center cell 📊 Data Context: Surrounding values for pattern analysis 🎯 Coordinates: Clear row/column reference system

Examples: # Inspect around a specific data point context = await inspect_data_around(ctx, row=50, column_name="price", radius=3)

# Minimal context view
context = await inspect_data_around(ctx, row=10,
                                  column_name="status", radius=1)

AI Workflow Integration: 1. Error investigation and data quality assessment 2. Pattern recognition in local data areas 3. Understanding data relationships and context 4. Validation of data transformations and corrections

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
rowYesRow index to center the inspection (0-based)
column_nameYesName of the column to center on
radiusNoNumber of rows/columns to include around center point

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
radiusYes
successNoWhether operation completed successfully
surrounding_dataYes
center_coordinatesYes

Implementation Reference

  • Main handler function implementing the inspect_data_around tool. It fetches the dataframe from session, validates the column, slices data around the specified row and column within the radius, processes the slice into records compatible with DataPreview, and returns InspectDataResult.
    async def inspect_data_around(
        ctx: Annotated[Context, Field(description="FastMCP context for session access")],
        row: Annotated[int, Field(description="Row index to center the inspection (0-based)")],
        column_name: Annotated[str, Field(description="Name of the column to center on")],
        radius: Annotated[
            int,
            Field(description="Number of rows/columns to include around center point"),
        ] = 2,
    ) -> InspectDataResult:
        """Inspect data around a specific coordinate for contextual analysis.
    
        Examines the data surrounding a specific cell to understand context,
        patterns, and relationships. Useful for data validation, error investigation,
        and understanding local data patterns.
    
        Returns:
            Contextual view of data around the specified coordinates
    
        Inspection Features:
            📍 Center Point: Specified cell as reference point
            🔍 Radius View: Configurable area around center cell
            📊 Data Context: Surrounding values for pattern analysis
            🎯 Coordinates: Clear row/column reference system
    
        Examples:
            # Inspect around a specific data point
            context = await inspect_data_around(ctx, row=50,
                                              column_name="price", radius=3)
    
            # Minimal context view
            context = await inspect_data_around(ctx, row=10,
                                              column_name="status", radius=1)
    
        AI Workflow Integration:
            1. Error investigation and data quality assessment
            2. Pattern recognition in local data areas
            3. Understanding data relationships and context
            4. Validation of data transformations and corrections
    
        """
        # Get session_id from FastMCP context
        session_id = ctx.session_id
        _session, df = get_session_data(session_id)
    
        # Handle column specification
        column = column_name
        if isinstance(column, int):
            if column < 0 or column >= len(df.columns):
                raise InvalidParameterError(
                    "column_name",  # noqa: EM101
                    column,
                    f"integer between 0 and {len(df.columns) - 1}",
                )
            column_name = df.columns[column]
            col_index = column
        else:
            if column not in df.columns:
                raise ColumnNotFoundError(column, df.columns.tolist())
            column_name = column
            col_index_result = df.columns.get_loc(column)
            col_index = col_index_result if isinstance(col_index_result, int) else 0
    
        # Calculate bounds
        row_start = max(0, row - radius)
        row_end = min(len(df), row + radius + 1)
        col_start = max(0, col_index - radius)
        col_end = min(len(df.columns), col_index + radius + 1)
    
        # Get column slice
        cols_slice = df.columns[col_start:col_end].tolist()
    
        # Get data slice
        data_slice = df.iloc[row_start:row_end][cols_slice]
    
        # Convert to records with row indices
        records = []
        for _, (orig_idx, row_data) in enumerate(data_slice.iterrows()):
            # Handle different index types from iterrows safely
            row_index_val = int(orig_idx) if isinstance(orig_idx, int) else 0
            record: dict[str, CsvCellValue] = {"__row_index__": row_index_val}
            record.update(row_data.to_dict())
    
            # Handle pandas/numpy types
            for key, value in record.items():
                if key == "__row_index__":
                    continue
                if pd.isna(value):
                    record[key] = None
                elif isinstance(value, pd.Timestamp):
                    record[key] = str(value)
                elif hasattr(value, "item"):
                    record[key] = value.item()
    
            records.append(record)
    
        # Create DataPreview from the records
        surrounding_data = DataPreview(
            rows=records,
            row_count=len(records),
            column_count=len(cols_slice),
            truncated=False,
        )
    
        return InspectDataResult(
            center_coordinates={"row": row, "column": column_name},
            surrounding_data=surrounding_data,
            radius=radius,
        )
  • Pydantic output schema/model for the inspect_data_around tool response, defining the structure of center_coordinates, surrounding_data (DataPreview), and radius.
    class InspectDataResult(BaseToolResponse):
        """Response model for contextual data inspection."""
    
        center_coordinates: dict[str, Any]
        surrounding_data: DataPreview
        radius: int
  • Registration of the inspect_data_around handler as an MCP tool on the discovery_server FastMCP instance.
    discovery_server.tool(name="inspect_data_around")(inspect_data_around)
Behavior4/5

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

With no annotations provided, the description carries full burden and does well by explaining what the tool returns ('contextual view of data around the specified coordinates'), its inspection features (center point, radius view, data context), and practical applications. It doesn't mention performance implications, rate limits, or data size constraints, but provides substantial behavioral context beyond basic functionality.

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 (purpose, returns, features, examples, workflow integration) and uses emojis for visual organization. While somewhat lengthy, every section adds value. The front-loaded purpose statement is strong, though the later sections could be more condensed while maintaining clarity.

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 moderate complexity, 100% schema coverage, and presence of an output schema, the description provides excellent contextual completeness. It covers purpose, usage scenarios, behavioral characteristics, examples, and integration workflows. The output schema existence means the description doesn't need to detail return values, and it provides all necessary context for effective tool selection and use.

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

Parameters3/5

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

The schema description coverage is 100%, providing complete parameter documentation. The description adds minimal value beyond the schema, mentioning 'configurable area around center cell' for radius and 'clear row/column reference system' for coordinates, but doesn't provide additional semantic context about parameter interactions or edge cases. This meets the baseline 3 for high schema coverage.

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 ('inspect', 'examines') and resources ('data around a specific coordinate'), distinguishing it from siblings like get_cell_value (single cell) or get_row_data (entire row). It explicitly mentions 'contextual analysis' and 'understanding local data patterns', which differentiates it from broader analysis tools like profile_data or get_data_summary.

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 guidance with 'Useful for data validation, error investigation, and understanding local data patterns' and 'AI Workflow Integration' section listing specific scenarios (error investigation, pattern recognition, etc.). It clearly indicates when to use this tool versus alternatives like get_cell_value (single point) or get_row_data (entire row) by emphasizing the 'surrounding' 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

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/jonpspri/databeak'

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