### Configure Perplexity MCP Server Source: https://context7.com/dainfernalcoder/perplexity-mcp/llms.txt Configure the Perplexity MCP server in your MCP client settings. This example shows basic setup with an environment variable for the API key. ```json { "mcpServers": { "perplexity": { "command": "npx", "args": ["-y", "perplexity-mcp"], "env": { "PERPLEXITY_API_KEY": "your_api_key" } } } } ``` -------------------------------- ### Use Perplexity Search Tool Source: https://context7.com/dainfernalcoder/perplexity-mcp/llms.txt Examples of using the 'search' tool with the Perplexity MCP server. Includes basic queries, recommended technical details, and forcing the search model. ```javascript // Basic search query const result = await use_mcp_tool({ server_name: "perplexity", tool_name: "search", arguments: { query: "What is the capital of France?" } }); ``` ```javascript // Search with specific technical details (recommended) const technicalResult = await use_mcp_tool({ server_name: "perplexity", tool_name: "search", arguments: { query: "What is the default port for PostgreSQL 15.4 on Ubuntu 22.04?" } }); ``` ```javascript // Force using search model even if query seems complex const forcedResult = await use_mcp_tool({ server_name: "perplexity", tool_name: "search", arguments: { query: "How does React's virtual DOM work?", force_model: true // Prevents automatic routing to reason tool } }); ``` ```javascript // Response includes content and sources // { // content: [{ // type: "text", // text: "The capital of France is Paris...\n\n## Sources\n1: https://..." // }] // } ``` -------------------------------- ### Configure Perplexity MCP Server (Node.js) Source: https://github.com/dainfernalcoder/perplexity-mcp/blob/main/README.md Configure the MCP server to use the Perplexity server by specifying the command, arguments, and environment variables, including the Perplexity API key. This example uses Node.js. ```json { "mcpServers": { "perplexity": { "command": "node", "args": ["/path/to/perplexity-server/build/index.js"], "env": { "PERPLEXITY_API_KEY": "YOUR_API_KEY_HERE" }, "disabled": false, "autoApprove": [] } } } ``` -------------------------------- ### Configure Perplexity MCP Server (NPX) Source: https://github.com/dainfernalcoder/perplexity-mcp/blob/main/README.md Configure the MCP server to use the Perplexity server via NPX, which avoids local installation. Specify the command, arguments, and environment variables, including the Perplexity API key. ```json { "mcpServers": { "perplexity": { "command": "npx", "args": [ "-y", "perplexity-mcp" ], "env": { "PERPLEXITY_API_KEY": "your_api_key" } } } } ``` -------------------------------- ### Conduct Deep Research with Focus Areas Source: https://context7.com/dainfernalcoder/perplexity-mcp/llms.txt Use the 'deep_research' tool for comprehensive research. Specify the main query and optional `focus_areas` to guide the research towards specific subtopics. ```javascript // Comprehensive research with focus areas const researchResult = await use_mcp_tool({ server_name: "perplexity", tool_name: "deep_research", arguments: { query: "The impact of quantum computing on cryptography", focus_areas: [ "Post-quantum cryptographic algorithms", "Timeline for quantum threats to current encryption", "Practical mitigation strategies for organizations" ] } }); ``` -------------------------------- ### Compare Technologies with Reason Tool Source: https://context7.com/dainfernalcoder/perplexity-mcp/llms.txt Use the 'reason' tool to compare and contrast technologies. Provide a detailed query outlining the comparison points and desired output format. ```javascript // Compare technologies with reasoning const comparisonResult = await use_mcp_tool({ server_name: "perplexity", tool_name: "reason", arguments: { query: "Compare and contrast REST and GraphQL APIs, explaining their pros and cons for a mobile application with limited bandwidth" } }); ``` -------------------------------- ### Configure Perplexity MCP Server (Command-Line API Key) Source: https://github.com/dainfernalcoder/perplexity-mcp/blob/main/README.md Configure the MCP server to use the Perplexity server, passing the API key directly as a command-line argument. This is a fallback if the API key cannot be read from the environment. ```json { "mcpServers": { "perplexity": { "command": "node", "args": [ "/path/to/perplexity-server/build/index.js", "--api-key", "your_api_key_here" ], "disabled": false, "autoApprove": [] } } } ``` -------------------------------- ### Use Perplexity Search Tool Source: https://github.com/dainfernalcoder/perplexity-mcp/blob/main/README.md Use this tool for quick searches and basic information lookup. It's best for straightforward questions requiring direct answers. The `force_model` option is optional. ```javascript const result = await use_mcp_tool({ server_name: "perplexity", tool_name: "search", arguments: { query: "What is the capital of France?", force_model: false // Optional: force using this model even if query seems complex } }); ``` -------------------------------- ### Perplexity API Key Configuration Options Source: https://context7.com/dainfernalcoder/perplexity-mcp/llms.txt Provides three methods for configuring the Perplexity API key: environment variable (preferred), command-line argument, or .env file with --cwd flag. Ensure the API key format is correct. ```json // Option 1: Environment variable (preferred) { "mcpServers": { "perplexity": { "command": "npx", "args": ["-y", "perplexity-mcp"], "env": { "PERPLEXITY_API_KEY": "pplx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" } } } } ``` ```json // Option 2: Command-line argument { "mcpServers": { "perplexity": { "command": "node", "args": [ "/path/to/perplexity-server/build/index.js", "--api-key", "pplx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" ] } } } ``` ```json // Option 3: .env file with --cwd (reads PERPLEXITY_API_KEY from .env) { "mcpServers": { "perplexity": { "command": "node", "args": [ "/path/to/perplexity-server/build/index.js", "--cwd", "/path/to/your/project" ] } } } ``` -------------------------------- ### Configure Perplexity MCP Server (.env File) Source: https://github.com/dainfernalcoder/perplexity-mcp/blob/main/README.md Configure the MCP server to read API keys from an explicit .env file using the `--cwd` argument. This is a fallback method for providing environment variables. ```json { "mcpServers": { "perplexity": { "command": "node", "args": [ "/path/to/perplexity-server/build/index.js", "--cwd", "/path/to/your/project" ], "disabled": false, "autoApprove": [] } } } ``` -------------------------------- ### Use Perplexity Reason Tool Source: https://github.com/dainfernalcoder/perplexity-mcp/blob/main/README.md Handles complex, multi-step tasks requiring detailed analysis, such as explanations and comparisons. The `force_model` option is optional. ```javascript const result = await use_mcp_tool({ server_name: "perplexity", tool_name: "reason", arguments: { query: "Compare and contrast REST and GraphQL APIs, explaining their pros and cons", force_model: false // Optional: force using this model even if query seems simple } }); ``` -------------------------------- ### Analyze Architecture with Reason Tool Source: https://context7.com/dainfernalcoder/perplexity-mcp/llms.txt Employ the 'reason' tool for architectural decision analysis. Specify the architectures to compare and the context, such as team size and project type. The `force_model` argument can be set to `false` to allow the model to choose the best approach. ```javascript // Architectural decision analysis const architectureResult = await use_mcp_tool({ server_name: "perplexity", tool_name: "reason", arguments: { query: "What are the advantages and disadvantages of using microservices vs monolithic architecture for a startup with a team of 5 developers building an e-commerce platform?", force_model: false } }); ``` -------------------------------- ### Automatic Query Routing to Reason Model Source: https://context7.com/dainfernalcoder/perplexity-mcp/llms.txt Queries containing complexity indicators like 'how', 'explain', or 'difference' are automatically upgraded from 'search' to the 'reason' tool (Sonar Reasoning Pro). ```javascript // This query will be auto-routed to "reason" (Sonar Reasoning Pro) // because it contains complexity indicators: "how", "explain", "difference" await use_mcp_tool({ server_name: "perplexity", tool_name: "search", // Will be upgraded to "reason" automatically arguments: { query: "How does React's reconciliation algorithm work and what's the difference between React 17 and React 18?" } }); ``` -------------------------------- ### Perform Deep Research with deep_research Tool Source: https://github.com/dainfernalcoder/perplexity-mcp/blob/main/examples/deep-research.md Use this snippet to initiate a deep research query on a specific topic. Provide a detailed query and optional focus areas for a comprehensive analysis. ```javascript const result = await use_mcp_tool({ server_name: "perplexity-ask", tool_name: "deep_research", arguments: { query: "The impact of quantum computing on cryptography", focus_areas: [ "Post-quantum cryptographic algorithms", "Timeline for quantum threats to current encryption", "Practical mitigation strategies for organizations" ] } }); console.log(result); ``` -------------------------------- ### Use Perplexity Deep Research Tool Source: https://github.com/dainfernalcoder/perplexity-mcp/blob/main/README.md Conducts comprehensive research and generates detailed reports for in-depth analysis. The `force_model` option is optional. You can specify `focus_areas` for more targeted research. ```javascript const result = await use_mcp_tool({ server_name: "perplexity", tool_name: "deep_research", arguments: { query: "The impact of quantum computing on cryptography", focus_areas: [ "Post-quantum cryptographic algorithms", "Timeline for quantum threats", "Practical mitigation strategies" ], force_model: false // Optional: force using this model even if query seems simple } }); ``` -------------------------------- ### Query with Specific Details Source: https://context7.com/dainfernalcoder/perplexity-mcp/llms.txt Providing specific details such as error messages, code snippets, versions, and environment information in the query leads to more precise and actionable responses, avoiding the 'missing details' note. ```javascript // Better query with specific details - no missing details note const specificResult = await use_mcp_tool({ server_name: "perplexity", tool_name: "reason", arguments: { query: `TypeError: Cannot read property 'map' of undefined at UserList (UserList.tsx:15:23) Code: \`\`\`typescript // UserList.tsx const UserList = ({ users }) => { return users.map(user =>