perplexity
Send a prompt to Perplexity to receive AI-powered answers and engage in conversation. Optionally set a country name to localize responses.
Instructions
Search and interact with Perplexity for AI-powered responses and conversations
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| prompt | Yes | Prompt to send to Perplexity | |
| geo | No | Geolocation of the desired request, expressed as a country name |
Implementation Reference
- PerplexityTool class that handles the tool logic. The register method calls server.registerTool with the name 'perplexity', defines input schema (prompt + geo), and the handler function builds params with target='perplexity', calls sapiClient.scrape(), and returns the response as text content.
export class PerplexityTool extends Tool { toolset = TOOLSET.AI; transformResponse = ({ data }: { data: object }) => { return { data: JSON.stringify(data, null, 2) }; }; register = ({ server, sapiClient, auth }: ToolRegistrationArgs) => { server.registerTool( 'perplexity', { description: 'Search and interact with Perplexity for AI-powered responses and conversations', inputSchema: { prompt: z.string().describe('Prompt to send to Perplexity'), geo: zodGeo, }, annotations: { readOnlyHint: true, openWorldHint: true, }, }, async (scrapingParams: ScrapingMCPParams, extra: ProgressExtra) => { const params = { ...scrapingParams, target: SCRAPER_API_TARGETS.PERPLEXITY, parse: true, } satisfies ScraperAPIParams; const { data } = await sapiClient.scrape<object>({ auth, scrapingParams: params, extra }); const { data: text } = this.transformResponse({ data }); return { content: [ { type: 'text', text, }, ], }; } ); }; } - Input schema for the perplexity tool: 'prompt' (required string) and 'geo' (optional string from zodGeo). Also includes annotations: readOnlyHint and openWorldHint set to true.
{ description: 'Search and interact with Perplexity for AI-powered responses and conversations', inputSchema: { prompt: z.string().describe('Prompt to send to Perplexity'), geo: zodGeo, }, annotations: { readOnlyHint: true, openWorldHint: true, }, }, - src/server/sapi-base-server.ts:96-96 (registration)PerplexityTool instantiated in the allTools array (line 96) which is used in registerTools/registerAllTools methods to register it with the MCP server.
new PerplexityTool(), - src/server/sapi-base-server.ts:18-18 (registration)Import of PerplexityTool class from '../tools' into the server registration file.
PerplexityTool, - src/constants.ts:47-47 (helper)Constant definition: PERPLEXITY = 'perplexity' in the SCRAPER_API_TARGETS enum, used as the target parameter when calling the scraping API.
PERPLEXITY = 'perplexity',