Skip to main content
Glama

analysis_area

Find optimal stargazing spots by analyzing geographic areas for darkness, accessibility, and viewing conditions. Specify coordinates to identify locations with minimal light pollution and road access.

Instructions

Analyze a geographic area for suitable stargazing locations.

This tool searches for dark, accessible locations with good viewing conditions. Results are cached based on search parameters.

Args: south, west, north, east: Bounding box coordinates. max_locations: Maximum number of candidate locations to find (before pagination). min_height_diff: Minimum elevation difference for prominence. road_radius_km: Search radius for road access. network_type: Type of road network ('drive', 'walk', etc.). db_config_path: Optional path to database config. page: Page number (1-based). page_size: Number of results per page.

Returns: Dict with keys "data", "_meta". "data" contains: - items: List of location results for the current page. - total: Total number of locations found. - page: Current page number. - page_size: Current page size. - resource_id: Cache key for these search parameters.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
southYes
westYes
northYes
eastYes
max_locationsNo
min_height_diffNo
road_radius_kmNo
network_typeNodrive
db_config_pathNo
pageNo
page_sizeNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function for the 'analysis_area' tool. It is decorated with @mcp.tool() for registration and implements the core logic: caching results based on geographic parameters, computing stargazing locations using StargazingPlaceFinder if cache miss, serializing results, applying pagination, and formatting the response.
    @mcp.tool()
    async def analysis_area(
        south: float, west: float, north: float, east: float,
        max_locations: int = 30,
        min_height_diff: float = 100.0,
        road_radius_km: float = 10.0,
        network_type: str = 'drive',
        db_config_path: str = None,
        page: int = 1,
        page_size: int = 10
    ) -> Dict[str, Any]:
        """Analyze a geographic area for suitable stargazing locations.
        
        This tool searches for dark, accessible locations with good viewing conditions.
        Results are cached based on search parameters.
        
        Args:
            south, west, north, east: Bounding box coordinates.
            max_locations: Maximum number of candidate locations to find (before pagination).
            min_height_diff: Minimum elevation difference for prominence.
            road_radius_km: Search radius for road access.
            network_type: Type of road network ('drive', 'walk', etc.).
            db_config_path: Optional path to database config.
            page: Page number (1-based).
            page_size: Number of results per page.
            
        Returns:
            Dict with keys "data", "_meta". "data" contains:
            - items: List of location results for the current page.
            - total: Total number of locations found.
            - page: Current page number.
            - page_size: Current page size.
            - resource_id: Cache key for these search parameters.
        """
        # 1. Generate Cache Key based on calculation parameters (excluding pagination)
        calc_params = {
            "south": south, "west": west, "north": north, "east": east,
            "max_locations": max_locations,
            "min_height_diff": min_height_diff,
            "road_radius_km": road_radius_km,
            "network_type": network_type,
            "db_config_path": db_config_path
        }
        resource_id = generate_cache_key(**calc_params)
        
        # 2. Check Cache
        all_results = ANALYSIS_CACHE.get(resource_id)
        
        # 3. If miss, compute (in thread)
        if all_results is None:
            def _compute():
                db_config_p = Path(db_config_path) if db_config_path else None
                stargazing_place_finder = StargazingPlaceFinder(db_config_path=db_config_p)
                results = stargazing_place_finder.analyze_area(
                    south=south,
                    west=west,
                    north=north,
                    east=east,
                    min_height_diff=min_height_diff,
                    road_radius_km=road_radius_km,
                    max_locations=max_locations,
                    network_type=network_type,
                )
                
                # Ensure results are serializable
                serialized = []
                for item in results:
                    if isinstance(item, dict):
                        serialized.append(item)
                    elif hasattr(item, "to_dict") and callable(item.to_dict):
                        serialized.append(item.to_dict())
                    elif hasattr(item, "__dict__"):
                        serialized.append(vars(item))
                    else:
                        serialized.append(str(item))
                return serialized
    
            all_results = await asyncio.to_thread(_compute)
            ANALYSIS_CACHE.set(resource_id, all_results)
            
        # 4. Pagination
        total = len(all_results)
        start_idx = (page - 1) * page_size
        end_idx = start_idx + page_size
        
        # Slice results (safe even if indices are out of bounds)
        page_items = all_results[start_idx:end_idx]
        
        return format_response({
            "items": page_items,
            "total": total,
            "page": page,
            "page_size": page_size,
            "total_pages": (total + page_size - 1) // page_size if page_size > 0 else 0,
            "resource_id": resource_id
        })
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. It discloses key behavioral traits: it's a search operation with caching ('Results are cached based on search parameters'), pagination (implied by page parameters), and returns structured data. It doesn't mention rate limits, authentication needs, or error handling, but covers essential operational aspects.

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 with the core purpose. The parameter and return value sections are necessary given the complexity. However, the 'Args:' and 'Returns:' labels could be more integrated, and some sentences like 'Results are cached...' could be tighter.

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 (11 parameters, no annotations, but with output schema), the description is complete. It explains the purpose, parameters, caching behavior, pagination, and return structure. The output schema existence means the description doesn't need to detail return values, which it appropriately summarizes instead.

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%, so the description must compensate. It provides detailed semantic explanations for all 11 parameters, including bounding box coordinates, search limits, elevation criteria, road access details, and pagination controls. This adds significant meaning beyond the bare schema types and defaults.

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', 'searches for') and resources ('geographic area', 'suitable stargazing locations'). It distinguishes itself from sibling tools by focusing on location analysis rather than celestial data, weather, or light pollution mapping.

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 context through 'suitable stargazing locations' and 'dark, accessible locations with good viewing conditions', suggesting when this tool is appropriate. However, it doesn't explicitly state when to use it versus alternatives like 'light_pollution_map' or weather-related siblings, nor does it mention any prerequisites or exclusions.

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/StarGazer1995/mcp-stargazing'

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