@perplexity-ai/mcp-server 0.6.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +2 -2
- package/dist/server.js +42 -48
- package/package.json +1 -1
|
@@ -6,14 +6,14 @@
|
|
|
6
6
|
},
|
|
7
7
|
"metadata": {
|
|
8
8
|
"description": "Official Perplexity AI plugin providing real-time web search, reasoning, and research capabilities",
|
|
9
|
-
"version": "0.6.
|
|
9
|
+
"version": "0.6.1"
|
|
10
10
|
},
|
|
11
11
|
"plugins": [
|
|
12
12
|
{
|
|
13
13
|
"name": "perplexity",
|
|
14
14
|
"source": "./",
|
|
15
15
|
"description": "Real-time web search, reasoning, and research through Perplexity's API",
|
|
16
|
-
"version": "0.6.
|
|
16
|
+
"version": "0.6.1",
|
|
17
17
|
"author": {
|
|
18
18
|
"name": "Perplexity AI",
|
|
19
19
|
"email": "api@perplexity.ai"
|
package/dist/server.js
CHANGED
|
@@ -199,27 +199,34 @@ export async function performSearch(query, maxResults = 10, maxTokensPerPage = 1
|
|
|
199
199
|
export function createPerplexityServer(serviceOrigin) {
|
|
200
200
|
const server = new McpServer({
|
|
201
201
|
name: "io.github.perplexityai/mcp-server",
|
|
202
|
-
version: "0.6.
|
|
202
|
+
version: "0.6.1",
|
|
203
203
|
});
|
|
204
|
+
const messageSchema = z.object({
|
|
205
|
+
role: z.string().describe("Role of the message (e.g., system, user, assistant)"),
|
|
206
|
+
content: z.string().describe("The content of the message"),
|
|
207
|
+
});
|
|
208
|
+
const messagesField = z.array(messageSchema).describe("Array of conversation messages");
|
|
209
|
+
const stripThinkingField = z.boolean().optional()
|
|
210
|
+
.describe("If true, removes <think>...</think> tags and their content from the response to save context tokens. Default is false.");
|
|
211
|
+
const responseOutputSchema = {
|
|
212
|
+
response: z.string().describe("The response from Perplexity"),
|
|
213
|
+
};
|
|
214
|
+
// Input schemas
|
|
215
|
+
const messagesOnlyInputSchema = { messages: messagesField };
|
|
216
|
+
const messagesWithStripThinkingInputSchema = { messages: messagesField, strip_thinking: stripThinkingField };
|
|
204
217
|
server.registerTool("perplexity_ask", {
|
|
205
218
|
title: "Ask Perplexity",
|
|
206
219
|
description: "Engages in a conversation using the Sonar API. " +
|
|
207
220
|
"Accepts an array of messages (each with a role and content) " +
|
|
208
221
|
"and returns a chat completion response from the Perplexity model.",
|
|
209
|
-
inputSchema:
|
|
210
|
-
|
|
211
|
-
role: z.string().describe("Role of the message (e.g., system, user, assistant)"),
|
|
212
|
-
content: z.string().describe("The content of the message"),
|
|
213
|
-
})).describe("Array of conversation messages"),
|
|
214
|
-
},
|
|
215
|
-
outputSchema: {
|
|
216
|
-
response: z.string().describe("The chat completion response"),
|
|
217
|
-
},
|
|
222
|
+
inputSchema: messagesOnlyInputSchema,
|
|
223
|
+
outputSchema: responseOutputSchema,
|
|
218
224
|
annotations: {
|
|
219
225
|
readOnlyHint: true,
|
|
220
226
|
openWorldHint: true,
|
|
221
227
|
},
|
|
222
|
-
}, async (
|
|
228
|
+
}, async (args) => {
|
|
229
|
+
const { messages } = args;
|
|
223
230
|
validateMessages(messages, "perplexity_ask");
|
|
224
231
|
const result = await performChatCompletion(messages, "sonar-pro", false, serviceOrigin);
|
|
225
232
|
return {
|
|
@@ -232,22 +239,14 @@ export function createPerplexityServer(serviceOrigin) {
|
|
|
232
239
|
description: "Performs deep research using the Perplexity API. " +
|
|
233
240
|
"Accepts an array of messages (each with a role and content) " +
|
|
234
241
|
"and returns a comprehensive research response with citations.",
|
|
235
|
-
inputSchema:
|
|
236
|
-
|
|
237
|
-
role: z.string().describe("Role of the message (e.g., system, user, assistant)"),
|
|
238
|
-
content: z.string().describe("The content of the message"),
|
|
239
|
-
})).describe("Array of conversation messages"),
|
|
240
|
-
strip_thinking: z.boolean().optional()
|
|
241
|
-
.describe("If true, removes <think>...</think> tags and their content from the response to save context tokens. Default is false."),
|
|
242
|
-
},
|
|
243
|
-
outputSchema: {
|
|
244
|
-
response: z.string().describe("The research response"),
|
|
245
|
-
},
|
|
242
|
+
inputSchema: messagesWithStripThinkingInputSchema,
|
|
243
|
+
outputSchema: responseOutputSchema,
|
|
246
244
|
annotations: {
|
|
247
245
|
readOnlyHint: true,
|
|
248
246
|
openWorldHint: true,
|
|
249
247
|
},
|
|
250
|
-
}, async (
|
|
248
|
+
}, async (args) => {
|
|
249
|
+
const { messages, strip_thinking } = args;
|
|
251
250
|
validateMessages(messages, "perplexity_research");
|
|
252
251
|
const stripThinking = typeof strip_thinking === "boolean" ? strip_thinking : false;
|
|
253
252
|
const result = await performChatCompletion(messages, "sonar-deep-research", stripThinking, serviceOrigin);
|
|
@@ -261,22 +260,14 @@ export function createPerplexityServer(serviceOrigin) {
|
|
|
261
260
|
description: "Performs reasoning tasks using the Perplexity API. " +
|
|
262
261
|
"Accepts an array of messages (each with a role and content) " +
|
|
263
262
|
"and returns a well-reasoned response using the sonar-reasoning-pro model.",
|
|
264
|
-
inputSchema:
|
|
265
|
-
|
|
266
|
-
role: z.string().describe("Role of the message (e.g., system, user, assistant)"),
|
|
267
|
-
content: z.string().describe("The content of the message"),
|
|
268
|
-
})).describe("Array of conversation messages"),
|
|
269
|
-
strip_thinking: z.boolean().optional()
|
|
270
|
-
.describe("If true, removes <think>...</think> tags and their content from the response to save context tokens. Default is false."),
|
|
271
|
-
},
|
|
272
|
-
outputSchema: {
|
|
273
|
-
response: z.string().describe("The reasoning response"),
|
|
274
|
-
},
|
|
263
|
+
inputSchema: messagesWithStripThinkingInputSchema,
|
|
264
|
+
outputSchema: responseOutputSchema,
|
|
275
265
|
annotations: {
|
|
276
266
|
readOnlyHint: true,
|
|
277
267
|
openWorldHint: true,
|
|
278
268
|
},
|
|
279
|
-
}, async (
|
|
269
|
+
}, async (args) => {
|
|
270
|
+
const { messages, strip_thinking } = args;
|
|
280
271
|
validateMessages(messages, "perplexity_reason");
|
|
281
272
|
const stripThinking = typeof strip_thinking === "boolean" ? strip_thinking : false;
|
|
282
273
|
const result = await performChatCompletion(messages, "sonar-reasoning-pro", stripThinking, serviceOrigin);
|
|
@@ -285,28 +276,31 @@ export function createPerplexityServer(serviceOrigin) {
|
|
|
285
276
|
structuredContent: { response: result },
|
|
286
277
|
};
|
|
287
278
|
});
|
|
279
|
+
const searchInputSchema = {
|
|
280
|
+
query: z.string().describe("Search query string"),
|
|
281
|
+
max_results: z.number().min(1).max(20).optional()
|
|
282
|
+
.describe("Maximum number of results to return (1-20, default: 10)"),
|
|
283
|
+
max_tokens_per_page: z.number().min(256).max(2048).optional()
|
|
284
|
+
.describe("Maximum tokens to extract per webpage (default: 1024)"),
|
|
285
|
+
country: z.string().optional()
|
|
286
|
+
.describe("ISO 3166-1 alpha-2 country code for regional results (e.g., 'US', 'GB')"),
|
|
287
|
+
};
|
|
288
|
+
const searchOutputSchema = {
|
|
289
|
+
results: z.string().describe("Formatted search results"),
|
|
290
|
+
};
|
|
288
291
|
server.registerTool("perplexity_search", {
|
|
289
292
|
title: "Search the Web",
|
|
290
293
|
description: "Performs web search using the Perplexity Search API. " +
|
|
291
294
|
"Returns ranked search results with titles, URLs, snippets, and metadata. " +
|
|
292
295
|
"Perfect for finding up-to-date facts, news, or specific information.",
|
|
293
|
-
inputSchema:
|
|
294
|
-
|
|
295
|
-
max_results: z.number().min(1).max(20).optional()
|
|
296
|
-
.describe("Maximum number of results to return (1-20, default: 10)"),
|
|
297
|
-
max_tokens_per_page: z.number().min(256).max(2048).optional()
|
|
298
|
-
.describe("Maximum tokens to extract per webpage (default: 1024)"),
|
|
299
|
-
country: z.string().optional()
|
|
300
|
-
.describe("ISO 3166-1 alpha-2 country code for regional results (e.g., 'US', 'GB')"),
|
|
301
|
-
},
|
|
302
|
-
outputSchema: {
|
|
303
|
-
results: z.string().describe("Formatted search results"),
|
|
304
|
-
},
|
|
296
|
+
inputSchema: searchInputSchema,
|
|
297
|
+
outputSchema: searchOutputSchema,
|
|
305
298
|
annotations: {
|
|
306
299
|
readOnlyHint: true,
|
|
307
300
|
openWorldHint: true,
|
|
308
301
|
},
|
|
309
|
-
}, async (
|
|
302
|
+
}, async (args) => {
|
|
303
|
+
const { query, max_results, max_tokens_per_page, country } = args;
|
|
310
304
|
const maxResults = typeof max_results === "number" ? max_results : 10;
|
|
311
305
|
const maxTokensPerPage = typeof max_tokens_per_page === "number" ? max_tokens_per_page : 1024;
|
|
312
306
|
const countryCode = typeof country === "string" ? country : undefined;
|
package/package.json
CHANGED