Skip to main content
Glama

get_coordinates

Retrieve geographic coordinates for any Wikipedia article by providing its title, enabling location-based data extraction from the platform.

Instructions

Get the coordinates of a Wikipedia article.

Returns a dictionary containing coordinate information.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
titleYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Core handler logic for fetching coordinates from Wikipedia API using prop=coordinates query.
    def get_coordinates(self, title: str) -> Dict[str, Any]:
        """
        Get the coordinates of a Wikipedia article.
    
        Args:
            title: The title of the Wikipedia article.
    
        Returns:
            A dictionary containing the coordinates information.
        """
        params = {
            "action": "query",
            "format": "json",
            "prop": "coordinates",
            "titles": title,
        }
        # Add variant parameter if needed
        params = self._add_variant_to_params(params)
    
        try:
            response = requests.get(self.api_url, headers=self._get_request_headers(), params=params)
            response.raise_for_status()
            data = response.json()
    
            pages = data.get("query", {}).get("pages", {})
    
            if not pages:
                return {
                    "title": title,
                    "coordinates": None,
                    "exists": False,
                    "error": "No page found",
                }
    
            # Get the first (and typically only) page
            page_data = next(iter(pages.values()))
    
            # Check if page exists (pageid > 0 means page exists)
            if page_data.get("pageid", -1) < 0:
                return {
                    "title": title,
                    "coordinates": None,
                    "exists": False,
                    "error": "Page does not exist",
                }
    
            coordinates = page_data.get("coordinates", [])
    
            if not coordinates:
                return {
                    "title": page_data.get("title", title),
                    "pageid": page_data.get("pageid"),
                    "coordinates": None,
                    "exists": True,
                    "error": None,
                    "message": "No coordinates available for this article",
                }
    
            # Process coordinates - typically there's one primary coordinate
            processed_coordinates = []
            for coord in coordinates:
                processed_coordinates.append(
                    {
                        "latitude": coord.get("lat"),
                        "longitude": coord.get("lon"),
                        "primary": coord.get("primary", False),
                        "globe": coord.get("globe", "earth"),
                        "type": coord.get("type", ""),
                        "name": coord.get("name", ""),
                        "region": coord.get("region", ""),
                        "country": coord.get("country", ""),
                    }
                )
    
            return {
                "title": page_data.get("title", title),
                "pageid": page_data.get("pageid"),
                "coordinates": processed_coordinates,
                "exists": True,
                "error": None,
            }
    
        except Exception as e:
            logger.error(f"Error getting coordinates for Wikipedia article: {e}")
            return {
                "title": title,
                "coordinates": None,
                "exists": False,
                "error": str(e),
            }
  • MCP tool registration via @server.tool() decorator and thin wrapper handler that delegates to WikipediaClient.get_coordinates.
    @server.tool()
    def get_coordinates(title: str) -> Dict[str, Any]:
        """
        Get the coordinates of a Wikipedia article.
    
        Returns a dictionary containing coordinate information.
        """
        logger.info(f"Tool: Getting coordinates for: {title}")
        coordinates = wikipedia_client.get_coordinates(title)
        return coordinates
  • Optional caching decorator applied to get_coordinates method when enable_cache=True.
    self.get_coordinates = functools.lru_cache(maxsize=128)(self.get_coordinates)
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool returns 'a dictionary containing coordinate information,' which hints at the output format but lacks details on error handling, rate limits, authentication needs, or whether it's a read-only operation. For a tool with no annotation coverage, this leaves significant gaps in understanding its behavior.

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 extremely concise and front-loaded: the first sentence directly states the purpose, and the second adds minimal but useful information about the return type. There is no wasted language, and every sentence earns its place by contributing essential details without redundancy.

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

Completeness3/5

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

Given the tool's low complexity (1 parameter, no annotations, but has an output schema), the description is minimally adequate. The output schema existence means the description doesn't need to explain return values in detail, but it lacks context on usage guidelines and behavioral traits. It meets the basic requirement but has clear gaps in providing a complete picture for effective tool selection.

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 input schema has 1 parameter with 0% description coverage, meaning the parameter 'title' is undocumented in the schema. The description doesn't add any semantic details about this parameter, such as what format the title should be in or examples. However, with only one parameter and a clear tool purpose, the baseline is 3 as the schema's minimal structure is somewhat compensated by the tool's straightforward nature.

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 tool's purpose: 'Get the coordinates of a Wikipedia article.' This specifies the verb ('Get') and resource ('coordinates of a Wikipedia article'), making it immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'get_article' or 'get_related_topics' that might also involve Wikipedia article data retrieval, so it doesn't reach the highest score.

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 doesn't mention any prerequisites, exclusions, or compare it to sibling tools such as 'get_article' or 'get_summary' that might serve overlapping purposes. The agent must infer usage based solely on the tool name and description without explicit direction.

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/Rudra-ravi/wikipedia-mcp'

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