Skip to main content
Glama
Jercik

Perplexity Agent MCP

by Jercik

lookup

Fetch precise, source-backed facts from official documentation for API syntax, config keys, CLI flags, runtime compatibility, and package metadata.

Instructions

Fetch precise, source-backed facts from official sources. Use for API syntax/params, config keys/defaults, CLI flags, runtime compatibility, and package metadata (types, ESM/CJS, side-effects). Returns short, factual answers. No recommendations or comparisons.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesWhat fact to look up from docs

Implementation Reference

  • The asynchronous handler function for the 'lookup' tool. It takes a query, performs a chat completion using Perplexity's 'sonar-pro' model with the LOOKUP_SYSTEM_PROMPT, and returns the result as text content.
    async ({ query }) => {
      const result = await performChatCompletion(
        [{ role: "user", content: query }],
        {
          model: "sonar-pro",
          system: LOOKUP_SYSTEM_PROMPT,
          searchContextSize: "medium",
        },
      );
      return { content: [{ type: "text", text: result }] };
    },
  • The schema definition for the 'lookup' tool, including description and inputSchema using Zod for the 'query' parameter.
        {
          description: `
    Fetches precise, source-backed facts from official sources.
    Use for API syntax/params, config keys/defaults, CLI flags, runtime compatibility, and package metadata (types, ESM/CJS, side-effects).
    Returns short, factual answers. No recommendations or comparisons.
    Examples: "What's the default timeout for fetch()?", "What parameters does useState accept?", "Show me how Zod validates email addresses"
    One question per call—split combined requests into separate queries.
    `.trim(),
          inputSchema: {
            query: z.string().describe("The documentation query to look up"),
          },
        },
  • The registerLookupTool function that registers the 'lookup' tool with the MCP server, including its schema and handler.
    export function registerLookupTool(server: McpServer) {
      server.registerTool(
        "lookup",
        {
          description: `
    Fetches precise, source-backed facts from official sources.
    Use for API syntax/params, config keys/defaults, CLI flags, runtime compatibility, and package metadata (types, ESM/CJS, side-effects).
    Returns short, factual answers. No recommendations or comparisons.
    Examples: "What's the default timeout for fetch()?", "What parameters does useState accept?", "Show me how Zod validates email addresses"
    One question per call—split combined requests into separate queries.
    `.trim(),
          inputSchema: {
            query: z.string().describe("The documentation query to look up"),
          },
        },
        async ({ query }) => {
          const result = await performChatCompletion(
            [{ role: "user", content: query }],
            {
              model: "sonar-pro",
              system: LOOKUP_SYSTEM_PROMPT,
              searchContextSize: "medium",
            },
          );
          return { content: [{ type: "text", text: result }] };
        },
      );
    }
  • src/server.ts:17-17 (registration)
    The call to register the 'lookup' tool during server setup.
    registerLookupTool(server);
  • The system prompt used by the 'lookup' tool handler for guiding fact extraction from sources.
    export const LOOKUP_SYSTEM_PROMPT = `
    # Role: Fact Extraction Agent
    Extract precise, verifiable facts from source code and documentation. Optimized for quick lookups of:
    - API signatures and parameter types
    - Configuration keys and default values
    - CLI flags and options
    - Package metadata (versions, exports, compatibility)
    - Exact error messages and codes
    
    # Instructions
    - Search GitHub source code FIRST - find the exact line where something is defined/used
    - Return the specific fact requested, nothing more
    - Include file path and line numbers when citing code
    - State "Not found in available sources" if information doesn't exist
    - Avoid explanations unless the fact itself is ambiguous
    
    ${AUTHORITATIVE_SOURCES}
    
    # Output Format
    - Direct answer with source citation: "The default value is X [repo/file.ts:123]"
    - For code usage: Show the exact line(s) from source
    - For missing info: "Not found in available sources"
    - No preamble, no "Based on my search...", just the fact
    `.trim();
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/Jercik/perplexity-agent-mcp'

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