Skip to main content
Glama
arjunkmrm

Perplexity Deep Research MCP

deep_research

Conduct detailed web searches with contextually relevant results and citations using Perplexity's Deep Research API, filtering by recency as needed.

Instructions

Perform a comprehensive web search using Perplexity's Deep Research API, which provides detailed and contextually relevant results with citations.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesThe search query to perform
search_recency_filterNoFilter search results by recency (options: month, week, day, hour)

Implementation Reference

  • Handler for executing the 'deep_research' tool. Sends the query to Perplexity's sonar-deep-research model via API, includes optional recency filter, returns formatted content and citations or error.
    case "deep_research": {
      const { 
        query, 
        search_recency_filter
      } = request.params.arguments as {
        query: string;
        search_recency_filter?: string;
      };
    
      try {
        const payload: any = {
          model: "sonar-deep-research",
          messages: [
            {
              role: "user",
              content: query
            }
          ],
          max_tokens: this.maxTokens,
          temperature: this.temperature
        };
    
        // Add optional parameters if provided
        if (search_recency_filter) {
          payload.search_recency_filter = search_recency_filter;
        }
    
        console.error(`Using model: sonar-deep-research, max_tokens: ${this.maxTokens}, temperature: ${this.temperature}`);
    
        const response = await axios.post('https://api.perplexity.ai/chat/completions', payload, {
          headers: {
            'Authorization': `Bearer ${process.env.PERPLEXITY_API_KEY!}`,
            'Content-Type': 'application/json'
          }
        });
        
        // Format the response to only include content and citations
        const formattedResponse = {
          content: response.data.choices[0].message.content,
          citations: response.data.citations || []
        };
        
        return {
          content: [{
            type: "text",
            text: JSON.stringify(formattedResponse, null, 2)
          }]
        };
      } catch (error: unknown) {
        if (axios.isAxiosError(error)) {
          const axiosError = error as AxiosError<PerplexityErrorResponse>;
          const errorData = axiosError.response?.data;
          const errorMessage = errorData?.error || errorData?.message || axiosError.message;
          
          return {
            content: [{
              type: "text", 
              text: `Perplexity API error: ${errorMessage}`
            }],
            isError: true
          };
        }
        throw error;
      }
    }
  • src/index.ts:55-77 (registration)
    Registers the 'deep_research' tool in the ListToolsRequestHandler, providing name, description, and input schema.
    this.server.setRequestHandler(ListToolsRequestSchema, async () => {
      return {
        tools: [{
          name: "deep_research",
          description: "Perform a comprehensive web search using Perplexity's Deep Research API, which provides detailed and contextually relevant results with citations.",
          inputSchema: {
            type: "object",
            properties: {
              query: {
                type: "string",
                description: "The search query to perform"
              },
              search_recency_filter: {
                type: "string",
                description: "Filter search results by recency (options: month, week, day, hour)",
                enum: ["month", "week", "day", "hour"]
              }
            },
            required: ["query"]
          }
        }]
      };
    });
  • Input schema definition for the 'deep_research' tool: requires 'query' string, optional 'search_recency_filter' enum.
    inputSchema: {
      type: "object",
      properties: {
        query: {
          type: "string",
          description: "The search query to perform"
        },
        search_recency_filter: {
          type: "string",
          description: "Filter search results by recency (options: month, week, day, hour)",
          enum: ["month", "week", "day", "hour"]
        }
      },
      required: ["query"]
    }

Tool Definition Quality

Score is being calculated. Check back soon.

Install Server

Other Tools

Related 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/arjunkmrm/perplexity-deep-research'

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