Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .claude-plugin/marketplace.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
},
"metadata": {
"description": "Official Perplexity AI plugin providing real-time web search, reasoning, and research capabilities",
"version": "1.2.1"
"version": "1.3.0"
},
"plugins": [
{
"name": "perplexity",
"source": "./",
"description": "Real-time web search, reasoning, and research through Perplexity's API",
"version": "1.2.1",
"version": "1.3.0",
"author": {
"name": "Perplexity AI",
"email": "api@perplexity.ai"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ The server will be accessible at `http://localhost:8080/mcp`
## Available Tools

### **perplexity_search**
Direct web search using the Perplexity Search API. Returns ranked search results with metadata, perfect for finding current information. Supports recency filters (`search_recency_filter`) and domain restrictions (`search_domain_filter`).
Direct web search using the Perplexity Search API. Returns ranked search results with metadata, perfect for finding current information. Supports recency filters (`search_recency_filter`), domain restrictions (`search_domain_filter`), and [Fast Search](https://docs.perplexity.ai/docs/search/fast-search) (`search_type: "fast"`) for lower latency and cost.

### **perplexity_ask**
General-purpose conversational AI with real-time web search, backed by the Agent API `fast` preset. Great for quick questions and everyday searches.
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@perplexity-ai/mcp-server",
"version": "1.2.1",
"version": "1.3.0",
"mcpName": "ai.perplexity/mcp-server",
"description": "Real-time web search, reasoning, and research through Perplexity's API",
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion plugin.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
"name": "perplexity",
"version": "1.2.1",
"version": "1.3.0",
"description": "Real-time web search, reasoning, and research through Perplexity's API",
"author": {
"name": "Perplexity AI",
Expand Down
4 changes: 2 additions & 2 deletions server.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
"name": "ai.perplexity/mcp-server",
"title": "Perplexity API Platform",
"description": "Real-time web search, reasoning, and research through Perplexity's API",
"version": "1.2.1",
"version": "1.3.0",
"packages": [
{
"registryType": "npm",
"identifier": "@perplexity-ai/mcp-server",
"version": "1.2.1",
"version": "1.3.0",
"transport": {
"type": "stdio"
}
Expand Down
4 changes: 2 additions & 2 deletions src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ describe("Perplexity MCP Server", () => {
headers: {
"Content-Type": "application/json",
Authorization: "Bearer test-api-key",
"User-Agent": "perplexity-mcp/1.2.1",
"User-Agent": "perplexity-mcp/1.3.0",
"X-Source": "pplx-mcp-server",
"X-Pplx-Integration": "perplexity-mcp/1.2.1",
"X-Pplx-Integration": "perplexity-mcp/1.3.0",
},
body: JSON.stringify({
preset: "fast",
Expand Down
19 changes: 13 additions & 6 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import type {
AgentCallHooks,
ApiKeyProvider,
PerplexityServerOptions,
SearchOptions,
SearchResponse,
SearchType,
UndiciRequestOptions
} from "./types.js";
import { AgentResponseSchema, SearchResponseSchema } from "./validation.js";
Expand All @@ -18,7 +20,7 @@ export type { ApiKeyProvider, PerplexityServerOptions } from "./types.js";

const PERPLEXITY_API_KEY = process.env.PERPLEXITY_API_KEY;
const PERPLEXITY_BASE_URL = process.env.PERPLEXITY_BASE_URL || "https://api.perplexity.ai";
const VERSION = "1.2.1";
const VERSION = "1.3.0";

// Agent API presets backing each tool: https://docs.perplexity.ai/docs/agent-api/presets
export const ASK_PRESET = "fast";
Expand Down Expand Up @@ -481,7 +483,7 @@ export async function performSearch(
maxResults: number = 10,
maxTokensPerPage: number = 1024,
country?: string,
filters?: Pick<AgentToolOptions, "search_recency_filter" | "search_domain_filter">,
filters?: SearchOptions,
serviceOrigin?: string,
apiKey?: ApiKeyProvider,
): Promise<string> {
Expand All @@ -492,6 +494,7 @@ export async function performSearch(
...(country && { country }),
...(filters?.search_recency_filter && { search_recency_filter: filters.search_recency_filter }),
...(filters?.search_domain_filter && { search_domain_filter: filters.search_domain_filter }),
...(filters?.search_type && { search_type: filters.search_type }),
};

const response = await makeApiRequest("search", body, serviceOrigin, undefined, apiKey);
Expand Down Expand Up @@ -547,7 +550,7 @@ export function createPerplexityServer(serviceOrigin?: string, serverOptions?: P
{
instructions:
"Perplexity AI server for web-grounded search, research, and reasoning, backed by the Perplexity Agent API. " +
"Use perplexity_search for finding URLs, facts, and recent news. Supports recency filters and domain restrictions. " +
"Use perplexity_search for finding URLs, facts, and recent news. Supports recency filters, domain restrictions, and fast search. " +
"Use perplexity_ask for quick AI-answered questions with citations. Supports recency filters, domain restrictions, and search context size control. " +
"Use perplexity_research for in-depth multi-source investigation (slow, can take minutes). " +
"Use perplexity_reason for complex analysis requiring step-by-step logic. Supports recency filters, domain restrictions, and search context size control. " +
Expand Down Expand Up @@ -727,6 +730,8 @@ export function createPerplexityServer(serviceOrigin?: string, serverOptions?: P
.describe("ISO 3166-1 alpha-2 country code for regional results (e.g., 'US', 'GB')"),
search_recency_filter: searchRecencyFilterField,
search_domain_filter: searchDomainFilterField,
search_type: z.enum(["web", "fast"]).optional()
.describe("Search backend. 'web' (default) is the standard web search. 'fast' is lower latency and lower cost; prefer it for routine lookups inside agent loops, and keep 'web' for rare or ambiguous questions."),
};

const searchOutputSchema = {
Expand All @@ -740,7 +745,7 @@ export function createPerplexityServer(serviceOrigin?: string, serverOptions?: P
description: "Search the web and return a ranked list of results with titles, URLs, snippets, and dates. " +
"Best for: finding specific URLs, checking recent news, verifying facts, discovering sources. " +
"Returns formatted results (title, URL, snippet, date) with no AI synthesis. " +
"Supports recency filters and domain restrictions. " +
"Supports recency filters, domain restrictions, and a lower-latency fast search mode. " +
"For AI-generated answers with citations, use perplexity_ask instead.",
inputSchema: searchInputSchema as any,
outputSchema: searchOutputSchema as any,
Expand All @@ -752,20 +757,22 @@ export function createPerplexityServer(serviceOrigin?: string, serverOptions?: P
},
},
async (args: any) => {
const { query, max_results, max_tokens_per_page, country, search_recency_filter, search_domain_filter } = args as {
const { query, max_results, max_tokens_per_page, country, search_recency_filter, search_domain_filter, search_type } = args as {
query: string;
max_results?: number;
max_tokens_per_page?: number;
country?: string;
search_recency_filter?: "hour" | "day" | "week" | "month" | "year";
search_domain_filter?: string[];
search_type?: SearchType;
};
const maxResults = typeof max_results === "number" ? max_results : 10;
const maxTokensPerPage = typeof max_tokens_per_page === "number" ? max_tokens_per_page : 1024;
const countryCode = typeof country === "string" ? country : undefined;
const filters = {
const filters: SearchOptions = {
...(search_recency_filter && { search_recency_filter }),
...(search_domain_filter && { search_domain_filter }),
...(search_type && { search_type }),
};

const result = await performSearch(query, maxResults, maxTokensPerPage, countryCode, filters, serviceOrigin, serverOptions?.apiKey);
Expand Down
2 changes: 2 additions & 0 deletions src/transport.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ describe("Transport Integration Tests", () => {
query: "test",
search_recency_filter: "week",
search_domain_filter: ["wikipedia.org", "-reddit.com"],
search_type: "fast",
},
});

Expand All @@ -433,6 +434,7 @@ describe("Transport Integration Tests", () => {
query: "test",
search_recency_filter: "week",
search_domain_filter: ["wikipedia.org", "-reddit.com"],
search_type: "fast",
});
} finally {
await client.close();
Expand Down
6 changes: 6 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ export interface SearchRequestBody {
country?: string;
}

export type SearchType = "web" | "fast";

export interface SearchOptions extends Pick<AgentToolOptions, "search_recency_filter" | "search_domain_filter"> {
search_type?: SearchType;
}

export interface AgentToolOptions {
search_recency_filter?: "hour" | "day" | "week" | "month" | "year";
search_domain_filter?: string[];
Expand Down
Loading