Skip to main content
Glama
jaacob

Perplexity MCP Server

by jaacob

search

Search the web using Perplexity AI to find information, answer questions, and retrieve relevant results through Claude's interface.

Instructions

Search the web using Perplexity AI

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesThe search query

Implementation Reference

  • MCP CallToolRequestSchema handler that implements the 'search' tool logic by validating arguments and calling Perplexity AI's chat completions API.
    this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
      if (request.params.name !== 'search') {
        throw new McpError(
          ErrorCode.MethodNotFound,
          `Unknown tool: ${request.params.name}`
        );
      }
    
      if (!isValidSearchArgs(request.params.arguments)) {
        throw new McpError(
          ErrorCode.InvalidParams,
          'Invalid search arguments. Query must be a non-empty string.'
        );
      }
    
      try {
        const response = await this.axiosInstance.post<SearchResponse>('/chat/completions', {
          model: MODEL,
          messages: [
            {
              role: 'system',
              content: 'You are a helpful assistant that searches the web for accurate information.'
            },
            {
              role: 'user',
              content: request.params.arguments.query
            }
          ]
        });
    
        if (response.data.choices && response.data.choices.length > 0) {
          return {
            content: [
              {
                type: 'text',
                text: response.data.choices[0].message.content,
              },
            ],
          };
        } else {
          throw new Error('No response content received');
        }
      } catch (error) {
        if (axios.isAxiosError(error)) {
          const errorMessage = error.response?.data?.error?.message ||
            error.response?.data?.detail ||
            error.message;
          console.error('Full error:', JSON.stringify(error.response?.data, null, 2));
          return {
            content: [
              {
                type: 'text',
                text: `Perplexity API error: ${errorMessage}`,
              },
            ],
            isError: true,
          };
        }
        throw error;
      }
    });
  • src/index.ts:74-91 (registration)
    Registration of the 'search' tool in the ListToolsRequestSchema handler, providing name, description, and input schema.
    this.server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: [
        {
          name: 'search',
          description: 'Search the web using Perplexity AI',
          inputSchema: {
            type: 'object',
            properties: {
              query: {
                type: 'string',
                description: 'The search query',
              },
            },
            required: ['query'],
          },
        },
      ],
    }));
  • TypeScript interface defining the expected response structure from Perplexity AI API.
    interface SearchResponse {
      choices: [{
        message: {
          content: string;
        };
      }];
    }
  • Input schema definition for the 'search' tool.
    inputSchema: {
      type: 'object',
      properties: {
        query: {
          type: 'string',
          description: 'The search query',
        },
      },
      required: ['query'],
    },
  • Helper function to validate the arguments for the 'search' tool.
    const isValidSearchArgs = (args: any): args is { query: string } =>
      typeof args === 'object' &&
      args !== null &&
      typeof args.query === 'string' &&
      args.query.trim().length > 0;
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 specify rate limits, authentication requirements, result format, pagination, or any other behavioral characteristics. The description is minimal and lacks important operational context.

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 that directly states the tool's function. There's zero waste or unnecessary verbiage. It's appropriately sized for a simple search tool and front-loaded with the essential information.

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?

For a search tool with no annotations and no output schema, the description is insufficiently complete. It doesn't explain what kind of results to expect, whether there are limitations on query types, how results are formatted, or any other operational details. The description leaves too many questions unanswered for effective tool usage.

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 'query' parameter clearly documented. The description doesn't add any additional parameter semantics beyond what's already in the schema. According to the scoring rules, when schema_description_coverage is high (>80%), the baseline is 3 even with no parameter information in the description.

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 specifies the resource/context ('using Perplexity AI'), making the purpose immediately understandable. It's not a tautology and provides specific information about what the tool does. However, since there are no sibling tools mentioned, 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 provides no guidance on when to use this tool versus alternatives, prerequisites, or specific contexts where it's most appropriate. It simply states what the tool does without any usage context 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/jaacob/perplexity-mcp'

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