Skip to main content
Glama
Rohit-Seelam

Perplexity MCP Server

by Rohit-Seelam

perplexity_medium

Analyze complex questions with moderate research depth, providing technical explanations and citations for informed decision-making.

Instructions

Enhanced reasoning with moderate search depth using sonar-reasoning-pro. Best for: Complex questions requiring analysis, moderate research depth, technical explanations with citations. Uses medium reasoning effort and search context size. Args: query: The question or prompt to send to Perplexity messages: Optional conversation context (list of {"role": "user/assistant", "content": "..."}) Returns: Dictionary with content and citations

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
messagesNo
queryYes

Implementation Reference

  • The core handler function decorated with @mcp.tool(), implementing the perplexity_medium tool logic: prepares user messages, loads medium configuration, calls Perplexity API via client, formats response with citations, handles errors.
    @mcp.tool() def perplexity_medium(query: str, messages: List[Dict[str, str]] = None) -> Dict[str, Any]: """ Enhanced reasoning with moderate search depth using sonar-reasoning-pro. Best for: Complex questions requiring analysis, moderate research depth, technical explanations with citations. Uses medium reasoning effort and search context size. Args: query: The question or prompt to send to Perplexity messages: Optional conversation context (list of {"role": "user/assistant", "content": "..."}) Returns: Dictionary with content and citations """ try: client = get_perplexity_client() # Prepare messages if messages is None: messages = [] # Add the current query messages.append({"role": "user", "content": query}) # Get tool configuration config = TOOL_CONFIGS["medium"] # Make API request response = client.chat_completion(messages=messages, **config) # Format and return response return client.format_response(response) except Exception as e: logger.exception("Error in perplexity_medium") return { "error": "tool_error", "message": f"Failed to process query: {str(e)}" }
  • Schema/configuration defining the model ('sonar-reasoning-pro'), reasoning effort, and web search options specifically for the perplexity_medium tool.
    "medium": { "model": "sonar-reasoning-pro", "reasoning_effort": "medium", "web_search_options": { "search_context_size": "medium" } },
  • server.py:78-119 (registration)
    The @mcp.tool() decorator registers the perplexity_medium function as an MCP tool.
    @mcp.tool() def perplexity_medium(query: str, messages: List[Dict[str, str]] = None) -> Dict[str, Any]: """ Enhanced reasoning with moderate search depth using sonar-reasoning-pro. Best for: Complex questions requiring analysis, moderate research depth, technical explanations with citations. Uses medium reasoning effort and search context size. Args: query: The question or prompt to send to Perplexity messages: Optional conversation context (list of {"role": "user/assistant", "content": "..."}) Returns: Dictionary with content and citations """ try: client = get_perplexity_client() # Prepare messages if messages is None: messages = [] # Add the current query messages.append({"role": "user", "content": query}) # Get tool configuration config = TOOL_CONFIGS["medium"] # Make API request response = client.chat_completion(messages=messages, **config) # Format and return response return client.format_response(response) except Exception as e: logger.exception("Error in perplexity_medium") return { "error": "tool_error", "message": f"Failed to process query: {str(e)}" }
  • Helper function to initialize and provide the shared PerplexityClient instance used by perplexity_medium.
    def get_perplexity_client() -> PerplexityClient: """Get or create the Perplexity client instance.""" global perplexity_client if perplexity_client is None: perplexity_client = PerplexityClient() return perplexity_client

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/Rohit-Seelam/Perplexity_MCP'

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