recency_filter
Set time windows for search results to focus on recent information. Choose hour, day, week, or month filters for time-sensitive queries like news and updates.
Instructions
Control the time window for search results. Essential for time-sensitive queries like news, updates, or recent developments. Filter persists until changed.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filter | Yes | Time window: 'hour' for breaking news, 'day' for daily updates, 'week' for recent developments, 'month' for broader recent context, 'none' to include all time periods |
Implementation Reference
- RecencyFilterHandler class that implements the core logic for the recency_filter tool: validates input arguments and delegates to FilterState to set the filter.export class RecencyFilterHandler { constructor(private filterState: FilterState) {} async handle(request: McpRequest) { if (!isValidRecencyArgs(request.params.arguments)) { throw ErrorHandler.createMcpError( ErrorCode.InvalidParams, "Invalid recency filter argument. Filter must be one of: hour, day, week, month, none." ); } const { filter } = request.params.arguments as RecencyArgs; const resultMessage = this.filterState.setRecencyFilter(filter); return { content: [ { type: "text", text: resultMessage, }, ], }; }
- src/schemas/toolSchemas.ts:46-58 (schema)JSON schema definition for the recency_filter tool, including name, description, and input schema with enum validation.name: "recency_filter", description: "Control the time window for search results. Essential for time-sensitive queries like news, updates, or recent developments. Filter persists until changed.", inputSchema: { type: "object", properties: { filter: { type: "string", enum: ["hour", "day", "week", "month", "none"], description: "Time window: 'hour' for breaking news, 'day' for daily updates, 'week' for recent developments, 'month' for broader recent context, 'none' to include all time periods", }, }, required: ["filter"], },
- src/server/PerplexityMcpServer.ts:116-135 (registration)Registration of tool handlers in the MCP server's CallToolRequest handler, dispatching recency_filter to RecencyFilterHandler.handle()switch (request.params.name) { case "search": return this.searchHandler.handle(request); case "domain_filter": return this.domainFilterHandler.handle(request); case "recency_filter": return this.recencyFilterHandler.handle(request); case "clear_filters": return this.filterManagementHandler.handleClearFilters(); case "list_filters": return this.filterManagementHandler.handleListFilters(); case "model_info": return this.modelInfoHandler.handle(request); default: throw new McpError( ErrorCode.MethodNotFound, `Unknown tool: ${request.params.name}` ); } });
- src/server/PerplexityMcpServer.ts:83-83 (registration)Instantiation of RecencyFilterHandler instance in PerplexityMcpServer constructor.this.recencyFilterHandler = new RecencyFilterHandler(this.filterState);
- src/models/FilterState.ts:55-70 (helper)FilterState.setRecencyFilter method, which stores the recency filter value and generates the response message used by the handler.setRecencyFilter(filter: string): string { if (filter === "none") { this.recencyFilter = null; return "Recency filter has been disabled. Searches will include results from any time period."; } this.recencyFilter = filter; const timeDescription = { hour: "hour", day: "24 hours", week: "7 days", month: "30 days" }[filter] || filter; return `Recency filter set to "${filter}". Searches will be limited to content from the last ${timeDescription}.`; }