Skip to main content
Glama
spragginsdesigns

Perplexity MCP Server

perplexity_search

Search the web using Perplexity AI to retrieve relevant information and answers for your queries.

Instructions

Search the web using Perplexity AI

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesThe search query

Implementation Reference

  • The handler function for the 'perplexity_search' tool. It checks for the API key, validates the query argument, makes a POST request to Perplexity AI's chat completions endpoint using the 'sonar-pro' model, and returns the text response.
    if (request.params.name === "perplexity_search") {
    	const apiKey = process.env.PERPLEXITY_API_KEY;
    	if (!apiKey) {
    		throw new McpError(
    			ErrorCode.InvalidRequest,
    			"PERPLEXITY_API_KEY environment variable is not set"
    		);
    	}
    
    	const args = request.params.arguments;
    	if (!args || typeof args.query !== "string") {
    		throw new McpError(
    			ErrorCode.InvalidParams,
    			"Query parameter is required and must be a string"
    		);
    	}
    
    	try {
    		const response = await fetch(
    			"https://api.perplexity.ai/chat/completions",
    			{
    				method: "POST",
    				headers: {
    					Authorization: `Bearer ${apiKey}`,
    					"Content-Type": "application/json"
    				},
    				body: JSON.stringify({
    					model: "sonar-pro",
    					messages: [
    						{
    							role: "user",
    							content: args.query
    						}
    					]
    				})
    			}
    		);
    
    		if (!response.ok) {
    			throw new Error(`HTTP error! status: ${response.status}`);
    		}
    
    		const data = await response.json();
    		return {
    			content: [
    				{
    					type: "text",
    					text: data.choices[0].message.content
    				}
    			]
    		};
    	} catch (error) {
    		const errorMessage =
    			error instanceof Error ? error.message : String(error);
    		throw new McpError(
    			ErrorCode.InternalError,
    			`Search failed: ${errorMessage}`
    		);
    	}
    }
  • Input schema definition for the 'perplexity_search' tool, specifying a required 'query' string parameter.
    inputSchema: {
    	type: "object",
    	properties: {
    		query: {
    			type: "string",
    			description: "The search query"
    		}
    	},
    	required: ["query"]
    }
  • src/index.ts:18-31 (registration)
    Tool registration in server capabilities, defining name, description, and input schema for 'perplexity_search'.
    perplexity_search: {
    	name: "perplexity_search",
    	description: "Search the web using Perplexity AI",
    	inputSchema: {
    		type: "object",
    		properties: {
    			query: {
    				type: "string",
    				description: "The search query"
    			}
    		},
    		required: ["query"]
    	}
    }
  • src/index.ts:38-57 (registration)
    ListTools request handler that returns the registered 'perplexity_search' tool details.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
    	return {
    		tools: [
    			{
    				name: "perplexity_search",
    				description: "Search the web using Perplexity AI",
    				inputSchema: {
    					type: "object",
    					properties: {
    						query: {
    							type: "string",
    							description: "The search query"
    						}
    					},
    					required: ["query"]
    				}
    			}
    		]
    	};
    });
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. While 'Search the web' implies a read-only operation, it doesn't address critical aspects like rate limits, authentication requirements, response format, or whether it's a real-time search versus cached results. The description is too minimal for a tool that interacts with external services.

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 - a single sentence with zero wasted words. It's front-loaded with the core functionality and uses straightforward language. For a simple search tool, this level of brevity is appropriate.

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 that there are no annotations and no output schema, the description is insufficiently complete. It doesn't explain what kind of results to expect, whether there are usage limitations, or how the search differs from standard web searches. For a tool that presumably returns search results, more context about the output would be helpful.

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 100% description coverage, with the single parameter 'query' clearly documented in the schema. The description doesn't add any additional semantic context about the parameter beyond what's already in the schema, so it meets the baseline score of 3.

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 action ('Search the web') and the resource/mechanism ('using Perplexity AI'), providing a specific verb+resource combination. However, with no sibling tools mentioned, there's no opportunity to distinguish from alternatives, so it cannot achieve a perfect score of 5.

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 other search methods or alternatives. It simply states what the tool does without any context about appropriate use cases, prerequisites, or limitations.

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/spragginsdesigns/perplexity-mcp-server'

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