Skip to main content
Glama
thetom42

Perplexica MCP Server

search

Perform AI-powered searches across web, academic sources, writing assistance, and platforms like YouTube and Reddit using Perplexica's search engine with customizable focus modes.

Instructions

Search using Perplexica's AI-powered search engine.

This tool provides access to Perplexica's search capabilities with various focus modes for different types of searches including web search, academic search, writing assistance, and specialized searches for platforms like YouTube and Reddit.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch query
focus_modeYesFocus mode: webSearch, academicSearch, writingAssistant, wolframAlphaSearch, youtubeSearch, redditSearch
chat_modelNoChat model configuration
embedding_modelNoEmbedding model configuration
optimization_modeNoOptimization mode: speed or balanced
historyNoConversation history
system_instructionsNoCustom system instructions
streamNoWhether to stream responses

Implementation Reference

  • The @mcp.tool()-decorated handler function for the 'search' MCP tool. Defines the tool logic, input schema via Annotated Pydantic Fields, validation for models, and delegates to the perplexica_search helper for API interaction.
    @mcp.tool()
    async def search(
        query: Annotated[str, Field(description="Search query")],
        focus_mode: Annotated[
            str,
            Field(
                description="Focus mode: webSearch, academicSearch, writingAssistant, wolframAlphaSearch, youtubeSearch, redditSearch"
            ),
        ],
        chat_model: Annotated[
            Optional[dict], Field(description="Chat model configuration")
        ] = DEFAULT_CHAT_MODEL,
        embedding_model: Annotated[
            Optional[dict], Field(description="Embedding model configuration")
        ] = DEFAULT_EMBEDDING_MODEL,
        optimization_mode: Annotated[
            Optional[str], Field(description="Optimization mode: speed or balanced")
        ] = None,
        history: Annotated[
            Optional[list], Field(description="Conversation history")
        ] = None,
        system_instructions: Annotated[
            Optional[str], Field(description="Custom system instructions")
        ] = None,
        stream: Annotated[bool, Field(description="Whether to stream responses")] = False,
    ) -> dict:
        """
        Search using Perplexica's AI-powered search engine.
    
        This tool provides access to Perplexica's search capabilities with various focus modes
        for different types of searches including web search, academic search, writing assistance,
        and specialized searches for platforms like YouTube and Reddit.
        """
        # Fail fast if required models are absent
        if (chat_model or DEFAULT_CHAT_MODEL) is None or (
            embedding_model or DEFAULT_EMBEDDING_MODEL
        ) is None:
            return {
                "error": "Both chatModel and embeddingModel are required. Configure PERPLEXICA_* model env vars or pass them in the request."
            }
    
        return await perplexica_search(
            query=query,
            focus_mode=focus_mode,
            chat_model=chat_model,
            embedding_model=embedding_model,
            optimization_mode=optimization_mode,
            history=history,
            system_instructions=system_instructions,
            stream=stream,
        )
  • Pydantic input schema for the search tool, using Annotated[str/dict/etc., Field(description=...)] for parameters like query, focus_mode, models, etc.
    query: Annotated[str, Field(description="Search query")],
    focus_mode: Annotated[
        str,
        Field(
            description="Focus mode: webSearch, academicSearch, writingAssistant, wolframAlphaSearch, youtubeSearch, redditSearch"
        ),
    ],
    chat_model: Annotated[
        Optional[dict], Field(description="Chat model configuration")
    ] = DEFAULT_CHAT_MODEL,
    embedding_model: Annotated[
        Optional[dict], Field(description="Embedding model configuration")
    ] = DEFAULT_EMBEDDING_MODEL,
    optimization_mode: Annotated[
        Optional[str], Field(description="Optimization mode: speed or balanced")
    ] = None,
    history: Annotated[
        Optional[list], Field(description="Conversation history")
    ] = None,
    system_instructions: Annotated[
        Optional[str], Field(description="Custom system instructions")
    ] = None,
    stream: Annotated[bool, Field(description="Whether to stream responses")] = False,
  • perplexica_search helper function that prepares the JSON payload with search parameters and performs asynchronous HTTP POST to the Perplexica backend URL, handling errors.
    async def perplexica_search(
        query,
        focus_mode,
        chat_model=None,
        embedding_model=None,
        optimization_mode=None,
        history=None,
        system_instructions=None,
        stream=False,
    ) -> dict:
        """
        Search using the Perplexica API
    
        Args:
            query (str): The search query
            chat_model (dict, optional): Chat model configuration with:
                provider: Provider name (e.g., openai, ollama)
                name: Model name (e.g., gpt-4o-mini)
                customOpenAIBaseURL: Optional custom OpenAI base URL
                customOpenAIKey: Optional custom OpenAI API key
            embedding_model (dict, optional): Embedding model configuration with:
                provider: Provider name (e.g., openai)
                name: Model name (e.g., text-embedding-3-small)
                customOpenAIBaseURL: Optional custom OpenAI base URL
                customOpenAIKey: Optional custom OpenAI API key
            focus_mode (str): Search focus mode (webSearch, academicSearch, etc.)
            optimization_mode (str, optional): Optimization mode (speed, balanced)
            history (list, optional): Conversation history
            system_instructions (str, optional): Custom system instructions
            stream (bool, optional): Whether to stream responses
    
        Returns:
            dict: Search results from Perplexica
        """
    
        # Prepare the request payload
        payload = {"query": query, "focusMode": focus_mode}
    
        # Add optional parameters if provided
        if chat_model:
            payload["chatModel"] = chat_model
        if embedding_model:
            payload["embeddingModel"] = embedding_model
        if optimization_mode:
            payload["optimizationMode"] = optimization_mode
        else:
            payload["optimizationMode"] = "balanced"
        if history is not None:
            payload["history"] = history
        else:
            payload["history"] = []
        if system_instructions:
            payload["systemInstructions"] = system_instructions
        if stream is not None:
            payload["stream"] = stream
    
        try:
            async with httpx.AsyncClient() as client:
                response = await client.post(
                    PERPLEXICA_BACKEND_URL, json=payload, timeout=PERPLEXICA_READ_TIMEOUT
                )
                response.raise_for_status()
                return response.json()
        except httpx.HTTPError as e:
            return {"error": f"HTTP error occurred: {str(e)}"}
        except Exception as e:
            return {"error": f"An error occurred: {str(e)}"}
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. It mentions 'AI-powered search engine' and 'capabilities with various focus modes,' but lacks critical behavioral details such as rate limits, authentication needs, response format, pagination, or error handling. For a search tool with 8 parameters, this is insufficient.

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 with two sentences. The first sentence states the core purpose, and the second elaborates on focus modes. It is front-loaded and avoids unnecessary repetition, though it could be slightly more structured.

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

Completeness2/5

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

Given the complexity (8 parameters, no output schema, no annotations), the description is incomplete. It lacks details on return values, error conditions, performance characteristics, and practical usage scenarios. For a search tool with multiple configuration options, more context is needed.

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 100%, so the schema fully documents all 8 parameters. The description adds minimal value by listing focus modes (e.g., 'web search, academic search') but does not explain parameter interactions or provide usage examples beyond what the schema already specifies.

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: 'Search using Perplexica's AI-powered search engine' and mentions 'various focus modes for different types of searches.' It specifies the verb ('search') and resource ('Perplexica's search engine'), but without sibling tools, it cannot demonstrate differentiation from alternatives.

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 mentions 'various focus modes for different types of searches' but does not provide explicit guidance on when to use specific modes or when to choose this tool over alternatives. No exclusions, prerequisites, or comparative context are given.

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/thetom42/perplexica-mcp'

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