search
Search for straightforward questions and basic information using Perplexity's Sonar Pro model. Provide specific details like error messages, code snippets, and platform information for accurate results.
Instructions
Quick search for simple queries using Perplexity's Sonar Pro model. Best for straightforward questions and basic information lookup.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | The search query or question. IMPORTANT: Be extremely specific and include all relevant details: - Include exact error messages, logs, and stack traces if applicable - Provide exact terminology, function names, API names, version numbers - Include relevant code snippets showing the problem or context - Specify platform, OS, framework versions, and environment details - Mention any attempted solutions or workarounds - Provide context about what you're trying to achieve The more specific details you include, the more accurate and helpful the answer will be. If you don't have enough specific information, prompt the user to provide it before using this tool. | |
| force_model | No | Optional: Force using this model even if query seems complex |
Implementation Reference
- src/index.ts:352-360 (handler)Handler logic for the 'search' tool: sets the Perplexity model to 'sonar-pro' and constructs a prompt optimized for simple, specific queries.case "search": { model = "sonar-pro"; prompt = `You are answering a query that contains specific details like error messages, logs, code snippets, exact terminology, version numbers, and context. Use all provided details to give the most accurate answer possible. Query: ${query} Provide a clear, concise answer that directly addresses the specific details in the query.`; break; }
- src/index.ts:266-280 (schema)Input schema defining the parameters for the 'search' tool: required 'query' string and optional 'force_model' boolean.inputSchema: { type: "object", properties: { query: { type: "string", description: "The search query or question. IMPORTANT: Be extremely specific and include all relevant details:\n- Include exact error messages, logs, and stack traces if applicable\n- Provide exact terminology, function names, API names, version numbers\n- Include relevant code snippets showing the problem or context\n- Specify platform, OS, framework versions, and environment details\n- Mention any attempted solutions or workarounds\n- Provide context about what you're trying to achieve\n\nThe more specific details you include, the more accurate and helpful the answer will be.\nIf you don't have enough specific information, prompt the user to provide it before using this tool." }, force_model: { type: "boolean", description: "Optional: Force using this model even if query seems complex", default: false } }, required: ["query"] }
- src/index.ts:264-281 (registration)Registration of the 'search' tool in the MCP server's tools list, including name, description, and input schema.name: "search", description: "Quick search for simple queries using Perplexity's Sonar Pro model. Best for straightforward questions and basic information lookup.", inputSchema: { type: "object", properties: { query: { type: "string", description: "The search query or question. IMPORTANT: Be extremely specific and include all relevant details:\n- Include exact error messages, logs, and stack traces if applicable\n- Provide exact terminology, function names, API names, version numbers\n- Include relevant code snippets showing the problem or context\n- Specify platform, OS, framework versions, and environment details\n- Mention any attempted solutions or workarounds\n- Provide context about what you're trying to achieve\n\nThe more specific details you include, the more accurate and helpful the answer will be.\nIf you don't have enough specific information, prompt the user to provide it before using this tool." }, force_model: { type: "boolean", description: "Optional: Force using this model even if query seems complex", default: false } }, required: ["query"] } },
- src/index.ts:229-258 (helper)Helper method that classifies the query complexity and decides whether to use 'search', upgrade to 'reason', or 'deep_research'.private determineQueryComplexity(query: string): "simple" | "complex" | "research" { // Check for research indicators const researchIndicators = [ "analyze", "research", "investigate", "study", "examine", "explore", "comprehensive", "detailed", "in-depth", "thorough", "compare and contrast", "evaluate", "assess" ]; // Check for complex reasoning indicators const complexIndicators = [ "how", "why", "what if", "explain", "solve", "steps to", "difference between", "compare", "which is better", "pros and cons", "advantages", "disadvantages" ]; const query_lower = query.toLowerCase(); // Check for research patterns if (researchIndicators.some(indicator => query_lower.includes(indicator))) { return "research"; } // Check for complex patterns if (complexIndicators.some(indicator => query_lower.includes(indicator))) { return "complex"; } // Default to simple if no complex/research patterns found return "simple"; }
- src/index.ts:168-224 (helper)Helper method that detects missing details in technical queries and appends suggestions for better responses in tool outputs.private detectMissingDetails(query: string): string[] { const queryLower = query.toLowerCase(); const missingDetails: string[] = []; // Check for error messages, stack traces, or error-related terms const hasErrors = /error|exception|failure|crash|traceback|stack trace|failed/i.test(query) || /Error:|Exception:|at\s+\w+\.\w+/i.test(query); // Check for code snippets (common patterns) const hasCode = /```|function\s+\w+|const\s+\w+|let\s+\w+|var\s+\w+|import\s+|require\(|\.\w+\(/i.test(query) || /[a-z]\w*\([^)]*\)/i.test(query) || // function calls /\w+\.\w+\s*=/i.test(query); // property assignments // Check for version numbers const hasVersions = /\d+\.\d+(\.\d+)?/i.test(query) || /version\s*\d+|v\d+/i.test(query); // Check for specific API/function names (camelCase, PascalCase, or names with dots) const hasSpecificNames = /[A-Z][a-z]+[A-Z]|\.\w+\(|::\w+|api\.|sdk\./i.test(query); // Check for logs or console output const hasLogs = /log|console|output|print|trace|debug/i.test(query) && (query.length > 100 || /\n/.test(query)); // Check for environment/platform details const hasEnvironment = /node|python|java|javascript|typescript|react|vue|angular|linux|windows|macos|ubuntu|docker/i.test(queryLower); // Determine missing details for technical queries if (hasErrors && !hasCode && !hasLogs) { missingDetails.push("code snippets showing the error context"); missingDetails.push("relevant logs or stack traces"); } if (!hasVersions && (hasCode || hasEnvironment)) { missingDetails.push("version numbers (framework, library, runtime versions)"); } if (!hasSpecificNames && (hasCode || hasErrors)) { missingDetails.push("exact function names, API endpoints, or library names"); } if (hasErrors && !hasEnvironment) { missingDetails.push("environment details (OS, runtime version, framework)"); } // If query seems technical/problem-solving but lacks specifics const seemsTechnical = hasErrors || hasCode || /problem|issue|bug|fix|solution|how to|why|debug/i.test(queryLower); if (seemsTechnical && missingDetails.length === 0) { // Still check if it could be more specific if (query.length < 50 && !hasCode && !hasErrors) { missingDetails.push("specific error messages or code snippets"); missingDetails.push("exact terminology and context"); } } return missingDetails; }