Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/perplexityai/modelcontextprotocol/llms.txt

Use this file to discover all available pages before exploring further.

Overview

The perplexity_reason tool provides advanced reasoning and analytical capabilities using the Sonar Reasoning Pro model. It excels at tasks requiring step-by-step logic, mathematical reasoning, and complex analytical thinking.
This tool uses the sonar-reasoning-pro model, which combines chain-of-thought reasoning with real-time web search for grounded, logical analysis.

Use Cases

  • Mathematical problem solving
  • Logical puzzles and brain teasers
  • Product or option comparisons
  • Complex argument analysis
  • Scientific reasoning
  • Code debugging and optimization
  • Strategic decision making

Parameters

messages
array
required
Array of conversation messages in OpenAI format.Each message must have:
  • role: One of "system", "user", or "assistant"
  • content: The message text (string)
Example:
[
  { "role": "user", "content": "Compare the time complexity of merge sort vs quick sort" }
]
strip_thinking
boolean
default:false
If true, removes <think>...</think> tags and their content from the response.The model includes step-by-step reasoning in <think> tags. Stripping these saves context tokens but hides the reasoning process.Default: false (shows thinking process)Example: true
search_recency_filter
enum
Filter search results by how recent they are.Options: "hour", "day", "week", "month", "year"
  • "hour": Very recent information (last 60 minutes)
  • "day": Today’s updates (last 24 hours)
  • "week": This week’s content
  • "month": This month’s content
  • "year": This year’s content
Example: "week"
search_domain_filter
array
Restrict or exclude specific domains from search results.
  • Include domains: ["wikipedia.org", "arxiv.org"]
  • Exclude domains: ["-reddit.com", "-quora.com"] (use - prefix)
Example: ["mathworld.wolfram.com", "arxiv.org"]
search_context_size
enum
Control how much web context is retrieved for reasoning.Options: "low", "medium", "high"
  • "low" (default): Fastest, minimal context
  • "medium": Balanced speed and context
  • "high": Most comprehensive, slower
Example: "high"

Response Format

The tool returns a reasoned analysis with inline citations and optional thinking process:
response
string
Analytical response with:
  • Optional <think>...</think> tags showing step-by-step reasoning (if strip_thinking: false)
  • Logical analysis with numbered citation references [1], [2], etc.
  • Citations list appended at the end
Response Structure:
[Optional: <think>step-by-step reasoning</think>]

Analytical content with inline citations[1][2]...

Citations:
[1] https://source1.com
[2] https://source2.com

Example Response

<think>
To compare merge sort and quick sort time complexity:
1. Analyze worst-case scenarios
2. Consider average-case performance
3. Examine space complexity
4. Discuss practical implications
</think>

Time Complexity Comparison: Merge Sort vs Quick Sort

Worst-Case Analysis:
- Merge Sort: O(n log n) in all cases[1]
- Quick Sort: O(n²) when poorly pivoted[2]

Merge sort maintains consistent O(n log n) performance regardless of input 
order because it always divides the array into equal halves[1]. Quick sort's 
worst case occurs with already sorted data or when the pivot consistently 
selects the smallest/largest element[2].

Average-Case Performance:
Both algorithms achieve O(n log n) average time complexity[3]. However, quick 
sort often performs better in practice due to:
1. Better cache locality (in-place sorting)[4]
2. Smaller constant factors in the O(n log n) term[5]

Space Complexity:
- Merge Sort: O(n) auxiliary space[1]
- Quick Sort: O(log n) for recursion stack[2]

Practical Considerations:
Quick sort is generally preferred for in-memory sorting due to its space 
efficiency and cache performance[4]. Merge sort is preferred when:
- Worst-case guarantees are critical[1]
- Sorting linked lists (no random access penalty)[6]
- External sorting (disk-based operations)[7]

Citations:
[1] https://mathworld.wolfram.com/MergeSort.html
[2] https://mathworld.wolfram.com/Quicksort.html
[3] https://bigocheatsheet.com
[4] https://stackoverflow.com/questions/cache-locality-sorting
[5] https://cstheory.stackexchange.com/constant-factors
[6] https://wikipedia.org/wiki/Merge_sort
[7] https://db.cs.berkeley.edu/external-sorting

Usage Examples

const result = await use_mcp_tool(
  "perplexity",
  "perplexity_reason",
  {
    messages: [
      {
        role: "user",
        content: "If a train leaves New York at 3pm traveling 80mph, and another leaves Boston at 4pm traveling 100mph, when will they meet?"
      }
    ]
  }
);

Common Patterns

Mathematical Problem Solving

Solve complex math problems with step-by-step reasoning:
const solution = await use_mcp_tool(
  "perplexity",
  "perplexity_reason",
  {
    messages: [
      {
        role: "user",
        content: "Solve: If f(x) = x² + 3x - 2 and g(x) = 2x + 1, find (f ∘ g)(x) and simplify."
      }
    ]
  }
);

Comparative Analysis

Compare options with detailed reasoning:
const comparison = await use_mcp_tool(
  "perplexity",
  "perplexity_reason",
  {
    messages: [
      {
        role: "user",
        content: "Compare React Server Components vs traditional SSR: architecture, performance, developer experience, and use cases."
      }
    ],
    search_recency_filter: "month",
    search_domain_filter: ["reactjs.org", "nextjs.org", "vercel.com"]
  }
);

