Skip to main content
Glama
anilsharmay

Country Explorer MCP Server

by anilsharmay

unsplash_search

Search for high-quality photos on Unsplash to enhance country profiles with relevant imagery and proper photographer credits.

Instructions

Search for photos on Unsplash using the given query.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes
num_resultsNo
orientationNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • server.py:26-30 (handler)
    MCP tool handler function for 'unsplash_search'. This is the entry point decorated with @mcp.tool(), which registers and executes the tool logic by delegating to UnsplashSearcher.
    @mcp.tool()
    def unsplash_search(query: str, num_results: int = 10, orientation: Optional[str] = None) -> str:
        """Search for photos on Unsplash using the given query."""
        searcher = UnsplashSearcher()
        return searcher.search_photos(query, num_results, orientation)
  • server.py:26-30 (registration)
    Registration of the 'unsplash_search' tool using FastMCP's @mcp.tool() decorator.
    @mcp.tool()
    def unsplash_search(query: str, num_results: int = 10, orientation: Optional[str] = None) -> str:
        """Search for photos on Unsplash using the given query."""
        searcher = UnsplashSearcher()
        return searcher.search_photos(query, num_results, orientation)
  • Core implementation of the Unsplash photo search logic in the UnsplashSearcher class's search_photos method, which handles API calls, error handling, and result formatting.
    def search_photos(self, query: str, num_results: int = 10, orientation: Optional[str] = None) -> str:
        """
        Search for photos on Unsplash using the given query.
        
        Args:
            query: Search term for photos
            num_results: Number of photos to return (1-30, default: 10)
            orientation: Filter by orientation - 'landscape', 'portrait', or 'squarish' (optional)
        
        Returns:
            JSON string containing search results with photo URLs and metadata
        """
        if not self.api_key:
            return "Error: UNSPLASH_API_KEY environment variable not set. Please add your Unsplash API key to your .env file."
        
        # Validate num_results parameter
        num_results = max(1, min(30, num_results))
        
        # Build the API URL
        url = f"{self.base_url}/search/photos"
        headers = {
            "Authorization": f"Client-ID {self.api_key}",
            "Accept-Version": "v1"
        }
        
        params = {
            "query": query,
            "per_page": num_results
        }
        
        # Add orientation filter if specified
        if orientation and orientation.strip() and orientation.lower() in ['landscape', 'portrait', 'squarish']:
            params["orientation"] = orientation.lower()
        
        try:
            response = requests.get(url, headers=headers, params=params)
            response.raise_for_status()
            
            data = response.json()
            
            # Format the results for better readability
            results = {
                "total": data.get("total", 0),
                "total_pages": data.get("total_pages", 0),
                "photos": []
            }
            
            for photo in data.get("results", []):
                photo_info = {
                    "id": photo.get("id"),
                    "description": photo.get("description", "No description"),
                    "alt_description": photo.get("alt_description", "No alt description"),
                    "width": photo.get("width"),
                    "height": photo.get("height"),
                    "color": photo.get("color"),
                    "likes": photo.get("likes"),
                    "urls": {
                        "raw": photo.get("urls", {}).get("raw"),
                        "full": photo.get("urls", {}).get("full"),
                        "regular": photo.get("urls", {}).get("regular"),
                        "small": photo.get("urls", {}).get("small"),
                        "thumb": photo.get("urls", {}).get("thumb")
                    },
                    "user": {
                        "name": photo.get("user", {}).get("name"),
                        "username": photo.get("user", {}).get("username"),
                        "portfolio_url": photo.get("user", {}).get("portfolio_url")
                    },
                    "links": {
                        "html": photo.get("links", {}).get("html"),
                        "download": photo.get("links", {}).get("download")
                    }
                }
                results["photos"].append(photo_info)
            
            return json.dumps(results, indent=2)
            
        except requests.exceptions.RequestException as e:
            return f"Error making request to Unsplash API: {str(e)}"
        except json.JSONDecodeError as e:
            return f"Error parsing response from Unsplash API: {str(e)}"
        except Exception as e:
            return f"Unexpected error: {str(e)}"
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states the basic action but lacks critical details: no mention of rate limits, authentication requirements, pagination behavior, or what the output contains (though an output schema exists). For a search tool with zero annotation coverage, this leaves significant behavioral gaps.

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 a single, efficient sentence that gets straight to the point with zero wasted words. It's appropriately sized for a search tool and front-loads the core functionality without unnecessary elaboration.

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 moderate complexity (3 parameters, search functionality) and the existence of an output schema (which handles return values), the description is minimally complete. However, with no annotations and poor parameter documentation, it leaves gaps in behavioral understanding and parameter usage that could hinder 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?

Schema description coverage is 0%, so parameters are undocumented in the schema. The description mentions 'using the given query' which only addresses one of three parameters (query, num_results, orientation). It doesn't explain what num_results controls or what orientation values are acceptable. The description adds minimal value beyond the schema's parameter names.

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 verb ('Search') and resource ('photos on Unsplash'), making the purpose immediately understandable. It distinguishes from sibling tools like 'roll_dice' and 'web_search' by specifying the Unsplash photo domain. However, it doesn't explicitly differentiate from potential alternative photo search tools beyond the Unsplash context.

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. While it's clearly for searching Unsplash photos, there's no mention of when to choose this over 'web_search' (which might also find photos) or other hypothetical photo sources. No prerequisites, limitations, or comparative context is provided.

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/anilsharmay/mcp-demo'

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