perplexity tool
A custom MCP tool that integrates Perplexity AI's API with Claude Desktop, allowing Claude to perform web-based research and provide answers with citations.
A custom MCP tool that integrates Perplexity AI's API with Claude Desktop, allowing Claude to perform web-based research and provide answers with citations.
A custom MCP tool that integrates Perplexity AI's API with Claude Desktop, allowing Claude to perform web-based research and provide answers with citations.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install git
For Windows:
Install Node.js:
brew install node
For Windows:
Verify installations by running:
git --version
node --version
Clone the repository
git clone https://github.com/letsbuildagent/perplexity-tool
cd perplexity-tool
Install dependencies
npm install
Set up your API Key
You have two options:
Option 1 (Quick setup):
- Open server.js
- Find this line:
const PERPLEXITY_API_KEY = "YOUR-API-KEY-HERE";
- Replace with your Perplexity API key
Option 2 (Best practice): - Create a .env file:
# On Mac/Linux:
touch .env
open .env
# On Windows:
notepad .env
Or simply create a new file named .env
in your text editor
- Add your API key to the .env file:
PERPLEXITY_API_KEY=your-api-key-here
- Install dotenv:
npm install dotenv
- Update server.js:
import 'dotenv/config'
const PERPLEXITY_API_KEY = process.env.PERPLEXITY_API_KEY;
~/Library/Application Support/Claude/claude_desktop_config.json
Add this configuration:
{
"mcpServers": {
"perplexity-tool": {
"command": "node",
"args": [
"/full/path/to/perplexity-tool/server.js"
]
}
}
}
Replace /full/path/to
with the actual path where you cloned the repository.
Restart Claude Desktop
Once installed, you can use the tool through Claude with commands like:
You can specify additional parameters:
- temperature
: Controls response randomness (0-2)
- max_tokens
: Limits response length
- search_domain_filter
: Restricts search to specific domains
- search_recency_filter
: Filters by time period (day/week/month/year)
On Mac, make sure Homebrew is in your PATH
Node.js errors:
node --version
Try reinstalling Node.js
API Key issues:
If using Option 2, verify dotenv is installed
Tool not appearing in Claude:
MIT
If you're planning to share your code or make it public: - Don't commit your API key to Git - Use the .env method (Option 2) - Add .env to your .gitignore file
[
{
"description": "Ask a question to Perplexity AI",
"inputSchema": {
"properties": {
"max_tokens": {
"default": 1000,
"description": "Maximum tokens in response",
"type": "integer"
},
"question": {
"description": "The question to ask",
"type": "string"
},
"search_domain_filter": {
"default": [],
"description": "Limit search to specific domains",
"items": {
"type": "string"
},
"type": "array"
},
"search_recency_filter": {
"default": "month",
"description": "Filter results by recency",
"enum": [
"day",
"week",
"month",
"year"
],
"type": "string"
},
"temperature": {
"default": 0.2,
"description": "Response randomness (0-2)",
"type": "number"
}
},
"required": [
"question"
],
"type": "object"
},
"name": "ask_perplexity"
}
]