Logical Puzzle Solving

Work through logic puzzles systematically:
const puzzle = await use_mcp_tool(
  "perplexity",
  "perplexity_reason",
  {
    messages: [
      {
        role: "user",
        content: "Three people (A, B, C) each wear a hat that's either red or blue. Each can see the others' hats but not their own. A says 'I don't know my color.' B says 'I don't know my color.' C says 'I know my color!' What color is C's hat and why?"
      }
    ]
  }
);

Strategic Decision Making

Analyze complex decisions with multiple factors:
const decision = await use_mcp_tool(
  "perplexity",
  "perplexity_reason",
  {
    messages: [
      {
        role: "system",
        content: "Analyze decisions using: 1) Pros and cons, 2) Risk assessment, 3) Long-term implications, 4) Recommendation with reasoning."
      },
      {
        role: "user",
        content: "Should a startup choose microservices or monolithic architecture?"
      }
    ],
    search_context_size: "high"
  }
);

Advanced Usage

Multi-step Reasoning Chain

Build complex reasoning across multiple turns:
// Step 1: Establish premises
const step1 = await use_mcp_tool(
  "perplexity",
  "perplexity_reason",
  {
    messages: [
      { role: "user", content: "What are the key principles of quantum entanglement?" }
    ]
  }
);

// Step 2: Apply reasoning
const step2 = await use_mcp_tool(
  "perplexity",
  "perplexity_reason",
  {
    messages: [
      { role: "user", content: "What are the key principles of quantum entanglement?" },
      { role: "assistant", content: step1.response },
      { role: "user", content: "Given these principles, explain why quantum teleportation doesn't violate the speed of light." }
    ]
  }
);

Debugging with Context

Provide code context for detailed analysis:
const debug = await use_mcp_tool(
  "perplexity",
  "perplexity_reason",
  {
    messages: [
      {
        role: "system",
        content: "Analyze code for: 1) Bugs, 2) Performance issues, 3) Best practices violations, 4) Security concerns."
      },
      {
        role: "user",
        content: `
Analyze this React component:

function UserList() {
  const [users, setUsers] = useState([]);
  
  fetch('/api/users')
    .then(res => res.json())
    .then(setUsers);
  
  return users.map(u => <div key={u.name}>{u.name}</div>);
}
        `
      }
    ],
    search_domain_filter: ["react.dev", "stackoverflow.com"]
  }
);

Understanding Thinking Tags

When strip_thinking: false (default), responses include reasoning process:
<think>
To solve this optimization problem:
1. Identify the objective function
2. List constraints
3. Determine feasible region
4. Apply linear programming techniques
5. Verify solution satisfies all constraints
</think>

[Detailed solution with steps...]
Thinking tags reveal:
  • Problem-solving strategy
  • Intermediate calculations
  • Logical deductions
  • Error checking
Set strip_thinking: true to get only the final answer.

Tips and Best Practices

Keep thinking visible for learning: Leave strip_thinking: false when you want to understand the reasoning process, especially for educational purposes.
Use domain filters for technical topics: Filter to authoritative sources like Stack Overflow, official docs, or academic sites for better reasoning quality.
Provide clear problem statements: Well-defined problems with specific constraints yield better reasoned responses.
Leverage system prompts: Guide the reasoning format with system messages (e.g., “Show all steps”, “Compare pros and cons”).
Increase context for complex reasoning: Set search_context_size: "high" for problems requiring extensive background knowledge.
While perplexity_reason excels at logical analysis, it’s not a substitute for formal mathematical proofs or certified calculations in critical applications.

Comparison with Other Tools

Featureperplexity_reasonperplexity_askperplexity_research
Modelsonar-reasoning-prosonar-prosonar-deep-research
SpeedMedium (5-15s)Fast (< 5s)Slow (30s+)
ReasoningChain-of-thoughtStandardDeep analysis
Best ForLogic & mathQuick Q&ALiterature reviews
Thinking TagsYes (optional)NoYes (optional)
Recency FilterYesYesNo
Domain FilterYesYesNo
Context SizeAdjustableAdjustableHigh (default)
perplexity_reason is optimized for analytical tasks requiring logical thinking. For fact-based questions, use perplexity_ask. For comprehensive research, use perplexity_research.

Error Handling

Common errors and solutions:
  • Invalid messages array: Ensure each message has role and content fields
  • Invalid role: Must be "system", "user", or "assistant"
  • Invalid recency filter: Must be hour, day, week, month, or year
  • Invalid context size: Must be low, medium, or high
  • Network errors: Check API key and connectivity

Performance Optimization

Strip Thinking

Enable strip_thinking: true to reduce response size by 15-25%

Filter Domains

Limit to relevant domains to speed up search and improve quality

Adjust Context

Use search_context_size: "low" for faster responses on simple problems

Cache Results

Store solutions to common problems to avoid repeated API calls

Ask Tool

Use for straightforward factual questions without complex reasoning

Research Tool

Use for comprehensive multi-source research instead of analytical reasoning

Search Tool

Use to find sources and documentation before reasoning

Tools Overview

Compare all available tools and their capabilities

Build docs developers (and LLMs) love