Perplexity Scrape
Allows querying Perplexity AI for web and academic search and category-based research, including model selection and optional citations, through MCP tools and an OpenAI-compatible REST API.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
Perplexity Scrape
Access premium AI models (Claude, GPT, Gemini, Grok) through Perplexity AI — as an MCP server for AI assistants or an OpenAI-compatible REST API for any application.
Transform your Perplexity Pro subscription into a powerful API backend. Use cutting-edge AI models like Claude 4.5 Sonnet, GPT-5.2, Gemini 3, and Grok 4.1 through a single unified interface — no separate API keys needed.
Table of Contents
Related MCP server: Perplexity API Platform MCP Server
Features
Feature | Description |
MCP Server | 6 specialized search tools for AI assistants (Claude Desktop, OpenCode, etc.) |
REST API | OpenAI-compatible |
Multi-Model | Access Claude, GPT, Gemini, Grok, Kimi through a single Perplexity account |
Web Search | Real-time internet search with citations and sources |
Academic Search | Scholarly sources from academic databases |
Docker Ready | Pre-built images on GitHub Container Registry |
Optional Auth | Protect endpoints with API key authentication |
Quick Start
Docker (recommended):
docker run -d -p 8045:8045 \
-e PERPLEXITY_SESSION_TOKEN=your_token \
ghcr.io/ardzz/perplexity-scrape:latestLocal:
pip install -r requirements.txt
python unified_service.pyThen use the API:
curl http://localhost:8045/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{"model": "claude-4.5-sonnet-thinking", "messages": [{"role": "user", "content": "Hello!"}]}'Setup
Install dependencies:
pip install -r requirements.txtConfigure
.envfile with your Perplexity credentials:
PERPLEXITY_SESSION_TOKEN=your_session_token
# (optional) PERPLEXITY_CF_CLEARANCE=your_cf_clearance
# (optional) PERPLEXITY_VISITOR_ID=your_visitor_id
# (optional) PERPLEXITY_SESSION_ID=your_session_idGetting Cookies: Use the Perplexity Cookies Extension to easily extract these values, or manually copy them from browser DevTools → Network tab → Copy cookies from any Perplexity request.
MCP Server
Run MCP Server (stdio mode - default)
python mcp_service.pyThis runs the MCP server in stdio mode, suitable for integration with MCP clients like Claude Desktop.
Run MCP Server (HTTP mode)
MCP_TRANSPORT_MODE=http python mcp_service.pyThis runs the MCP server with streamable-http transport at http://127.0.0.1:8000/mcp, suitable for remote access.
MCP Client Configuration
Claude Desktop (stdio mode)
{
"mcpServers": {
"perplexity": {
"command": "python",
"args": ["/path/to/perplexity-mcp/mcp_service.py"],
"env": {}
}
}
}OpenCode (stdio local mode)
{
"perplexity": {
"type": "local",
"command": "python",
"args": ["/path/to/perplexity-mcp/mcp_service.py"],
"enabled": true
}
}OpenCode (remote HTTP mode)
{
"perplexity": {
"type": "remote",
"url": "https://your-server.com/mcp",
"enabled": true,
"headers": {
"X-API-Key": "your-api-key"
}
}
}Generic MCP Client (HTTP mode)
Connect to http://127.0.0.1:8000/mcp (local) or your deployed URL.
MCP HTTP Examples
Initialize session:
curl -X POST http://localhost:8000/mcp \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-H "X-API-Key: your-api-key" \
-d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}'List available tools:
curl -X POST http://localhost:8000/mcp \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-H "X-API-Key: your-api-key" \
-H "Mcp-Session-Id: YOUR_SESSION_ID" \
-d '{"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}'Call a tool:
curl -X POST http://localhost:8000/mcp \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-H "X-API-Key: your-api-key" \
-H "Mcp-Session-Id: YOUR_SESSION_ID" \
-d '{
"jsonrpc": "2.0",
"id": 3,
"method": "tools/call",
"params": {
"name": "perplexity_search",
"arguments": {"query": "What is MCP?"}
}
}'Note: The
X-API-Keyheader is only required whenAPI_KEYis set in your.envfile. TheMcp-Session-Idheader is returned in the initialize response and must be included in subsequent requests.
Available MCP Tools
Tool | Description |
| Web/scholar search; returns answer text. Citations and related queries are opt-in. |
| Topic research with category-specific prompts. Citations and related queries are opt-in. |
Token efficiency (v1.0.0): Citations and related queries are now opt-in via
include_citations=Trueandinclude_related=True. Default responses contain onlytext— typical sessions consume ~85% fewer tokens than v0.x. Pass the flags when you actually need sources.
Search examples
# Default: text-only response (cheapest)
perplexity_search(query="What is the capital of France?")
# Web search with citations
perplexity_search(query="latest GPT-5 benchmarks", include_citations=True)
# Academic-only search
perplexity_search(query="contrastive learning survey", sources=["scholar"], include_citations=True)
# Combined web + academic
perplexity_search(query="vector databases", sources=["web", "scholar"], include_citations=True)Model Selection: Both tools accept the
model_preferenceparameter. Use any model ID from the Available Models section. Default:claude46sonnetthinking.
Migration from v0.x
v0.x tool | v1.0.0 equivalent |
|
|
|
|
|
|
|
|
|
|
|
|
Research Categories
The perplexity_research tool supports 21 specialized categories organized into four groups:
General
Category | Best For |
| Non-programming topics; academic-style overview with definitions and citations |
Programming Categories
Category | Best For |
| API/SDK documentation and usage patterns |
| Library/framework guides and integration |
| Step-by-step implementation guidance |
| Troubleshooting and debugging approaches |
| Technical comparisons between options |
| General programming research (default) |
ML Core Categories
Category | Best For |
| Neural network architectures and design patterns |
| Training optimization, hyperparameters, convergence |
| ML/DL theoretical concepts and foundations |
| PyTorch, TensorFlow, JAX framework usage |
| Mathematical foundations (linear algebra, calculus, probability) |
| Research paper analysis and implementation |
| ML model debugging, loss issues, gradient problems |
ML Dataset Categories
Category | Best For |
| Structured/tabular data (CSV, databases, feature engineering) |
| Image datasets (classification, detection, segmentation) |
| Text/NLP datasets (classification, NER, generation) |
| Time series data (forecasting, anomaly detection) |
| Audio datasets (speech, music, sound classification) |
| Graph-structured data (social networks, molecules) |
| Multi-modal datasets (image+text, video+audio) |
Examples:
# Programming research
perplexity_research(topic="FastAPI authentication", category="implementation")
# ML framework research
perplexity_research(topic="PyTorch DataLoader optimization", category="ml_frameworks")
# ML dataset research
perplexity_research(topic="CIFAR-10 image classification", category="ml_dataset_image")OpenAI-Compatible REST API
Run REST Server
python rest_api_service.pyDefault: http://127.0.0.1:8045
Endpoints
Method | Endpoint | Description |
POST |
| Create chat completion (OpenAI-compatible) |
GET |
| List available models |
GET |
| Health check |
GET |
| Swagger UI documentation |
cURL Example
curl -X POST http://127.0.0.1:8045/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "claude-4.5-sonnet-thinking",
"messages": [
{"role": "user", "content": "What is quantum computing?"}
]
}'Python Example
from openai import OpenAI
client = OpenAI(
base_url="http://127.0.0.1:8045/v1",
api_key="not-needed" # Or your API_KEY if auth enabled
)
response = client.chat.completions.create(
model="claude-4.5-sonnet-thinking",
messages=[
{"role": "user", "content": "Explain machine learning"}
]
)
print(response.choices[0].message.content)Combined Server (REST API + MCP)
For convenience, you can run both the REST API and MCP HTTP server on the same port using the combined server:
python unified_service.pyThis serves:
REST API at
http://127.0.0.1:8045/v1/...MCP HTTP at
http://127.0.0.1:8045/mcpDocumentation at
http://127.0.0.1:8045/docs
Combined Server Examples
REST API (same as standalone):
curl http://localhost:8045/v1/modelsMCP Initialize:
curl -X POST http://localhost:8045/mcp \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}'MCP List Tools:
curl -X POST http://localhost:8045/mcp \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-H "Mcp-Session-Id: YOUR_SESSION_ID" \
-d '{"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}'Note: The
Mcp-Session-Idheader is returned in the initialize response and must be included in subsequent requests.
Docker Deployment
Pre-built Docker images are available on GitHub Container Registry.
Available Images
Image | Description | Port |
| Combined server (REST API + MCP) | 8045 |
| REST API only | 8045 |
| MCP HTTP server only | 8000 |
Quick Start with Docker
docker run -d \
--name perplexity \
-p 8045:8045 \
-e PERPLEXITY_SESSION_TOKEN=your_session_token \
-e API_KEY=your-api-key \
ghcr.io/ardzz/perplexity-scrape:latestDocker Compose
version: '3.8'
services:
perplexity:
image: ghcr.io/ardzz/perplexity-scrape:latest
container_name: perplexity
restart: unless-stopped
ports:
- "8045:8045"
environment:
# Perplexity credentials (only SESSION_TOKEN is required)
- PERPLEXITY_SESSION_TOKEN=your_session_token
# - PERPLEXITY_CF_CLEARANCE=your_cf_clearance # optional
# - PERPLEXITY_VISITOR_ID=your_visitor_id # optional
# - PERPLEXITY_SESSION_ID=your_session_id # optional
# Optional settings
- API_KEY=your-api-key
- DEFAULT_MODEL=claude45sonnetthinking
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8045/health"]
interval: 30s
timeout: 10s
retries: 3Building from Source
# Combined server (recommended)
docker build -f docker/Dockerfile.combined -t perplexity-scrape .
# REST API only
docker build -f docker/Dockerfile.openai -t perplexity-openai .
# MCP server only
docker build -f docker/Dockerfile.mcp -t perplexity-mcp .Deployment Platforms
The Docker images work with any container platform:
Coolify - Set environment variables in the deployment settings
Railway - Use the Docker image URL directly
Fly.io - Deploy with
fly launch --image ghcr.io/ardzz/perplexity-scrapeDigitalOcean App Platform - Use container registry image
AWS ECS / Google Cloud Run / Azure Container Apps - Standard container deployment
Authentication
API key authentication is optional and disabled by default. When enabled, it protects the /v1/chat/completions and /v1/models endpoints.
Enable Authentication
Generate a secure API key:
python scripts/generate_api_key.pyAdd the key to your
.envfile:
API_KEY=your-generated-key-hereRestart the server. All protected endpoints now require the
X-API-Keyheader.
Using Authentication
cURL:
curl -X POST http://127.0.0.1:8045/v1/chat/completions \
-H "Content-Type: application/json" \
-H "X-API-Key: your-api-key" \
-d '{"model": "claude-4.5-sonnet", "messages": [{"role": "user", "content": "Hello"}]}'Python (OpenAI client):
from openai import OpenAI
client = OpenAI(
base_url="http://127.0.0.1:8045/v1",
api_key="your-api-key", # Will be sent as Authorization header
default_headers={"X-API-Key": "your-api-key"} # Required header
)Python (httpx):
import httpx
response = httpx.post(
"http://127.0.0.1:8045/v1/chat/completions",
headers={"X-API-Key": "your-api-key"},
json={"model": "claude-4.5-sonnet", "messages": [...]}
)Disable Authentication
Set API_KEY to empty or remove it from .env:
API_KEY=Available Models
Perplexity Native
Model ID | Description |
| Perplexity Sonar (experimental) |
| Perplexity Alpha - faster responses |
Claude (Anthropic)
Model ID | Description |
| Claude 4.5 Sonnet |
| Claude 4.5 Sonnet with Reasoning (default) |
| Claude 4.5 Opus |
| Claude 4.5 Opus with Reasoning |
Gemini (Google)
Model ID | Description |
| Gemini 3 Flash |
| Gemini 3 Flash with Reasoning |
| Gemini 3 Pro with Reasoning |
GPT (OpenAI)
Model ID | Description |
| GPT 5.2 |
| GPT 5.2 with Reasoning |
Grok (xAI)
Model ID | Description |
| Grok 4.1 |
| Grok 4.1 with Reasoning |
Kimi (Moonshot)
Model ID | Description |
| Kimi K2.5 Thinking |
Environment Variables
Variable | Default | Description |
| (required) | Session token from Perplexity cookies |
| (optional) | Cloudflare clearance token |
| (optional) | Visitor ID from Perplexity |
| (optional) | Session ID from Perplexity |
|
| REST API host |
|
| REST API port |
|
| Default model for requests |
|
| Search mode (copilot/search) |
|
| Search focus (internet/academic) |
| (empty) | API key for authentication (empty = auth disabled) |
|
| MCP transport mode ( |
|
| MCP HTTP server host (when mode=http) |
|
| MCP HTTP server port (when mode=http) |
|
| Enable DNS rebinding protection for MCP |
| (empty) | Allowed hosts when host check enabled (comma-separated) |
License
MIT
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Real-time web search, reasoning, and research through Perplexity's API
Enable AI assistants to perform web searches using Perplexity's Sonar Pro.
Web search, page fetch and cited research for AI agents: 26 engines, 8 tools, one key, from $15/mo.
Give your AI today's internet: live web search, real-time breaking news, full articles and papers.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceProvides AI-powered search, research, and reasoning capabilities through integration with Perplexity.ai, offering three specialized tools: general conversational AI, deep research with citations, and advanced reasoning.2MIT
- AlicenseAqualityCmaintenanceProvides AI assistants with real-time web search, reasoning, and research capabilities through Perplexity's Sonar models and Search API. Supports quick searches, deep research, advanced reasoning, and direct web search with ranked results.475,070 npm2,639MIT
- FlicenseBqualityDmaintenanceEnables AI assistants to perform real-time web and academic searches using Perplexity's Sonar API.2-
- AlicenseAqualityDmaintenanceProvides AI assistants with real-time web search, reasoning, and research capabilities through Perplexity's Agent API and Search API, enabling tools for search, conversational Q&A, deep research, and advanced reasoning.4MIT